区分环境

This commit is contained in:
2024-10-02 11:27:51 +08:00
parent ab842d8694
commit b8d9a72dac
30 changed files with 626 additions and 181 deletions

View File

@@ -1,64 +1,75 @@
version: '3'
services:
etcd:
tyapi_etcd:
image: bitnami/etcd
container_name: etcd
container_name: tyapi_etcd
environment:
- TZ=Asia/Shanghai
- ALLOW_NONE_AUTHENTICATION=yes
#- ETCD_ADVERTISE_CLIENT_URLS=http://etcd:2379
- ETCD_ADVERTISE_CLIENT_URLS=http://127.0.0.1:2379
ports:
- "2379:2379" # 宿主机可以通过127.0.0.1:2379访问etcd服务
networks:
- tyapi_network
restart: always
etcdManage:
tyapi_etcdManage:
image: evildecay/etcdkeeper
container_name: etcdManage
container_name: tyapi_etcdManage
environment:
- TZ=Asia/Shanghai
ports:
- "7000:8080" # 将容器的8080端口映射到宿主机的7000端口便于web访问
depends_on:
- etcd # 确保etcd容器先启动
- tyapi_etcd
networks:
- tyapi_network
restart: always
zookeeper:
image: wurstmeister/zookeeper
ports:
- "2181:2181"
kafka:
tyapi_zookeeper:
image: wurstmeister/zookeeper
container_name: tyapi_zookeeper
networks:
- tyapi_network
restart: always
tyapi_kafka:
image: wurstmeister/kafka
ports:
- "9092:9092"
container_name: tyapi_kafka
environment:
KAFKA_LISTENERS: PLAINTEXT://0.0.0.0:9092
KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://localhost:9092
KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181
KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://tyapi_kafka:9092
KAFKA_ZOOKEEPER_CONNECT: tyapi_zookeeper:2181
volumes:
- /var/run/docker.sock:/var/run/docker.sock
redis:
image: redis:7.4.0
ports:
- "6379:6379"
networks:
- tyapi_network
restart: always
mysql:
tyapi_redis:
image: redis:7.4.0
container_name: tyapi_redis
ports:
- "11002:6379"
networks:
- tyapi_network
restart: always
tyapi_mysql:
image: mysql:8.0.34
container_name: tyapi_mysql
environment:
- MYSQL_ROOT_PASSWORD=rootpassword
- MYSQL_DATABASE=tianyuanapi
- MYSQL_USER=tianyuanapi
- MYSQL_PASSWORD=g3h98u0291j
ports:
- "3307:3306"
- "11001:3306"
volumes:
- mysql_data:/var/lib/mysql
networks:
- tyapi_network
- 1panel-network
restart: always
# Gateway service
gateway:
tyapi_gateway:
container_name: tyapi_gateway
build:
context: .
dockerfile: ./apps/gateway/Dockerfile
@@ -67,14 +78,17 @@ services:
environment:
- ENV=production
depends_on:
- etcd
- redis
- mysql
- user
- sentinel
- tyapi_etcd
- tyapi_redis
- tyapi_mysql
- tyapi_user
- tyapi_sentinel
networks:
- tyapi_network
restart: always
# Admin service
admin:
tyapi_admin:
container_name: tyapi_admin
build:
context: .
dockerfile: ./apps/admin/Dockerfile
@@ -83,14 +97,17 @@ services:
environment:
- ENV=production
depends_on:
- etcd
- redis
- mysql
- user
- sentinel
- tyapi_etcd
- tyapi_redis
- tyapi_mysql
- tyapi_user
- tyapi_sentinel
networks:
- tyapi_network
restart: always
# API service
api:
tyapi_api:
container_name: tyapi_api
build:
context: .
dockerfile: ./apps/api/Dockerfile
@@ -99,58 +116,70 @@ services:
environment:
- ENV=production
depends_on:
- etcd
- redis
- mysql
- user
- sentinel
- mqs
- kafka
- tyapi_etcd
- tyapi_redis
- tyapi_mysql
- tyapi_user
- tyapi_sentinel
- tyapi_mqs
- tyapi_kafka
networks:
- tyapi_network
restart: always
# MQS service
mqs:
tyapi_mqs:
container_name: tyapi_mqs
build:
context: .
dockerfile: ./apps/mqs/Dockerfile
ports:
- "12001:12001"
environment:
- ENV=production
depends_on:
- kafka
- etcd
- redis
- user
- sentinel
- tyapi_kafka
- tyapi_etcd
- tyapi_redis
- tyapi_user
- tyapi_sentinel
networks:
- tyapi_network
restart: always
# Sentinel service
sentinel:
tyapi_sentinel:
container_name: tyapi_sentinel
build:
context: .
dockerfile: ./apps/sentinel/Dockerfile
ports:
- "11002:11002"
environment:
- ENV=production
depends_on:
- redis
- mysql
- etcd
- tyapi_redis
- tyapi_mysql
- tyapi_etcd
networks:
- tyapi_network
restart: always
# User service
user:
tyapi_user:
container_name: tyapi_user
build:
context: .
dockerfile: ./apps/user/Dockerfile
ports:
- "11001:11001"
environment:
- ENV=production
depends_on:
- mysql
- redis
- etcd
- tyapi_mysql
- tyapi_redis
- tyapi_etcd
networks:
- tyapi_network
restart: always
volumes:
mysql_data:
driver: local
driver: local
networks:
tyapi_network:
driver: bridge
1panel-network:
external: true