123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262 |
- #version: '3.9'
- services:
- nginx:
- restart: always
- container_name: nginx
- image: nginx
- # build:
- # context: ./nginx
- ports:
- - "80:80"
- volumes:
- - ./nginx/html/web-mobile:/home/web-mobile
- - ./nginx/logs:/var/log/nginx
- - ./nginx/conf.d:/etc/nginx/conf.d
- networks:
- - my_custom_network
- etcd:
- image: bitnami/etcd:latest
- container_name: etcd
- environment:
- - ALLOW_NONE_AUTHENTICATION=yes
- - ETCD_ADVERTISE_CLIENT_URLS=http://etcd:2379
- ports:
- - "2379:2379"
- - "2380:2380"
- restart: always
- networks:
- - my_custom_network
- redis:
- image: redis:latest
- container_name: redis
- command: ["redis-server","/usr/local/etc/redis/redis.conf"]
- volumes:
- - ./redis/data:/data
- - ./redis/redis.conf:/usr/local/etc/redis/redis.conf
- restart: always
- ports:
- - "6379:6379"
- networks:
- - my_custom_network
- mongodb:
- image: mongo:latest
- container_name: mongodb
- # environment:
- # - MONGO_INITDB_ROOT_USERNAME=admin
- # - MONGO_INITDB_ROOT_PASSWORD=123456
- ports:
- - "27017:27017"
- volumes:
- - ./mongo/mongod.conf:/etc/mongod.conf
- - ./mongo/database:/data/database
- - ./mongo/data/log:/data/log
- command: [ "mongod", "--config", "/etc/mongod.conf" ]
- restart: always
- networks:
- - my_custom_network
- nats:
- image: nats:latest
- container_name: nats
- ports:
- - "4222:4222"
- - "8222:8222"
- - "6222:6222"
- volumes:
- - ./nats/nats-server.conf:/etc/nats/nats-server.conf # 挂载配置文件
- command: -c /etc/nats/nats-server.conf # 使用配置文件启动 NATS 服务器
- restart: always
- networks:
- - my_custom_network
- center:
- build:
- context: ./center
- dockerfile: Dockerfile
- container_name: center
- environment:
- - GO_ENV=development # 可以根据需要设置环境变量
- - NATS_URL=nats://127.0.0.1:4222 # 确保这个环境变量存在
- volumes:
- - .:/app # 如果需要将本地代码挂载到容器中进行开发
- - ./config:/config # 挂载宿主机的配置文件目录到容器内的 /config
- restart: always
- networks:
- - my_custom_network
- depends_on:
- - etcd
- - nats
- - redis
- - mongodb
- game:
- build:
- context: ./game
- dockerfile: Dockerfile
- container_name: game
- environment:
- - GO_ENV=development # 可以根据需要设置环境变量
- volumes:
- - .:/app # 如果需要将本地代码挂载到容器中进行开发
- - ./config:/config # 挂载宿主机的配置文件目录到容器内的 /config
- restart: always
- command: ["sh","-c","./game game --path=/config/profile-gc.json --node=10001"]
- networks:
- - my_custom_network
- depends_on:
- - etcd
- - nats
- - redis
- - mongodb
- - center
- game-2:
- build:
- context: ./game
- dockerfile: Dockerfile
- container_name: game-2
- environment:
- - GO_ENV=development # 可以根据需要设置环境变量
- volumes:
- - .:/app # 如果需要将本地代码挂载到容器中进行开发
- - ./config:/config # 挂载宿主机的配置文件目录到容器内的 /config
- restart: always
- command: ["sh","-c","./game game --path=/config/profile-gc.json --node=10002"]
- networks:
- - my_custom_network
- depends_on:
- - etcd
- - nats
- - redis
- - mongodb
- - center
- game-3:
- build:
- context: ./game
- dockerfile: Dockerfile
- container_name: game-3
- environment:
- - GO_ENV=development # 可以根据需要设置环境变量
- volumes:
- - .:/app # 如果需要将本地代码挂载到容器中进行开发
- - ./config:/config # 挂载宿主机的配置文件目录到容器内的 /config
- restart: always
- command: [ "sh","-c","./game game --path=/config/profile-gc.json --node=10003" ]
- networks:
- - my_custom_network
- depends_on:
- - etcd
- - nats
- - redis
- - mongodb
- - center
- master:
- build:
- context: ./master
- dockerfile: Dockerfile
- container_name: master
- environment:
- - GO_ENV=development # 可以根据需要设置环境变量
- volumes:
- - .:/app # 如果需要将本地代码挂载到容器中进行开发
- - ./config:/config # 挂载宿主机的配置文件目录到容器内的 /config
- restart: always
- networks:
- - my_custom_network
- depends_on:
- - etcd
- - nats
- - redis
- - mongodb
- web:
- build:
- context: ./web
- dockerfile: Dockerfile
- container_name: web
- ports:
- - "20000:20000"
- environment:
- - GO_ENV=development # 可以根据需要设置环境变量
- volumes:
- - .:/app # 如果需要将本地代码挂载到容器中进行开发
- - ./config:/config # 挂载宿主机的配置文件目录到容器内的 /config
- restart: always
- networks:
- - my_custom_network
- depends_on:
- - etcd
- - nats
- - redis
- - mongodb
- database:
- build:
- context: ./database
- dockerfile: Dockerfile
- container_name: database
- environment:
- - GO_ENV=development # 可以根据需要设置环境变量
- volumes:
- - .:/app # 如果需要将本地代码挂载到容器中进行开发
- - ./config:/config # 挂载宿主机的配置文件目录到容器内的 /config
- restart: always
- networks:
- - my_custom_network
- depends_on:
- - etcd
- - nats
- - redis
- - mongodb
- adminapi:
- build:
- context: ./adminapi
- dockerfile: Dockerfile
- container_name: adminapi
- ports:
- - "3030:3030"
- environment:
- - GO_ENV=development # 可以根据需要设置环境变量
- volumes:
- - .:/app # 如果需要将本地代码挂载到容器中进行开发
- - ./config:/config # 挂载宿主机的配置文件目录到容器内的 /config
- restart: always
- networks:
- - my_custom_network
- depends_on:
- - etcd
- - nats
- - redis
- - mongodb
- - center
- bot:
- build:
- context: ./bot
- dockerfile: Dockerfile
- container_name: bot
- environment:
- - GO_ENV=development # 可以根据需要设置环境变量
- volumes:
- - .:/app # 如果需要将本地代码挂载到容器中进行开发
- - ./bot:/root # 挂载宿主机的配置文件目录到容器内的 /config
- restart: always
- networks:
- - my_custom_network
- depends_on:
- - redis
- volumes:
- mongo_data:
- networks:
- my_custom_network:
- driver: bridge
|