Skip to content

Commit e54b99a

Browse files
committed
chore(Dockerfile): 规范环境变量格式并优化构建步骤
- 统一环境变量赋值使用等号格式 - 注释掉未使用的public目录复制命令 - 调整构建步骤顺序以提高可读性
1 parent 83bfc11 commit e54b99a

1 file changed

Lines changed: 7 additions & 6 deletions

File tree

Dockerfile

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ COPY --from=deps /app/node_modules ./node_modules
1919
COPY . .
2020

2121
# 禁用 Next.js 遥测
22-
ENV NEXT_TELEMETRY_DISABLED 1
22+
ENV NEXT_TELEMETRY_DISABLED=1
2323

2424
# 构建应用
2525
RUN npm run build
@@ -28,24 +28,25 @@ RUN npm run build
2828
FROM base AS runner
2929
WORKDIR /app
3030

31-
ENV NODE_ENV production
32-
ENV NEXT_TELEMETRY_DISABLED 1
31+
ENV NODE_ENV=production
32+
ENV NEXT_TELEMETRY_DISABLED=1
3333

3434
# 创建非 root 用户
3535
RUN addgroup --system --gid 1001 nodejs
3636
RUN adduser --system --uid 1001 nextjs
3737

3838
# 复制构建产物
39-
COPY --from=builder /app/public ./public
40-
4139
# 自动利用 standalone 输出以减小镜像体积
4240
COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./
4341
COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static
4442

43+
# 如果有 public 目录,取消注释下一行
44+
# COPY --from=builder /app/public ./public
45+
4546
USER nextjs
4647

4748
# 暴露端口(默认 8367)
48-
ENV PORT 8367
49+
ENV PORT=8367
4950
EXPOSE 8367
5051

5152
# 启动命令

0 commit comments

Comments
 (0)