-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
50 lines (32 loc) · 1017 Bytes
/
Dockerfile
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
FROM node:22.13.0-alpine3.21 AS base
FROM base AS deps
WORKDIR /app
COPY package.json package-lock.json* ./
RUN apk --no-cache upgrade \
&& npm ci
FROM base AS builder
WORKDIR /app
COPY --from=deps /app/node_modules ./node_modules
COPY . .
# Disable Next telemetry, see https://nextjs.org/telemetry
ENV NEXT_TELEMETRY_DISABLED=1
RUN apk --no-cache upgrade \
&& npm run build
FROM base AS runner
WORKDIR /app
ENV NODE_ENV=production
# Disable Next telemetry, see https://nextjs.org/telemetry
ENV NEXT_TELEMETRY_DISABLED=1
ARG WORKER_USER_ID=1001
# Create a non-root user
RUN apk --no-cache upgrade \
&& addgroup -g ${WORKER_USER_ID} nodejs \
&& adduser -D -u ${WORKER_USER_ID} -G nodejs worker
WORKDIR /app
# Copy the built application from the builder stage
COPY --from=builder /app/public ./public
COPY --from=builder --chown=worker:nodejs /app/.next/standalone ./
COPY --from=builder --chown=worker:nodejs /app/.next/static ./.next/static
EXPOSE 3000
USER worker
CMD ["node", "server.js"]