-
Notifications
You must be signed in to change notification settings - Fork 18
Expand file tree
/
Copy pathDockerfile
More file actions
43 lines (25 loc) · 852 Bytes
/
Dockerfile
File metadata and controls
43 lines (25 loc) · 852 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
43
FROM node:20-alpine AS base
RUN npm install -g pnpm
WORKDIR /app
FROM base AS deps
# Because of docker layer caching dependencies should only be re-installed if package.json or pnpm-lock.yaml change.
COPY package.json pnpm-lock.yaml ./
RUN pnpm install --frozen-lockfile
FROM base AS builder
COPY --from=deps /app/node_modules ./node_modules
COPY . .
RUN pnpm build
FROM base AS runner
WORKDIR /app
ENV NODE_ENV=production
# non root user for security
RUN addgroup --system --gid 1001 nodejs
RUN adduser --system --uid 1001 nextjs
COPY --from=builder --chown=nextjs:nodejs /app/public ./public
COPY --from=builder --chown=nextjs:nodejs /app/.next ./.next
COPY --chown=nextjs:nodejs package.json pnpm-lock.yaml ./
# Install only prod dependencies
RUN pnpm install --prod --frozen-lockfile
USER nextjs
EXPOSE 3000
CMD ["pnpm", "start"]