charles_c 5 months ago
parent
commit
8a4bf28572
1 changed files with 3 additions and 2 deletions
  1. 3 2
      Dockerfile.prod

+ 3 - 2
Dockerfile.prod

@@ -44,14 +44,15 @@ RUN apk add --no-cache bash
 RUN addgroup --system --gid 1001 nodejs
 RUN adduser --system --uid 1001 nextjs
 
-RUN mkdir -p /app/public/uploads && chown nextjs:nodejs /app/public/uploads
-
 # 复制必要文件
 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
 
+# 创建 uploads 目录并设置权限
+RUN mkdir -p /app/public/uploads && chown -R nextjs:nodejs /app/public
+
 # 设置为非 root 用户
 USER nextjs