Skip to content

Commit 5f91b2f

Browse files
committed
feat: serve frontend from backend
1 parent b12af4a commit 5f91b2f

32 files changed

Lines changed: 4379 additions & 57929 deletions

.dockerignore

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# Include any files or directories that you don't want to be copied to your
2+
# container here (e.g., local build artifacts, temporary files, etc.).
3+
#
4+
# For more help, visit the .dockerignore file reference guide at
5+
# https://docs.docker.com/go/build-context-dockerignore/
6+
7+
**/.classpath
8+
**/.dockerignore
9+
**/.env
10+
**/.git
11+
**/.gitignore
12+
**/.project
13+
**/.settings
14+
**/.toolstarget
15+
**/.vs
16+
**/.vscode
17+
**/.next
18+
**/.cache
19+
**/*.*proj.user
20+
**/*.dbmdl
21+
**/*.jfm
22+
**/charts
23+
**/docker-compose*
24+
**/compose.y*ml
25+
**/Dockerfile*
26+
**/node_modules
27+
**/npm-debug.log
28+
**/obj
29+
**/secrets.dev.yaml
30+
**/values.dev.yaml
31+
**/build
32+
**/dist
33+
LICENSE
34+
README.md

.github/workflows/docker-build-manual.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,11 +70,11 @@ jobs:
7070
- name: Build & Push Backend
7171
uses: docker/build-push-action@v5
7272
with:
73-
context: ./backend
74-
file: backend/Dockerfile
73+
context: .
74+
file: ./Dockerfile.app
7575
platforms: linux/arm64
7676
push: true
77-
tags: sunjay195/cron-job-backend:latest
77+
tags: sunjay195/cron-job-app:latest
7878
cache-from: type=gha
7979
cache-to: type=gha,mode=max
8080
labels: |

.github/workflows/docker-build-push.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,10 +92,11 @@ jobs:
9292
- name: Build & Push Backend
9393
uses: docker/build-push-action@v5
9494
with:
95-
context: ./backend
95+
context: .
96+
file: ./Dockerfile.app
9697
platforms: linux/arm64
9798
push: true
98-
tags: sunjay195/cron-job-backend:latest
99+
tags: sunjay195/cron-job-app:latest
99100
cache-from: type=gha
100101
cache-to: type=gha,mode=max
101102
labels: |

Dockerfile.app

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
ARG NODE_VERSION=24.11.0-alpine
2+
ARG PNPM_VERSION=10.33.1
3+
4+
# --------------------- Base Stage ----------------
5+
FROM node:${NODE_VERSION} AS base
6+
7+
RUN corepack enable
8+
RUN corepack prepare pnpm@${PNPM_VERSION} --activate
9+
10+
WORKDIR /app
11+
12+
# --------------------- Client Builder Stage ----------------
13+
FROM base AS client-builder
14+
15+
COPY frontend/package.json frontend/pnpm-lock.yaml ./
16+
RUN pnpm install --frozen-lockfile --ignore-scripts
17+
18+
COPY frontend/ ./
19+
RUN pnpm build
20+
21+
# --------------------- Server Builder Stage ----------------
22+
FROM base AS server-builder
23+
24+
WORKDIR /app
25+
COPY backend/package.json backend/pnpm-lock.yaml ./
26+
RUN pnpm install --frozen-lockfile --ignore-scripts
27+
28+
COPY backend/ ./
29+
RUN pnpm build
30+
31+
# --------------------- Prod Deps Stage ---------------------
32+
FROM base AS prod-deps
33+
34+
WORKDIR /app
35+
COPY backend/package.json backend/pnpm-lock.yaml ./
36+
37+
RUN pnpm install --prod --frozen-lockfile --ignore-scripts
38+
39+
# --------------------- Runner Stage ----------------
40+
FROM node:${NODE_VERSION} AS runner
41+
42+
WORKDIR /app
43+
44+
COPY --from=prod-deps /app/node_modules ./node_modules
45+
COPY --from=server-builder /app/dist ./dist
46+
COPY --from=client-builder /app/dist ./public
47+
48+
ENV NODE_ENV=production
49+
ENV PORT=3000
50+
51+
EXPOSE 3000
52+
53+
# Run server
54+
CMD ["node", "./dist/src/server.js"]

backend/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
ARG NODE_VERSION=24.11.0
2-
ARG PNPM_VERSION=10.32.1
2+
ARG PNPM_VERSION=10.33.1
33

44
# =================== base stage ============================================
55
FROM node:${NODE_VERSION}-alpine AS base

0 commit comments

Comments
 (0)