docker-compose.yml 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199
  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. - ./nginx/html/web-mobile:/home/web-mobile
  13. - ./nginx/logs:/var/log/nginx
  14. - ./nginx/conf.d:/etc/nginx/conf.d
  15. networks:
  16. - my_custom_network
  17. etcd:
  18. image: bitnami/etcd:latest
  19. container_name: etcd
  20. environment:
  21. - ALLOW_NONE_AUTHENTICATION=yes
  22. - ETCD_ADVERTISE_CLIENT_URLS=http://etcd:2379
  23. ports:
  24. - "2379:2379"
  25. - "2380:2380"
  26. restart: always
  27. networks:
  28. - my_custom_network
  29. redis:
  30. image: redis:latest
  31. container_name: redis
  32. command: ["redis-server","/usr/local/etc/redis/redis.conf"]
  33. volumes:
  34. - ./redis/data:/data
  35. - ./redis/redis.conf:/usr/local/etc/redis/redis.conf
  36. restart: always
  37. ports:
  38. - "6379:6379"
  39. networks:
  40. - my_custom_network
  41. mongodb:
  42. image: mongo:latest
  43. container_name: mongodb
  44. # environment:
  45. # - MONGO_INITDB_ROOT_USERNAME=admin
  46. # - MONGO_INITDB_ROOT_PASSWORD=123456
  47. ports:
  48. - "27017:27017"
  49. volumes:
  50. - ./mongo/mongod.conf:/etc/mongod.conf
  51. - ./mongo/db:/data/db
  52. - ./mongo/data/log:/data/log
  53. command: [ "mongod", "--config", "/etc/mongod.conf" ]
  54. restart: always
  55. networks:
  56. - my_custom_network
  57. nats:
  58. image: nats:latest
  59. container_name: nats
  60. ports:
  61. - "4222:4222"
  62. - "8222:8222"
  63. - "6222:6222"
  64. volumes:
  65. - ./nats/nats-server.conf:/etc/nats/nats-server.conf # 挂载配置文件
  66. command: -c /etc/nats/nats-server.conf # 使用配置文件启动 NATS 服务器
  67. restart: always
  68. networks:
  69. - my_custom_network
  70. center:
  71. build:
  72. context: ./center
  73. dockerfile: Dockerfile
  74. container_name: center
  75. environment:
  76. - GO_ENV=development # 可以根据需要设置环境变量
  77. - NATS_URL=nats://127.0.0.1:4222 # 确保这个环境变量存在
  78. volumes:
  79. - .:/app # 如果需要将本地代码挂载到容器中进行开发
  80. - ./config:/config # 挂载宿主机的配置文件目录到容器内的 /config
  81. restart: always
  82. networks:
  83. - my_custom_network
  84. depends_on:
  85. - etcd
  86. - nats
  87. - redis
  88. - mongodb
  89. game:
  90. build:
  91. context: ./game
  92. dockerfile: Dockerfile
  93. container_name: db
  94. environment:
  95. - GO_ENV=development # 可以根据需要设置环境变量
  96. volumes:
  97. - .:/app # 如果需要将本地代码挂载到容器中进行开发
  98. - ./config:/config # 挂载宿主机的配置文件目录到容器内的 /config
  99. restart: always
  100. networks:
  101. - my_custom_network
  102. depends_on:
  103. - etcd
  104. - nats
  105. - redis
  106. - mongodb
  107. - center
  108. master:
  109. build:
  110. context: ./master
  111. dockerfile: Dockerfile
  112. container_name: master
  113. environment:
  114. - GO_ENV=development # 可以根据需要设置环境变量
  115. volumes:
  116. - .:/app # 如果需要将本地代码挂载到容器中进行开发
  117. - ./config:/config # 挂载宿主机的配置文件目录到容器内的 /config
  118. restart: always
  119. networks:
  120. - my_custom_network
  121. depends_on:
  122. - etcd
  123. - nats
  124. - redis
  125. - mongodb
  126. web:
  127. build:
  128. context: ./web
  129. dockerfile: Dockerfile
  130. container_name: web
  131. ports:
  132. - "20000:20000"
  133. environment:
  134. - GO_ENV=development # 可以根据需要设置环境变量
  135. volumes:
  136. - .:/app # 如果需要将本地代码挂载到容器中进行开发
  137. - ./config:/config # 挂载宿主机的配置文件目录到容器内的 /config
  138. restart: always
  139. networks:
  140. - my_custom_network
  141. depends_on:
  142. - etcd
  143. - nats
  144. - redis
  145. - mongodb
  146. adminapi:
  147. build:
  148. context: ./adminapi
  149. dockerfile: Dockerfile
  150. container_name: adminapi
  151. ports:
  152. - "3030:3030"
  153. environment:
  154. - GO_ENV=development # 可以根据需要设置环境变量
  155. volumes:
  156. - .:/app # 如果需要将本地代码挂载到容器中进行开发
  157. - ./config:/config # 挂载宿主机的配置文件目录到容器内的 /config
  158. restart: always
  159. networks:
  160. - my_custom_network
  161. depends_on:
  162. - etcd
  163. - nats
  164. - redis
  165. - mongodb
  166. - center
  167. bot:
  168. build:
  169. context: ./bot
  170. dockerfile: Dockerfile
  171. container_name: bot
  172. environment:
  173. - GO_ENV=development # 可以根据需要设置环境变量
  174. volumes:
  175. - .:/app # 如果需要将本地代码挂载到容器中进行开发
  176. - ./bot:/root # 挂载宿主机的配置文件目录到容器内的 /config
  177. restart: always
  178. networks:
  179. - my_custom_network
  180. depends_on:
  181. - redis
  182. volumes:
  183. mongo_data:
  184. networks:
  185. my_custom_network:
  186. driver: bridge