-
Notifications
You must be signed in to change notification settings - Fork 5
/
Dockerfile
35 lines (28 loc) · 887 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
FROM node:22-alpine AS base
# Install dependencies
FROM base AS deps
WORKDIR /app
COPY package.json ./
COPY package-lock.json ./
RUN npm ci
# Copy the source code files and generate the production build
FROM base AS builder
WORKDIR /app
COPY --from=deps /app/node_modules ./node_modules
COPY tsconfig.json ./
COPY next.config.ts ./
COPY package.json ./
COPY public ./public
COPY scripts ./scripts
COPY src ./src
RUN npm run build
FROM base AS runner
WORKDIR /app
# Create a group and a user to avoid being root in the container
RUN addgroup --system --gid 1001 nodejs
RUN adduser --system --uid 1001 nextjs
USER nextjs
# Copy the build from the previous stage and the start script
COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./.next/standalone
COPY --from=builder --chown=nextjs:nodejs /app/scripts/start-prod-server.sh .
ENTRYPOINT ["./start-prod-server.sh"]