-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
49 lines (33 loc) · 1.19 KB
/
Dockerfile
File metadata and controls
49 lines (33 loc) · 1.19 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
# Build stage
FROM node:24-alpine@sha256:d1b3b4da11eefd5941e7f0b9cf17783fc99d9c6fc34884a665f40a06dbdfc94f AS builder
ARG VERSION=unknown
WORKDIR /src
# Install pnpm
RUN npm install -g pnpm
# Copy dependency files first for better caching
COPY package.json pnpm-lock.yaml ./
RUN pnpm install --frozen-lockfile --ignore-scripts
# Copy source code
COPY . .
# Set version environment variable
ENV VERSION=${VERSION}
# Build the application
RUN NODE_OPTIONS=--max-old-space-size=4096 pnpm build
# Prune to production dependencies only
RUN pnpm prune --production --ignore-scripts && pnpm store prune
# Runtime stage
FROM gcr.io/distroless/nodejs24-debian13:nonroot@sha256:f16acace4aa70086d4a2caad6c716f01e3e2fe0dd8274c4530c7c17d987bdb1a
WORKDIR /app
# Copy built application and production dependencies from builder
COPY --from=builder --chown=65532:65532 /src/build ./build
COPY --from=builder --chown=65532:65532 /src/node_modules ./node_modules
COPY --from=builder --chown=65532:65532 /src/package.json ./
# Switch to non-root user
USER 65532:65532
# Set environment variable
ENV NODE_ENV=production
# Expose port
EXPOSE 3000
# Labels
LABEL maintainer="Chung-Hsuan Tsai <paul_tsai@phison.com>"
CMD ["./build"]