-
Notifications
You must be signed in to change notification settings - Fork 90
Expand file tree
/
Copy pathDockerfile
More file actions
43 lines (27 loc) · 828 Bytes
/
Dockerfile
File metadata and controls
43 lines (27 loc) · 828 Bytes
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
# --- Build stage ---
FROM node:22-alpine AS builder
WORKDIR /app
# Install deps based on lockfile (pnpm)
RUN corepack enable
COPY package.json pnpm-lock.yaml* ./
RUN pnpm install --frozen-lockfile
# Copy the rest of the source code
COPY . .
# Build Next.js in standalone mode
ENV NEXT_TELEMETRY_DISABLED=1
RUN pnpm build
# --- Runtime stage ---
FROM node:22-alpine AS runner
WORKDIR /app
ENV NODE_ENV=production
# Cloud Run will inject PORT, default 8080 for local usage
ENV PORT=8080
# Create non-root user
RUN addgroup -S nextjs && adduser -S nextjs -G nextjs
# Copy only the standalone server output and static assets
COPY --from=builder /app/.next/standalone ./
COPY --from=builder /app/.next/static ./.next/static
COPY --from=builder /app/public ./public
USER nextjs
EXPOSE 8080
CMD ["node", "server.js"]