Skip to content

Commit 675dadc

Browse files
feat: add more build support (#67)
* add * Update docker-build-frontend-node.yml
1 parent 0ffcf1a commit 675dadc

File tree

5 files changed

+91
-4
lines changed

5 files changed

+91
-4
lines changed

.github/workflows/docker-build-frontend.yml renamed to .github/workflows/docker-build-frontend-node.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Test Frontend Docker Build
1+
name: Test Frontend Node Docker Build
22

33
on:
44
push:
@@ -28,5 +28,5 @@ jobs:
2828
uses: docker/build-push-action@v5
2929
with:
3030
context: ./src/frontend
31-
file: ./src/frontend/Dockerfile
31+
file: ./src/frontend/builds/Dockerfile.node
3232
push: false
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: Test Frontend Static Docker Build
2+
3+
on:
4+
push:
5+
branches: ['main']
6+
paths:
7+
- 'src/frontend/**'
8+
- '.github/workflows/**'
9+
pull_request:
10+
branches: ['main']
11+
paths:
12+
- 'src/frontend/**'
13+
- '.github/workflows/**'
14+
workflow_dispatch:
15+
16+
jobs:
17+
build-docker:
18+
runs-on: ubuntu-latest
19+
20+
steps:
21+
- name: Checkout repository
22+
uses: actions/checkout@v4
23+
24+
- name: Set up Docker Buildx
25+
uses: docker/setup-buildx-action@v3
26+
27+
- name: Build Docker image
28+
uses: docker/build-push-action@v5
29+
with:
30+
context: ./src/frontend
31+
file: ./src/frontend/builds/Dockerfile.static
32+
push: false

.github/workflows/publish-ghcr.yml

Lines changed: 41 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ jobs:
7272
id: meta
7373
uses: docker/metadata-action@v5
7474
with:
75-
images: ${{ env.REGISTRY }}/${{ github.repository }}-frontend
75+
images: ${{ env.REGISTRY }}/${{ github.repository }}-frontend-node
7676
tags: |
7777
type=ref,event=branch
7878
type=ref,event=pr
@@ -87,7 +87,46 @@ jobs:
8787
uses: docker/build-push-action@v5
8888
with:
8989
context: ./src/frontend
90-
file: ./src/frontend/Dockerfile
90+
file: ./src/frontend/builds/Dockerfile.node
91+
push: true
92+
tags: ${{ steps.meta.outputs.tags }}
93+
labels: ${{ steps.meta.outputs.labels }}
94+
build-and-push-frontend-staic:
95+
runs-on: ubuntu-latest
96+
permissions:
97+
contents: read
98+
packages: write
99+
steps:
100+
- name: Checkout repository
101+
uses: actions/checkout@v4
102+
103+
- name: Log in to the Container registry
104+
uses: docker/login-action@v3
105+
with:
106+
registry: ${{ env.REGISTRY }}
107+
username: ${{ github.actor }}
108+
password: ${{ secrets.GITHUB_TOKEN }}
109+
110+
- name: Extract metadata (tags, labels) for Docker
111+
id: meta
112+
uses: docker/metadata-action@v5
113+
with:
114+
images: ${{ env.REGISTRY }}/${{ github.repository }}-frontend-static
115+
tags: |
116+
type=ref,event=branch
117+
type=ref,event=pr
118+
type=semver,pattern={{version}}
119+
type=semver,pattern={{major}}.{{minor}}
120+
type=raw,value=latest,enable=${{ github.event_name == 'release' || startsWith(github.ref, 'refs/tags/v') }}
121+
122+
- name: Set up Docker Buildx
123+
uses: docker/setup-buildx-action@v3
124+
125+
- name: Build and push Docker image
126+
uses: docker/build-push-action@v5
127+
with:
128+
context: ./src/frontend
129+
file: ./src/frontend/builds/Dockerfile.static
91130
push: true
92131
tags: ${{ steps.meta.outputs.tags }}
93132
labels: ${{ steps.meta.outputs.labels }}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
FROM node:25-alpine AS builder
2+
WORKDIR /app
3+
COPY package*.json .
4+
RUN npm ci
5+
COPY . .
6+
RUN npm run build:node
7+
RUN npm prune --production
8+
9+
FROM node:25-alpine
10+
WORKDIR /app
11+
COPY --from=builder /app/build build/
12+
COPY --from=builder /app/node_modules node_modules/
13+
COPY package.json .
14+
EXPOSE 3000
15+
ENV NODE_ENV=production
16+
CMD [ "node", "build" ]

0 commit comments

Comments
 (0)