Skip to content

Commit e4e3240

Browse files
committed
Add comments n stuff to Dockerfile
1 parent 8d16d55 commit e4e3240

1 file changed

Lines changed: 19 additions & 4 deletions

File tree

Dockerfile

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
1+
# Define versions as build arguments for easy updates
12
ARG NODE_VERSION=24.7.0
23
ARG PNPM_VERSION=10.5.0
34
ARG ALPINE_VERSION=3.22
5+
ARG PNPM_URL="https://github.com/pnpm/pnpm/releases/download/v${PNPM_VERSION}/pnpm-linuxstatic-x64"
46

7+
# --- Build stage ---
58
FROM node:${NODE_VERSION}-alpine${ALPINE_VERSION} AS build
69

7-
ARG PNPM_VERSION
10+
ARG PNPM_URL
811
ARG GIT_BRANCH
912
ARG GIT_COMMIT_SHA
1013

@@ -13,21 +16,28 @@ ENV DOCKER=true
1316
ENV GIT_BRANCH=${GIT_BRANCH}
1417
ENV GIT_COMMIT_SHA=${GIT_COMMIT_SHA}
1518

16-
RUN wget -qO /bin/pnpm "https://github.com/pnpm/pnpm/releases/download/v${PNPM_VERSION}/pnpm-linuxstatic-x64" && chmod +x /bin/pnpm
19+
# Install pnpm (static binary)
20+
RUN wget -qO /bin/pnpm "${PNPM_URL}" && chmod +x /bin/pnpm
1721

22+
# Copy dependency manifests first (for caching)
1823
COPY package.json .
1924
COPY pnpm-lock.yaml .
2025
COPY patches/ patches/
2126

27+
# Install deps (avoiding frozen-lockfile because it stalled CI/CD)
2228
RUN pnpm install --strict-peer-dependencies
2329

30+
# Copy full source after dependencies are cached
2431
COPY . .
2532

33+
# Build the app (output to /app/build)
2634
RUN pnpm run build
2735

36+
37+
# --- Runtime stage ---
2838
FROM node:${NODE_VERSION}-alpine${ALPINE_VERSION} AS runtime
2939

30-
ARG PNPM_VERSION
40+
ARG PNPM_URL
3141
ARG GIT_BRANCH
3242
ARG GIT_COMMIT_SHA
3343

@@ -37,15 +47,20 @@ ENV NODE_ENV=production
3747
ENV GIT_BRANCH=${GIT_BRANCH}
3848
ENV GIT_COMMIT_SHA=${GIT_COMMIT_SHA}
3949

40-
RUN wget -qO /bin/pnpm "https://github.com/pnpm/pnpm/releases/download/v${PNPM_VERSION}/pnpm-linuxstatic-x64" && chmod +x /bin/pnpm
50+
# Install pnpm again for runtime dependency resolution
51+
RUN wget -qO /bin/pnpm "${PNPM_URL}" && chmod +x /bin/pnpm
4152

53+
# App will run on port 3000
4254
EXPOSE 3000
4355

56+
# Copy only required runtime files and build output
4457
COPY --from=build /app/package.json .
4558
COPY --from=build /app/pnpm-lock.yaml .
4659
COPY --from=build /app/patches/ patches/
4760
COPY --from=build /app/build build/
4861

62+
# Install only production dependencies
4963
RUN pnpm install --strict-peer-dependencies
5064

65+
# Start the app
5166
CMD ["node","build/index.js"]

0 commit comments

Comments
 (0)