alexcdev1 6 달 전
부모
커밋
010fbe38e5
1개의 변경된 파일15개의 추가작업 그리고 11개의 파일을 삭제
  1. 15 11
      Dockerfile.prod

+ 15 - 11
Dockerfile.prod

@@ -43,14 +43,17 @@
 # CMD ["node_modules/.bin/next", "start"]
 
 # Stage 1: Dependencies
-FROM node:alpine AS deps
+FROM node:18-alpine AS deps
 WORKDIR /app
 
 # 安装 pnpm
 RUN npm install -g pnpm
 
-# 安装 libc6-compat(如果需要的话)
-RUN apk add --no-cache libc6-compat
+# 安装 bash 和其他必要的工具
+RUN apk add --no-cache libc6-compat bash
+
+# 设置 pnpm 使用淘宝镜像
+RUN pnpm config set registry https://registry.npm.taobao.org
 
 # 复制 package.json 和 pnpm-lock.yaml(如果有的话)
 COPY package.json pnpm-lock.yaml* ./
@@ -59,11 +62,12 @@ COPY package.json pnpm-lock.yaml* ./
 RUN pnpm install --frozen-lockfile
 
 # Stage 2: Builder
-FROM node:alpine AS builder
+FROM node:18-alpine AS builder
 WORKDIR /app
 
-# 安装 pnpm
+# 安装 pnpm 和 bash
 RUN npm install -g pnpm
+RUN apk add --no-cache bash
 
 # 复制所有文件
 COPY . .
@@ -75,11 +79,14 @@ COPY --from=deps /app/node_modules ./node_modules
 RUN pnpm build
 
 # Stage 3: Runner
-FROM node:alpine AS runner
+FROM node:18-alpine AS runner
 WORKDIR /app
 
 ENV NODE_ENV production
 
+# 安装 bash
+RUN apk add --no-cache bash
+
 # 创建非 root 用户
 RUN addgroup --system --gid 1001 nodejs
 RUN adduser --system --uid 1001 nextjs
@@ -98,8 +105,5 @@ EXPOSE 3000
 
 ENV PORT 3000
 
-# 禁用 Next.js 遥测(如果需要)
-# ENV NEXT_TELEMETRY_DISABLED 1
-
-# 启动应用
-CMD ["pnpm", "start"]
+# 使用 bash 启动应用
+CMD ["/bin/bash", "-c", "node_modules/.bin/next start"]