Skip to content

Commit 81b984c

Browse files
committed
clear and add comments
1 parent 8312773 commit 81b984c

File tree

1 file changed

+37
-30
lines changed

1 file changed

+37
-30
lines changed

Dockerfile

Lines changed: 37 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,59 +1,66 @@
1-
# Stage 1: builder
1+
2+
# Builder Stage
23
FROM node:22-alpine AS builder
34

45
WORKDIR /app
56

6-
# install pnpm & git
7-
RUN npm install -g pnpm
8-
RUN apk update && \
9-
apk upgrade && \
10-
apk add --no-cache git
11-
12-
RUN git init
7+
# install tools
8+
RUN npm install -g pnpm && \
9+
apk add --no-cache git && \
10+
git init
1311

14-
15-
# copy lock, package files and configs
12+
# copy files needed for installing dependencies
1613
COPY package.json pnpm-lock.yaml ./
17-
COPY run-jiti.js ./
18-
COPY src/features/build-info/script-to-generate-json.ts src/features/build-info/build-info.gen.json ./src/features/build-info/
1914
COPY prisma/schema.prisma ./prisma/
15+
COPY run-jiti.js ./
16+
COPY src/features/build-info/script-to-generate-json.ts ./src/features/build-info/
2017

18+
# install dependencies
2119
RUN pnpm install --frozen-lockfile
2220

23-
# copy source
21+
# copy source code
2422
COPY . .
2523

24+
# build the application
2625
ENV NODE_OPTIONS=--max-old-space-size=4096
27-
28-
# build app
2926
RUN pnpm build
3027

3128

32-
# Stage 2: runtime
33-
FROM node:22-alpine AS runtime
34-
29+
# Runtime Stage
30+
FROM node:22-alpine
3531

3632
WORKDIR /app
3733

38-
# ENV
39-
ENV NODE_ENV=production
40-
ENV HOST=0.0.0.0
41-
ENV PORT=3000
34+
# Environnement variables
35+
ENV NODE_ENV=production \
36+
HOST=0.0.0.0 \
37+
PORT=3000
4238

43-
# install pnpm
44-
RUN npm install -g pnpm npm-run-all
39+
# install tools
40+
RUN npm install -g pnpm npm-run-all && \
41+
apk add --no-cache git && \
42+
git init
4543

46-
COPY .env ./
44+
# copy files needed for installing dependencies
4745

4846

47+
COPY --from=builder /app/package.json ./
48+
COPY --from=builder /app/pnpm-lock.yaml ./
49+
COPY --from=builder /app/run-jiti.js ./
50+
COPY --from=builder /app/prisma ./prisma
51+
COPY --from=builder /app/src/features/build-info ./src/features/build-info
4952

50-
## copy output build and package.json from builder
51-
COPY --from=builder /app/.output ./.output
52-
COPY --from=builder /app/package.json ./package.json
53-
COPY --from=builder /app/pnpm-lock.yaml ./pnpm-lock.yaml
53+
# copy environment configuration
54+
# TODO: Replace with environment variables or secrets in production
55+
COPY .env ./
56+
57+
# install production dependencies (this will run prisma generate)
5458
RUN pnpm install --frozen-lockfile
5559

60+
# copy build artifacts after installation
61+
COPY --from=builder /app/.output ./.output
62+
5663
EXPOSE 3000
5764

58-
# start
65+
# start the application
5966
CMD ["pnpm", "start"]

0 commit comments

Comments
 (0)