charles_c 5 months ago
parent
commit
2fbcb6cec4
1 changed files with 14 additions and 5 deletions
  1. 14 5
      Dockerfile.prod

+ 14 - 5
Dockerfile.prod

@@ -51,11 +51,20 @@ 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 && chown -R nextjs:nodejs /app/public/uploads
-# RUN mkdir -p /app/public/uploads && \
-#     chown -R nextjs:nodejs /app && \
-#     chmod -R 755 /app/public && \
-#     chmod 755 /app/public/uploads
+# RUN mkdir -p /app/public/uploads && chown -R nextjs:nodejs /app/public && chown -R nextjs:nodejs /app/public/uploads
+
+# 设置权限
+RUN mkdir -p /app/public/uploads && \
+    chown -R nextjs:nodejs /app && \
+    chmod -R 755 /app/public && \
+    chmod 755 /app/public/uploads && \
+    ls -la /app/public/uploads  # 用于调试
+
+# 再次确认 uploads 目录的权限
+RUN chown nextjs:nodejs /app/public/uploads && \
+    chmod 755 /app/public/uploads && \
+    ls -la /app/public/uploads  # 再次用于调试
+
 
 # 设置为非 root 用户
 USER nextjs