Browse Source

上传文件配置

charles_c 5 months ago
parent
commit
b9f6015ed3
2 changed files with 5 additions and 3 deletions
  1. 2 0
      Dockerfile.prod
  2. 3 3
      docker-compose.prod.yml

+ 2 - 0
Dockerfile.prod

@@ -44,6 +44,8 @@ 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

+ 3 - 3
docker-compose.prod.yml

@@ -14,8 +14,8 @@ services:
     depends_on:
       - mongodb
     restart: unless-stopped  # 添加自动重启策略
-    # volumes:
-    #   - nextjs-uploads:/app/public/uploads
+    volumes:
+      - nextjs-uploads:/app/public/uploads
     
   mongodb:
     image: mongo
@@ -37,7 +37,7 @@ services:
 
 volumes:
   mongodb_data:
-  # nextjs-uploads:
+  nextjs-uploads:
 
 networks:
   default: