|
1 |
| -# Install dependencies only when needed |
2 |
| -FROM node:16-alpine AS deps |
| 1 | +FROM node:18-alpine |
3 | 2 | # Check https://github.com/nodejs/docker-node/tree/b4117f9333da4138b03a546ec926ef50a31506c3#nodealpine to understand why libc6-compat might be needed.
|
4 | 3 | RUN apk add --no-cache libc6-compat
|
5 | 4 | RUN apk add --no-cache git
|
6 | 5 | WORKDIR /app
|
7 | 6 | COPY . .
|
8 | 7 | RUN yarn install --frozen-lockfile
|
9 |
| - |
10 |
| -# Rebuild the source code only when needed |
11 |
| -FROM node:16-alpine AS builder |
12 |
| -RUN apk add --no-cache git |
13 |
| -WORKDIR /app |
14 |
| -COPY . . |
15 |
| -COPY --from=deps /app/node_modules ./node_modules |
16 |
| -RUN yarn build |
17 |
| - |
18 |
| -# Production image, copy all the files and run next |
19 |
| -FROM node:16-alpine AS runner |
20 |
| -WORKDIR /app |
21 |
| - |
22 | 8 | ENV NODE_ENV production
|
23 |
| - |
| 9 | +RUN yarn build |
24 | 10 | RUN addgroup -g 1001 -S nodejs
|
25 | 11 | RUN adduser -S nextjs -u 1001
|
26 | 12 |
|
27 |
| -# You only need to copy next.config.js if you are NOT using the default configuration |
28 |
| -# COPY --from=builder /app/next.config.js ./ |
29 |
| -COPY --from=builder /app/public ./public |
30 |
| -COPY --from=builder /app/package.json ./package.json |
31 |
| - |
32 |
| -# Automatically leverage output traces to reduce image size |
33 |
| -# https://nextjs.org/docs/advanced-features/output-file-tracing |
34 |
| -COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./ |
35 |
| -COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static |
36 |
| - |
37 | 13 | USER nextjs
|
38 | 14 |
|
39 | 15 | EXPOSE 3000
|
40 | 16 |
|
41 | 17 | ENV PORT 3000
|
42 | 18 |
|
43 |
| -# Next.js collects completely anonymous telemetry data about general usage. |
44 | 19 | # Learn more here: https://nextjs.org/telemetry
|
45 |
| -# Comment the following line in case you want to enable telemetry. |
46 | 20 | ENV NEXT_TELEMETRY_DISABLED 1
|
47 | 21 |
|
48 |
| -CMD ["node", "server.js"] |
| 22 | +CMD ["yarn", "start"] |
0 commit comments