docker-compose.prod.yml 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. services:
  2. nextjs:
  3. container_name: match-vote-nextjs-nextjs-1
  4. build:
  5. context: .
  6. dockerfile: Dockerfile.prod
  7. args:
  8. - MONGODB_URI=mongodb://mongodb:27017/mydatabase
  9. ports:
  10. - "3000:3000"
  11. environment:
  12. - NODE_ENV=production
  13. - MONGODB_URI=mongodb://mongodb:27017/mydatabase
  14. depends_on:
  15. - mongodb
  16. - init-uploads
  17. restart: unless-stopped # 添加自动重启策略
  18. volumes:
  19. - nextjs-uploads:/app/public/uploads # 添加这行来挂载 uploads volume
  20. init-uploads:
  21. image: alpine
  22. volumes:
  23. - nextjs-uploads:/uploads
  24. command: chown -R 1001:1001 /uploads
  25. user: root
  26. mongodb:
  27. image: mongo
  28. volumes:
  29. - mongodb_data:/data/db
  30. restart: unless-stopped # 添加自动重启策略
  31. nginx:
  32. image: nginx:alpine
  33. ports:
  34. - "8088:80"
  35. volumes:
  36. - ./nginx:/etc/nginx/conf.d
  37. - ./logs/nginx:/var/log/nginx
  38. depends_on:
  39. - nextjs
  40. restart: unless-stopped # 添加自动重启策略
  41. volumes:
  42. mongodb_data:
  43. nextjs-uploads:
  44. networks:
  45. default:
  46. name: match-vote-network # 为网络指定一个名称