charles_c 5 ay önce
ebeveyn
işleme
4858fd6b45
2 değiştirilmiş dosya ile 5 ekleme ve 10 silme
  1. 4 9
      Dockerfile.prod
  2. 1 1
      docker-compose.prod.yml

+ 4 - 9
Dockerfile.prod

@@ -54,15 +54,10 @@ COPY --from=builder /app/package.json ./package.json
 # 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/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 
-
-# 再次确认 uploads 目录的权限
-RUN chown nextjs:nodejs /app/public/uploads && \
-    chmod 755 /app/public/uploads 
-
+RUN mkdir -p /app/public/uploads
+RUN chown -R nextjs:nodejs /app/public
+RUN chown -R nextjs:nodejs /app/public/uploads
+RUN chmod -R 755 /app/public/uploads
 
 
 # 设置为非 root 用户
 # 设置为非 root 用户
 USER nextjs
 USER nextjs

+ 1 - 1
docker-compose.prod.yml

@@ -16,7 +16,7 @@ services:
     restart: unless-stopped  # 添加自动重启策略
     restart: unless-stopped  # 添加自动重启策略
     volumes:
     volumes:
       # - nextjs-uploads:/app/public/uploads
       # - nextjs-uploads:/app/public/uploads
-      - ./public/uploads:/app/public/uploads:rw
+      - ./public/uploads:/app/public/uploads:rw,z
     
     
   mongodb:
   mongodb:
     image: mongo
     image: mongo