File tree 2 files changed +23
-7
lines changed
2 files changed +23
-7
lines changed Original file line number Diff line number Diff line change 1
1
ARG NOTION_PAGE_ID
2
2
ARG NEXT_PUBLIC_THEME
3
3
4
- # Install dependencies only when needed
5
- FROM node:18-alpine3.18 AS deps
4
+ FROM node:18-alpine3.18 AS base
5
+
6
+ # 1. Install dependencies only when needed
7
+ FROM base AS deps
6
8
# Check https://github.com/nodejs/docker-node/tree/b4117f9333da4138b03a546ec926ef50a31506c3#nodealpine to understand why libc6-compat might be needed.
7
9
RUN apk add --no-cache libc6-compat
8
10
WORKDIR /app
9
11
COPY package.json ./
10
12
RUN yarn install --frozen-lockfile
11
13
12
- # Rebuild the source code only when needed
13
- FROM node:18-alpine3.18 AS builder
14
+ # 2. Rebuild the source code only when needed
15
+ FROM base AS builder
14
16
ARG NOTION_PAGE_ID
15
17
WORKDIR /app
16
18
COPY --from=deps /app/node_modules ./node_modules
17
19
COPY . .
18
20
RUN yarn build
19
21
20
- ENV NODE_ENV production
22
+ # 3. Production image, copy all the files and run next
23
+ FROM base AS runner
24
+ WORKDIR /app
25
+
26
+ ENV NODE_ENV=production
27
+
28
+ COPY --from=builder /app/public ./public
29
+
30
+ # Automatically leverage output traces to reduce image size
31
+ # https://nextjs.org/docs/advanced-features/output-file-tracing
32
+ COPY --from=builder /app/.next/standalone ./
33
+ COPY --from=builder /app/.next/static ./.next/static
34
+
35
+ # 个人仓库把将配置好的.env.local文件放到项目根目录,可自动使用环境变量
36
+ # COPY --from=builder /app/.env.local ./
21
37
22
38
EXPOSE 3000
23
39
@@ -26,4 +42,4 @@ EXPOSE 3000
26
42
# Uncomment the following line in case you want to disable telemetry.
27
43
# ENV NEXT_TELEMETRY_DISABLED 1
28
44
29
- CMD ["yarn " , "start " ]
45
+ CMD ["node " , "server.js " ]
Original file line number Diff line number Diff line change @@ -84,7 +84,7 @@ const nextConfig = {
84
84
eslint : {
85
85
ignoreDuringBuilds : true
86
86
} ,
87
- output : process . env . EXPORT ? 'export' : undefined ,
87
+ output : process . env . EXPORT ? 'export' : 'standalone' ,
88
88
staticPageGenerationTimeout : 120 ,
89
89
// 多语言, 在export时禁用
90
90
i18n : process . env . EXPORT
You can’t perform that action at this time.
0 commit comments