Skip to content

Commit 5a10032

Browse files
author
karmaking
committed
create build action
1 parent 36278f2 commit 5a10032

File tree

4 files changed

+111
-0
lines changed

4 files changed

+111
-0
lines changed

.dockerignore

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
Dockerfile
2+
.dockerignore
3+
.git
4+
.gitignore
5+
.gitattributes
6+
README.md
7+
.npmrc
8+
.prettierrc
9+
.eslintrc.cjs
10+
.graphqlrc
11+
.editorconfig
12+
.svelte-kit
13+
.vscode
14+
.env.example
15+
node_modules
16+
build
17+
package
18+
**/.env

.github/dependabot.yml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
2+
version: 2
3+
updates:
4+
5+
- package-ecosystem: "github-actions"
6+
directory: "/"
7+
schedule:
8+
interval: "weekly"
9+
10+
- package-ecosystem: "npm"
11+
directory: "/"
12+
schedule:
13+
interval: "daily"
14+
allow:
15+
- dependency-type: "direct"
16+
ignore:
17+
- dependency-type: "indirect"
18+
commit-message:
19+
prefix: "chore"
20+
security-updates-only: true
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
name: build and publish container
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
env:
9+
DOCKER_HUB_ORGANIZATION: ${{ vars.DOCKER_HUB_ORGANIZATION }}
10+
DOCKER_HUB_REPOSITORY: obp-portal
11+
12+
13+
jobs:
14+
build:
15+
runs-on: ubuntu-latest
16+
steps:
17+
18+
- uses: actions/checkout@v4
19+
- name: Build the Docker image with latest tag
20+
run: |
21+
echo "${{ secrets.DOCKER_HUB_TOKEN }}" | docker login -u "${{ secrets.DOCKER_HUB_USERNAME }}" --password-stdin docker.io
22+
docker build . --tag docker.io/${{ env.DOCKER_HUB_ORGANIZATION }}/${{ env.DOCKER_HUB_REPOSITORY }}:$GITHUB_SHA --tag docker.io/${{ env.DOCKER_HUB_ORGANIZATION }}/${{ env.DOCKER_HUB_REPOSITORY }}:main --tag docker.io/${{ env.DOCKER_HUB_ORGANIZATION }}/${{ env.DOCKER_HUB_REPOSITORY }}:latest
23+
docker push docker.io/${{ env.DOCKER_HUB_ORGANIZATION }}/${{ env.DOCKER_HUB_REPOSITORY }} --all-tags
24+
echo docker obp-portal with latest tag done
25+
26+
- uses: sigstore/cosign-installer@main
27+
- name: Write signing key to disk (only needed for `cosign sign --key`)
28+
run: echo "${{ secrets.COSIGN_PRIVATE_KEY }}" > cosign.key
29+
- name: Sign container image with annotations from our environment
30+
env:
31+
COSIGN_PASSWORD: ${{ secrets.COSIGN_PASSWORD }}
32+
run: |
33+
cosign sign -y --key cosign.key \
34+
-a "repo=${{ github.repository }}" \
35+
-a "workflow=${{ github.workflow }}" \
36+
-a "ref=${{ github.sha }}" \
37+
docker.io/${{ env.DOCKER_HUB_ORGANIZATION }}/${{ env.DOCKER_HUB_REPOSITORY }}:main
38+
39+
40+
41+

Dockerfile

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
FROM node:22-alpine AS builder
2+
WORKDIR /app
3+
COPY package*.json ./
4+
RUN npm install
5+
RUN npm ci
6+
COPY . .
7+
8+
# Accept build arguments for environment variables
9+
ARG PUBLIC_OBP_BASE_URL
10+
ARG OBP_OAUTH_CLIENT_ID
11+
ARG OBP_OAUTH_CLIENT_SECRET
12+
ARG APP_CALLBACK_URL
13+
ARG ORIGIN
14+
15+
# Set environment variables for build
16+
ENV PUBLIC_OBP_BASE_URL=$PUBLIC_OBP_BASE_URL
17+
ENV OBP_OAUTH_CLIENT_ID=$OBP_OAUTH_CLIENT_ID
18+
ENV OBP_OAUTH_CLIENT_SECRET=$OBP_OAUTH_CLIENT_SECRET
19+
ENV APP_CALLBACK_URL=$APP_CALLBACK_URL
20+
ENV ORIGIN=$ORIGIN
21+
22+
RUN npm run build
23+
RUN npm prune --production
24+
25+
FROM node:22-alpine
26+
WORKDIR /app
27+
COPY --from=builder /app/build build/
28+
COPY --from=builder /app/node_modules node_modules/
29+
COPY package.json .
30+
EXPOSE 3003
31+
ENV NODE_ENV=production
32+
CMD [ "node", "build" ]

0 commit comments

Comments
 (0)