-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
41 lines (30 loc) · 1015 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
FROM node:21.0.0-bullseye-slim as base
ENV PORT 3000
EXPOSE $PORT
USER node
WORKDIR /app
## BUILDER IMAGE
FROM base AS builder
ENV NODE_ENV production
ENV NEXT_TELEMETRY_DISABLED 1
COPY --chown=node:node package*.json ./
RUN npm ci && npm cache clean --force && npm prune --omit=peer
COPY --chown=node:node ./ ./
RUN npm run build
CMD ["node", ".next/standalone/server.js"]
## PRODUCTION CI IMAGE
FROM base AS prod
WORKDIR /app
ENV NODE_ENV production
ENV NEXT_TELEMETRY_DISABLED 1
# runtime environment variable substitution
COPY --chown=node:node .env .
COPY --chown=node:node entrypoint.sh /app/entrypoint.sh
RUN chmod +x /app/entrypoint.sh
ENTRYPOINT ["/app/entrypoint.sh"]
COPY --from=builder /app/public ./public
# Automatically leverage output traces to reduce image size
# https://nextjs.org/docs/advanced-features/output-file-tracing
COPY --from=builder --chown=node:node /app/.next/standalone ./
COPY --from=builder --chown=node:node /app/.next/static ./.next/static
CMD ["node", "server.js"]