-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathDockerfile
More file actions
66 lines (49 loc) · 1.58 KB
/
Dockerfile
File metadata and controls
66 lines (49 loc) · 1.58 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# Define versions as build arguments for easy updates
ARG NODE_VERSION=24.12.0
ARG PNPM_VERSION=10.30.1
ARG ALPINE_VERSION=3.22
ARG PNPM_URL="https://github.com/pnpm/pnpm/releases/download/v${PNPM_VERSION}/pnpm-linuxstatic-x64"
# --- Build stage ---
FROM node:${NODE_VERSION}-alpine${ALPINE_VERSION} AS build
ARG PNPM_URL
ARG GIT_BRANCH
ARG GIT_COMMIT_SHA
WORKDIR /app
ENV DOCKER=true
ENV GIT_BRANCH=${GIT_BRANCH}
ENV GIT_COMMIT_SHA=${GIT_COMMIT_SHA}
# Install pnpm (static binary)
RUN wget -qO /bin/pnpm "${PNPM_URL}" && chmod +x /bin/pnpm
# Copy dependency manifests first (for caching)
COPY package.json .
COPY pnpm-lock.yaml .
COPY patches/ patches/
# Install deps
RUN pnpm install --frozen-lockfile --strict-peer-dependencies
# Copy full source after dependencies are cached
COPY . .
# Build the app (output to /app/build)
RUN pnpm run build
# --- Runtime stage ---
FROM node:${NODE_VERSION}-alpine${ALPINE_VERSION} AS runtime
ARG PNPM_URL
ARG GIT_BRANCH
ARG GIT_COMMIT_SHA
WORKDIR /app
ENV DOCKER=true
ENV NODE_ENV=production
ENV GIT_BRANCH=${GIT_BRANCH}
ENV GIT_COMMIT_SHA=${GIT_COMMIT_SHA}
# Install pnpm again for runtime dependency resolution
RUN wget -qO /bin/pnpm "${PNPM_URL}" && chmod +x /bin/pnpm
# App will run on port 3000
EXPOSE 3000
# Copy only required runtime files and build output
COPY --from=build /app/package.json .
COPY --from=build /app/pnpm-lock.yaml .
COPY --from=build /app/patches/ patches/
COPY --from=build /app/build build/
# Install only production dependencies
RUN pnpm install --frozen-lockfile --strict-peer-dependencies
# Start the app
CMD ["node","build/index.js"]