docker-compose.yml 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243
  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: game
  94. environment:
  95. - GO_ENV=development # 可以根据需要设置环境变量
  96. volumes:
  97. - .:/app # 如果需要将本地代码挂载到容器中进行开发
  98. - ./config:/config # 挂载宿主机的配置文件目录到容器内的 /config
  99. restart: always
  100. command: ["sh","-c","./game game --path=/config/profile-gc.json --node=10001"]
  101. networks:
  102. - my_custom_network
  103. depends_on:
  104. - etcd
  105. - nats
  106. - redis
  107. - mongodb
  108. - center
  109. game-2:
  110. build:
  111. context: ./game
  112. dockerfile: Dockerfile
  113. container_name: game-2
  114. environment:
  115. - GO_ENV=development # 可以根据需要设置环境变量
  116. volumes:
  117. - .:/app # 如果需要将本地代码挂载到容器中进行开发
  118. - ./config:/config # 挂载宿主机的配置文件目录到容器内的 /config
  119. restart: always
  120. command: ["sh","-c","./game game --path=/config/profile-gc.json --node=10002"]
  121. networks:
  122. - my_custom_network
  123. depends_on:
  124. - etcd
  125. - nats
  126. - redis
  127. - mongodb
  128. - center
  129. game-3:
  130. build:
  131. context: ./game
  132. dockerfile: Dockerfile
  133. container_name: game-3
  134. environment:
  135. - GO_ENV=development # 可以根据需要设置环境变量
  136. volumes:
  137. - .:/app # 如果需要将本地代码挂载到容器中进行开发
  138. - ./config:/config # 挂载宿主机的配置文件目录到容器内的 /config
  139. restart: always
  140. command: [ "sh","-c","./game game --path=/config/profile-gc.json --node=10003" ]
  141. networks:
  142. - my_custom_network
  143. depends_on:
  144. - etcd
  145. - nats
  146. - redis
  147. - mongodb
  148. - center
  149. master:
  150. build:
  151. context: ./master
  152. dockerfile: Dockerfile
  153. container_name: master
  154. environment:
  155. - GO_ENV=development # 可以根据需要设置环境变量
  156. volumes:
  157. - .:/app # 如果需要将本地代码挂载到容器中进行开发
  158. - ./config:/config # 挂载宿主机的配置文件目录到容器内的 /config
  159. restart: always
  160. networks:
  161. - my_custom_network
  162. depends_on:
  163. - etcd
  164. - nats
  165. - redis
  166. - mongodb
  167. web:
  168. build:
  169. context: ./web
  170. dockerfile: Dockerfile
  171. container_name: web
  172. ports:
  173. - "20000:20000"
  174. environment:
  175. - GO_ENV=development # 可以根据需要设置环境变量
  176. volumes:
  177. - .:/app # 如果需要将本地代码挂载到容器中进行开发
  178. - ./config:/config # 挂载宿主机的配置文件目录到容器内的 /config
  179. restart: always
  180. networks:
  181. - my_custom_network
  182. depends_on:
  183. - etcd
  184. - nats
  185. - redis
  186. - mongodb
  187. adminapi:
  188. build:
  189. context: ./adminapi
  190. dockerfile: Dockerfile
  191. container_name: adminapi
  192. ports:
  193. - "3030:3030"
  194. environment:
  195. - GO_ENV=development # 可以根据需要设置环境变量
  196. volumes:
  197. - .:/app # 如果需要将本地代码挂载到容器中进行开发
  198. - ./config:/config # 挂载宿主机的配置文件目录到容器内的 /config
  199. restart: always
  200. networks:
  201. - my_custom_network
  202. depends_on:
  203. - etcd
  204. - nats
  205. - redis
  206. - mongodb
  207. - center
  208. bot:
  209. build:
  210. context: ./bot
  211. dockerfile: Dockerfile
  212. container_name: bot
  213. environment:
  214. - GO_ENV=development # 可以根据需要设置环境变量
  215. volumes:
  216. - .:/app # 如果需要将本地代码挂载到容器中进行开发
  217. - ./bot:/root # 挂载宿主机的配置文件目录到容器内的 /config
  218. restart: always
  219. networks:
  220. - my_custom_network
  221. depends_on:
  222. - redis
  223. volumes:
  224. mongo_data:
  225. networks:
  226. my_custom_network:
  227. driver: bridge