docker-compose.yml 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. #version: '3.9'
  2. services:
  3. nginx:
  4. restart: always
  5. container_name: nginx
  6. image: nginx
  7. # build:
  8. # context: ./nginx
  9. ports:
  10. - "80:80"
  11. volumes:
  12. - /home/docker/nginx/html/web-mobile:/home/web-mobile
  13. - /home/docker/nginx/logs:/var/log/nginx
  14. - /home/docker/nginx/conf.d:/etc/nginx/conf.d
  15. - /home/docker/nginx/ssl:/www/nginx
  16. networks:
  17. - my_custom_network
  18. # depends_on:
  19. # - certbot
  20. #
  21. # certbot:
  22. # image: certbot/certbot
  23. # volumes:
  24. # - /home/docker/nginx/ssl/:/etc/letsencrypt
  25. # - /home/docker/nginx/html:/var/www/html
  26. # command: >
  27. # sh -c "trap exit TERM; while :; do certbot renew --webroot --webroot-path=/var/www/html --quiet; sleep 12h & wait $$!; done;"
  28. # networks:
  29. # - my_custom_network
  30. etcd:
  31. image: bitnami/etcd:latest
  32. container_name: etcd
  33. environment:
  34. - ALLOW_NONE_AUTHENTICATION=yes
  35. - ETCD_ADVERTISE_CLIENT_URLS=http://etcd:2379
  36. ports:
  37. - "2379:2379"
  38. - "2380:2380"
  39. restart: always
  40. networks:
  41. - my_custom_network
  42. redis:
  43. image: redis:latest
  44. container_name: redis
  45. ports:
  46. - "6379:6379"
  47. command: ["redis-server", "--appendonly", "yes"]
  48. restart: always
  49. networks:
  50. - my_custom_network
  51. mongodb:
  52. image: mongo:latest
  53. container_name: mongodb
  54. # environment:
  55. # - MONGO_INITDB_ROOT_USERNAME=admin
  56. # - MONGO_INITDB_ROOT_PASSWORD=123456
  57. ports:
  58. - "27017:27017"
  59. volumes:
  60. - mongo_data:/data/db
  61. restart: always
  62. networks:
  63. - my_custom_network
  64. nats:
  65. image: nats:latest
  66. container_name: nats
  67. ports:
  68. - "4222:4222"
  69. - "8222:8222"
  70. - "6222:6222"
  71. restart: always
  72. networks:
  73. - my_custom_network
  74. center:
  75. build:
  76. context: ./center
  77. dockerfile: Dockerfile
  78. container_name: center
  79. # ports:
  80. # - "8080:8080"
  81. environment:
  82. - GO_ENV=development # 可以根据需要设置环境变量
  83. - NATS_URL=nats://127.0.0.1:4222 # 确保这个环境变量存在
  84. volumes:
  85. - .:/app # 如果需要将本地代码挂载到容器中进行开发
  86. - ./config:/config # 挂载宿主机的配置文件目录到容器内的 /config
  87. restart: always
  88. networks:
  89. - my_custom_network
  90. game:
  91. build:
  92. context: ./game
  93. dockerfile: Dockerfile
  94. container_name: game
  95. # ports:
  96. # - "8080:8080"
  97. environment:
  98. - GO_ENV=development # 可以根据需要设置环境变量
  99. volumes:
  100. - .:/app # 如果需要将本地代码挂载到容器中进行开发
  101. - ./config:/config # 挂载宿主机的配置文件目录到容器内的 /config
  102. restart: always
  103. networks:
  104. - my_custom_network
  105. master:
  106. build:
  107. context: ./master
  108. dockerfile: Dockerfile
  109. container_name: master
  110. # ports:
  111. # - "8080:8080"
  112. environment:
  113. - GO_ENV=development # 可以根据需要设置环境变量
  114. volumes:
  115. - .:/app # 如果需要将本地代码挂载到容器中进行开发
  116. - ./config:/config # 挂载宿主机的配置文件目录到容器内的 /config
  117. restart: always
  118. networks:
  119. - my_custom_network
  120. web:
  121. build:
  122. context: ./web
  123. dockerfile: Dockerfile
  124. container_name: web
  125. ports:
  126. - "20000:20000"
  127. environment:
  128. - GO_ENV=development # 可以根据需要设置环境变量
  129. volumes:
  130. - .:/app # 如果需要将本地代码挂载到容器中进行开发
  131. - ./config:/config # 挂载宿主机的配置文件目录到容器内的 /config
  132. restart: always
  133. networks:
  134. - my_custom_network
  135. volumes:
  136. mongo_data:
  137. networks:
  138. my_custom_network:
  139. driver: bridge