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_URI}
  14. - JWT_SECRET=${JWT_SECRET}
  15. env_file:
  16. - .env.production.docker
  17. depends_on:
  18. - mongodb
  19. restart: unless-stopped # 添加自动重启策略
  20. volumes:
  21. - uploads_data:/app/public/uploads
  22. mongodb:
  23. image: mongo
  24. volumes:
  25. - mongodb_data:/data/db
  26. restart: unless-stopped # 添加自动重启策略
  27. nginx:
  28. container_name: match-vote-nextjs-nginx-1
  29. image: nginx:alpine
  30. ports:
  31. - "8080:80"
  32. volumes:
  33. - ./nginx:/etc/nginx/conf.d
  34. - ./logs/nginx:/var/log/nginx
  35. - uploads_data:/app/public/uploads:ro
  36. - ./certs:/etc/nginx/certs
  37. depends_on:
  38. - nextjs
  39. restart: unless-stopped # 添加自动重启策略
  40. volumes:
  41. mongodb_data:
  42. uploads_data:
  43. networks:
  44. default:
  45. name: match-vote-network # 为网络指定一个名称