ci(docker): 更新docker-compose配置和容器版本

- 升级consul和traefik到新版本
- 为服务添加健康检查和环境变量配置
- 统一容器命名规范为ari-前缀
- 修改端口暴露方式和重启策略
- 添加whoami服务用于测试
This commit is contained in:
fanfpy 2025-07-17 11:35:35 +08:00
parent f12448c7d8
commit 9f37b523bd

View File

@ -6,105 +6,126 @@ networks:
services:
consul:
image: consul:1.11.4
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
command: "consul agent -server -bootstrap-expect=1 ${CONSUL_DEV_MODE} -config-dir=/consul/config -client=0.0.0.0"
ports:
- "8500:8500"
- "8600:8600/udp"
volumes:
- ./consul/config:/consul/config
- ./consul/config/${ENV_CONFIG_DIR}:/consul/config
environment:
- CONSUL_DEV_MODE=-dev
networks:
- microservice-network
restart: unless-stopped
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:8500/v1/status/leader"]
interval: 10s
timeout: 5s
retries: 3
restart: always
traefik:
image: traefik:v2.9
image: traefik:v2.11
container_name: ari-traefik
command:
- "--providers.consulcatalog=true"
- "--providers.consulcatalog.endpoint.address=ari-consul:8500"
- "--providers.consulcatalog.service.name=traefik"
- "--api.dashboard=true"
- "--log.level=INFO"
- --configFile=/etc/traefik/traefik.yml
ports:
- "80:80"
- "443:443"
- "8080:8080"
volumes:
- ./traefik/certs:/etc/traefik/certs
- ./traefik/config:/etc/traefik/config
- /var/run/docker.sock:/var/run/docker.sock:ro
depends_on:
- consul
- ./traefik/config/${TRAEFIK_CONFIG_DIR}/traefik.yml:/etc/traefik/traefik.yml
- /var/run/docker.sock:/var/run/docker.sock
depends_on: []
networks:
- microservice-network
restart: unless-stopped
restart: always
data-service:
image: crpi-amr0dt5e5pywqwaf.cn-hangzhou.personal.cr.aliyuncs.com/testrrr/data-service:latest
container_name: data-service
ports:
- "8001:80"
container_name: ari-data-service
expose:
- "8000"
environment:
- SERVICE_NAME=data-service
networks:
- microservice-network
depends_on:
- consul
restart: unless-stopped
- 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: emotion-service
ports:
- "8002:80"
container_name: ari-emotion-service
expose:
- "8002"
environment:
- SERVICE_NAME=emotion-service
networks:
- microservice-network
depends_on:
- consul
restart: unless-stopped
restart: always
frontend:
image: crpi-amr0dt5e5pywqwaf.cn-hangzhou.personal.cr.aliyuncs.com/testrrr/frontend:latest
container_name: frontend
ports:
- "8000:80"
container_name: ari-frontend
expose:
- "80"
environment:
- SERVICE_NAME=frontend
networks:
- microservice-network
depends_on:
- consul
restart: unless-stopped
restart: always
quant-service:
image: crpi-amr0dt5e5pywqwaf.cn-hangzhou.personal.cr.aliyuncs.com/testrrr/quant-service:latest
container_name: quant-service
ports:
- "8005:80"
container_name: ari-quant-service
expose:
- "8001"
environment:
- SERVICE_NAME=quant-service
networks:
- microservice-network
depends_on:
- consul
restart: unless-stopped
restart: always
recommend-service:
image: crpi-amr0dt5e5pywqwaf.cn-hangzhou.personal.cr.aliyuncs.com/testrrr/recommend-service:latest
container_name: recommend-service
ports:
- "8003:80"
container_name: ari-recommend-service
expose:
- "8003"
environment:
- SERVICE_NAME=recommend-service
networks:
- microservice-network
depends_on:
- consul
restart: unless-stopped
restart: always
user-service:
image: crpi-amr0dt5e5pywqwaf.cn-hangzhou.personal.cr.aliyuncs.com/testrrr/user-service:latest
container_name: user-service
ports:
- "8004:80"
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
whoami:
image: traefik/whoami
container_name: whoami
networks:
- microservice-network
depends_on:
- consul
restart: unless-stopped