1+ # Define versions as build arguments for easy updates
12ARG NODE_VERSION=24.7.0
23ARG PNPM_VERSION=10.5.0
34ARG 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 ---
58FROM node:${NODE_VERSION}-alpine${ALPINE_VERSION} AS build
69
7- ARG PNPM_VERSION
10+ ARG PNPM_URL
811ARG GIT_BRANCH
912ARG GIT_COMMIT_SHA
1013
@@ -13,21 +16,28 @@ ENV DOCKER=true
1316ENV GIT_BRANCH=${GIT_BRANCH}
1417ENV 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)
1823COPY package.json .
1924COPY pnpm-lock.yaml .
2025COPY patches/ patches/
2126
27+ # Install deps (avoiding frozen-lockfile because it stalled CI/CD)
2228RUN pnpm install --strict-peer-dependencies
2329
30+ # Copy full source after dependencies are cached
2431COPY . .
2532
33+ # Build the app (output to /app/build)
2634RUN pnpm run build
2735
36+
37+ # --- Runtime stage ---
2838FROM node:${NODE_VERSION}-alpine${ALPINE_VERSION} AS runtime
2939
30- ARG PNPM_VERSION
40+ ARG PNPM_URL
3141ARG GIT_BRANCH
3242ARG GIT_COMMIT_SHA
3343
@@ -37,15 +47,20 @@ ENV NODE_ENV=production
3747ENV GIT_BRANCH=${GIT_BRANCH}
3848ENV 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
4254EXPOSE 3000
4355
56+ # Copy only required runtime files and build output
4457COPY --from=build /app/package.json .
4558COPY --from=build /app/pnpm-lock.yaml .
4659COPY --from=build /app/patches/ patches/
4760COPY --from=build /app/build build/
4861
62+ # Install only production dependencies
4963RUN pnpm install --strict-peer-dependencies
5064
65+ # Start the app
5166CMD ["node" ,"build/index.js" ]
0 commit comments