-
Notifications
You must be signed in to change notification settings - Fork 1
/
Dockerfile
50 lines (36 loc) · 1.01 KB
/
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
###################
# BASE
###################
FROM node:lts-alpine3.21 AS base
# Create app directory
WORKDIR /app
###################
# BUILD STAGE
###################
FROM base AS build
# Copy package files
COPY --chown=node:node package.json package-lock.json ./
ENV NEXT_TELEMETRY_DISABLED=1
# Install all dependencies
RUN npm ci
# Copy the application source code
COPY --chown=node:node . .
# Build the application
RUN npm run build
###################
# PRODUCTION STAGE
###################
FROM base AS prod
ENV NODE_ENV=production
ENV NEXT_TELEMETRY_DISABLED=1
# Copy only necessary files for production
COPY --from=build /app/public ./public
# Automatically leverage output traces to reduce image size
# https://nextjs.org/docs/advanced-features/output-file-tracing
COPY --from=build --chown=node:node /app/.next/standalone ./
COPY --from=build --chown=node:node /app/.next/static ./.next/static
# Use a non-root user for security
USER node
ENV HOSTNAME="0.0.0.0"
# Start the application
CMD ["node", "server.js"]