-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
45 lines (31 loc) · 1.03 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
# Based on https://github.com/vercel/next.js/blob/canary/examples/with-docker/Dockerfile
# Install dependencies only when needed
FROM node:lts-alpine AS deps
RUN apk add --no-cache libc6-compat
RUN corepack enable
WORKDIR /srv/app
# Install dependencies
COPY package.json pnpm-lock.yaml ./
RUN pnpm install
# Rebuild the source code only when needed
FROM node:lts-alpine AS builder
RUN corepack enable
WORKDIR /srv/app
COPY --from=deps /srv/app/node_modules ./node_modules
COPY . .
ENV NEXT_TELEMETRY_DISABLED 1
RUN pnpm build
# Production image, copy all the files and run next
FROM node:lts-alpine AS runner
WORKDIR /srv/app
ENV NODE_ENV production
ENV NEXT_TELEMETRY_DISABLED 1
RUN addgroup --system --gid 1001 worker
RUN adduser --system --uid 1001 --ingroup worker worker
COPY --from=builder /srv/app/public ./public
COPY --from=builder --chown=worker:worker /srv/app/.next/standalone ./
COPY --from=builder --chown=worker:worker /srv/app/.next/static ./.next/static
USER worker
EXPOSE 3000
ENV PORT 3000
CMD ["node", "server.js"]