docker-compose.prod.yml 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. # version: '3'
  2. # services:
  3. # nextjs:
  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. # mongodb:
  17. # image: mongo
  18. # volumes:
  19. # - mongodb_data:/data/db
  20. # nginx:
  21. # image: nginx:alpine
  22. # ports:
  23. # - "8088:80"
  24. # volumes:
  25. # - ./nginx:/etc/nginx/conf.d
  26. # - ./logs/nginx:/var/log/nginx
  27. # depends_on:
  28. # - nextjs
  29. # volumes:
  30. # mongodb_data:
  31. services:
  32. nextjs:
  33. container_name: match-vote-nextjs-nextjs-1
  34. build:
  35. context: .
  36. dockerfile: Dockerfile.prod
  37. args:
  38. - MONGODB_URI=mongodb://mongodb:27017/mydatabase
  39. ports:
  40. - "3000:3000"
  41. environment:
  42. - NODE_ENV=production
  43. - MONGODB_URI=mongodb://mongodb:27017/mydatabase
  44. depends_on:
  45. - mongodb
  46. restart: unless-stopped # 添加自动重启策略
  47. mongodb:
  48. image: mongo
  49. volumes:
  50. - mongodb_data:/data/db
  51. restart: unless-stopped # 添加自动重启策略
  52. nginx:
  53. image: nginx:alpine
  54. ports:
  55. - "8088:80"
  56. volumes:
  57. - ./nginx:/etc/nginx/conf.d
  58. - ./logs/nginx:/var/log/nginx
  59. depends_on:
  60. - nextjs
  61. restart: unless-stopped # 添加自动重启策略
  62. volumes:
  63. mongodb_data:
  64. networks:
  65. default:
  66. name: match-vote-network # 为网络指定一个名称