feat: 启用docker服务自动暴露并添加多个微服务

修改traefik配置以自动暴露docker服务
取消注释docker-compose中的quant-service等微服务
更新data-service的路由规则语法
This commit is contained in:
fanfpy 2025-07-01 14:52:31 +08:00
parent 2feaff1aa9
commit 832c6c5a59
3 changed files with 70 additions and 70 deletions

View File

@ -9,7 +9,7 @@
"id": "data-service-1", "id": "data-service-1",
"meta": { "meta": {
"traefik_enable": "true", "traefik_enable": "true",
"traefik_http_routers_data_service_rule": "PathPrefix(`/api/data`)" "traefik_http_routers_data_service_rule": "PathPrefix('/api/data')"
}, },
"name": "data-service", "name": "data-service",
"port": 8000 "port": 8000

View File

@ -48,78 +48,78 @@ services:
environment: environment:
- SERVICE_NAME=data-service - SERVICE_NAME=data-service
# quant-service: quant-service:
# build: ./services/quant-service build: ./services/quant-service
# container_name: ari-quant-service container_name: ari-quant-service
# restart: always restart: always
# depends_on: depends_on:
# consul: consul:
# condition: service_healthy condition: service_healthy
# expose: expose:
# - "8001" - "8001"
# networks: networks:
# - microservice-network - microservice-network
# environment: environment:
# - SERVICE_NAME=quant-service - SERVICE_NAME=quant-service
# emotion-service: emotion-service:
# build: ./services/emotion-service build: ./services/emotion-service
# container_name: ari-emotion-service container_name: ari-emotion-service
# restart: always restart: always
# depends_on: depends_on:
# consul: consul:
# condition: service_healthy condition: service_healthy
# expose: expose:
# - "8002" - "8002"
# networks: networks:
# - microservice-network - microservice-network
# environment: environment:
# - SERVICE_NAME=emotion-service - SERVICE_NAME=emotion-service
# recommend-service: recommend-service:
# build: ./services/recommend-service build: ./services/recommend-service
# container_name: ari-recommend-service container_name: ari-recommend-service
# restart: always restart: always
# depends_on: depends_on:
# consul: consul:
# condition: service_healthy condition: service_healthy
# expose: expose:
# - "8003" - "8003"
# networks: networks:
# - microservice-network - microservice-network
# environment: environment:
# - SERVICE_NAME=recommend-service - SERVICE_NAME=recommend-service
# user-service: user-service:
# build: ./services/user-service build: ./services/user-service
# container_name: ari-user-service container_name: ari-user-service
# restart: always restart: always
# depends_on: depends_on:
# consul: consul:
# condition: service_healthy condition: service_healthy
# expose: expose:
# - "8004" - "8004"
# networks: networks:
# - microservice-network - microservice-network
# environment: environment:
# - SERVICE_NAME=user-service - SERVICE_NAME=user-service
# frontend: frontend:
# build: ./services/frontend build: ./services/frontend
# container_name: ari-frontend container_name: ari-frontend
# restart: always restart: always
# depends_on: depends_on:
# - data-service - data-service
# - quant-service - quant-service
# - emotion-service - emotion-service
# - recommend-service - recommend-service
# - user-service - user-service
# expose: expose:
# - "80" - "80"
# networks: networks:
# - microservice-network - microservice-network
# environment: environment:
# - SERVICE_NAME=frontend - SERVICE_NAME=frontend
whoami: whoami:
image: traefik/whoami image: traefik/whoami

View File

@ -5,7 +5,7 @@ entryPoints:
providers: providers:
docker: docker:
exposedByDefault: false exposedByDefault: true
consulCatalog: consulCatalog:
endpoint: endpoint: