refactor(docker): 优化docker-compose配置结构和镜像地址

- 重新组织服务配置结构,使其更清晰易读
- 更新镜像地址为阿里云registry标准格式
- 调整端口映射和健康检查配置
- 规范服务依赖关系声明
This commit is contained in:
fanfpy 2025-07-17 13:09:45 +08:00
parent 49cac43f4f
commit 28e572d700

View File

@ -8,14 +8,13 @@ services:
consul:
image: consul:1.15
container_name: ari-consul
command: "consul agent -server -bootstrap-expect=1 ${CONSUL_DEV_MODE} -config-dir=/consul/config -client=0.0.0.0"
restart: always
ports:
- "8500:8500"
- "8600:8600/udp"
- "8500:8500" # Consul Web UI
- "8600:8600/udp" # DNS服务
volumes:
- ./consul/config/${ENV_CONFIG_DIR}:/consul/config
environment:
- CONSUL_DEV_MODE=-dev
command: "consul agent -server -bootstrap-expect=1 ${CONSUL_DEV_MODE} -config-dir=/consul/config -client=0.0.0.0"
networks:
- microservice-network
healthcheck:
@ -23,7 +22,6 @@ services:
interval: 10s
timeout: 5s
retries: 3
restart: always
traefik:
image: traefik:v2.11
@ -33,99 +31,100 @@ services:
ports:
- "80:80"
- "443:443"
- "8080:8080"
- "8080:8080" # Traefik dashboard
volumes:
- ./traefik/certs:/etc/traefik/certs
- ./traefik/config/${TRAEFIK_CONFIG_DIR}/traefik.yml:/etc/traefik/traefik.yml
- /var/run/docker.sock:/var/run/docker.sock
depends_on: []
- ./traefik/config/${TRAEFIK_CONFIG_DIR}/traefik.yml:/etc/traefik/traefik.yml
- ./traefik/certs:/etc/traefik/certs
networks:
- microservice-network
restart: always
data-service:
image: crpi-amr0dt5e5pywqwaf.cn-hangzhou.personal.cr.aliyuncs.com/testrrr/data-service:latest
image: registry.cn-hangzhou.aliyuncs.com/testrrr/data-service:latest
container_name: ari-data-service
expose:
- "8000"
restart: always
ports:
- "8000:8000"
networks:
- microservice-network
environment:
- SERVICE_NAME=data-service
networks:
- microservice-network
depends_on:
- data-service
- quant-service
- emotion-service
- recommend-service
- user-service
restart: always
emotion-service:
image: crpi-amr0dt5e5pywqwaf.cn-hangzhou.personal.cr.aliyuncs.com/testrrr/emotion-service:latest
container_name: ari-emotion-service
expose:
- "8002"
environment:
- SERVICE_NAME=emotion-service
networks:
- microservice-network
depends_on:
- consul
restart: always
frontend:
image: crpi-amr0dt5e5pywqwaf.cn-hangzhou.personal.cr.aliyuncs.com/testrrr/frontend:latest
container_name: ari-frontend
expose:
- "80"
environment:
- SERVICE_NAME=frontend
networks:
- microservice-network
depends_on:
- consul
restart: always
quant-service:
image: crpi-amr0dt5e5pywqwaf.cn-hangzhou.personal.cr.aliyuncs.com/testrrr/quant-service:latest
image: registry.cn-hangzhou.aliyuncs.com/testrrr/quant-service:latest
container_name: ari-quant-service
restart: always
depends_on:
consul:
condition: service_healthy
expose:
- "8001"
networks:
- microservice-network
environment:
- SERVICE_NAME=quant-service
emotion-service:
image: registry.cn-hangzhou.aliyuncs.com/testrrr/emotion-service:latest
container_name: ari-emotion-service
restart: always
depends_on:
consul:
condition: service_healthy
expose:
- "8002"
networks:
- microservice-network
depends_on:
- consul
restart: always
environment:
- SERVICE_NAME=emotion-service
recommend-service:
image: crpi-amr0dt5e5pywqwaf.cn-hangzhou.personal.cr.aliyuncs.com/testrrr/recommend-service:latest
image: registry.cn-hangzhou.aliyuncs.com/testrrr/recommend-service:latest
container_name: ari-recommend-service
restart: always
depends_on:
consul:
condition: service_healthy
expose:
- "8003"
environment:
- SERVICE_NAME=recommend-service
networks:
- microservice-network
depends_on:
- consul
restart: always
environment:
- SERVICE_NAME=recommend-service
user-service:
image: crpi-amr0dt5e5pywqwaf.cn-hangzhou.personal.cr.aliyuncs.com/testrrr/user-service:latest
container_name: ari-user-service
expose:
- "8004"
environment:
- SERVICE_NAME=user-service
networks:
- microservice-network
depends_on: []
restart: always
image: registry.cn-hangzhou.aliyuncs.com/testrrr/user-service:latest
container_name: ari-user-service
restart: always
depends_on:
consul:
condition: service_healthy
expose:
- "8004"
networks:
- microservice-network
environment:
- SERVICE_NAME=user-service
frontend:
image: registry.cn-hangzhou.aliyuncs.com/testrrr/frontend:latest
container_name: ari-frontend
restart: always
depends_on:
- data-service
- quant-service
- emotion-service
- recommend-service
- user-service
expose:
- "80"
networks:
- microservice-network
environment:
- SERVICE_NAME=frontend
whoami:
image: traefik/whoami
container_name: whoami
networks:
- microservice-network
- microservice-network