alexcdev1 il y a 6 mois
Parent
commit
5452d93078
1 fichiers modifiés avec 20 ajouts et 18 suppressions
  1. 20 18
      Dockerfile.prod

+ 20 - 18
Dockerfile.prod

@@ -46,31 +46,33 @@
 FROM node:alpine AS deps
 WORKDIR /app
 
+# 安装 pnpm
+RUN npm install -g pnpm
+
 # 安装 libc6-compat(如果需要的话)
 RUN apk add --no-cache libc6-compat
 
-# 配置 yarn 使用淘宝镜像
-RUN yarn config set registry https://registry.npm.taobao.org
-
-# 复制 package.json、yarn.lock 和 .yarnrc(如果你创建了的话)
-COPY package.json yarn.lock .yarnrc* ./
+# 复制 package.json 和 pnpm-lock.yaml(如果有的话)
+COPY package.json pnpm-lock.yaml* ./
 
 # 安装依赖
-RUN yarn install --frozen-lockfile --network-timeout 600000 --network-concurrency 1
-
+RUN pnpm install --frozen-lockfile
 
 # Stage 2: Builder
 FROM node:alpine AS builder
 WORKDIR /app
 
-# Copy all files
+# 安装 pnpm
+RUN npm install -g pnpm
+
+# 复制所有文件
 COPY . .
 
-# Copy node_modules from deps stage
+# 复制 node_modules
 COPY --from=deps /app/node_modules ./node_modules
 
-# Build the app
-RUN yarn build
+# 构建应用
+RUN pnpm build
 
 # Stage 3: Runner
 FROM node:alpine AS runner
@@ -78,26 +80,26 @@ WORKDIR /app
 
 ENV NODE_ENV production
 
-# Create a non-root user
+# 创建非 root 用户
 RUN addgroup --system --gid 1001 nodejs
 RUN adduser --system --uid 1001 nextjs
 
-# Copy necessary files from builder stage
+# 复制必要文件
 COPY --from=builder /app/public ./public
 COPY --from=builder --chown=nextjs:nodejs /app/.next ./.next
 COPY --from=builder /app/node_modules ./node_modules
 COPY --from=builder /app/package.json ./package.json
 
-# Set user to non-root
+# 设置为非 root 用户
 USER nextjs
 
-# Expose the port the app will run on
+# 暴露端口
 EXPOSE 3000
 
 ENV PORT 3000
 
-# Disable Next.js telemetry if desired
+# 禁用 Next.js 遥测(如果需要)
 # ENV NEXT_TELEMETRY_DISABLED 1
 
-# Start the application
-CMD ["yarn", "start"]
+# 启动应用
+CMD ["pnpm", "start"]