feat(docker): 添加网关服务,实现前端-》网关-》后端调用链路
- 更新 docker-compose.yml 添加网关服务 - 更新后端 Dockerfile 支持多模块构建 - 更新网关 Dockerfile 支持多模块构建 - 前端 API 请求现在通过网关路由到后端
This commit is contained in:
+35
-2
@@ -30,6 +30,39 @@ services:
|
||||
- novalon-network
|
||||
restart: unless-stopped
|
||||
|
||||
# 网关服务
|
||||
gateway:
|
||||
build:
|
||||
context: ./novalon-manage-api
|
||||
dockerfile: manage-gateway/Dockerfile
|
||||
args:
|
||||
- BUILD_VERSION=${BUILD_VERSION:-latest}
|
||||
container_name: novalon-gateway
|
||||
environment:
|
||||
<<: *common-env
|
||||
SPRING_PROFILES_ACTIVE: docker
|
||||
USER_SERVICE_URL: http://backend:8084
|
||||
SPRING_CLOUD_GATEWAY_ROUTES_0_URI: http://backend:8084
|
||||
ports:
|
||||
- "8080:8080"
|
||||
depends_on:
|
||||
backend:
|
||||
condition: service_healthy
|
||||
healthcheck:
|
||||
test: ["CMD", "curl", "-f", "http://localhost:8080/actuator/health"]
|
||||
interval: 30s
|
||||
timeout: 10s
|
||||
retries: 3
|
||||
start_period: 40s
|
||||
networks:
|
||||
- novalon-network
|
||||
restart: unless-stopped
|
||||
logging:
|
||||
driver: "json-file"
|
||||
options:
|
||||
max-size: "10m"
|
||||
max-file: "3"
|
||||
|
||||
# 后端API服务
|
||||
backend:
|
||||
build:
|
||||
@@ -77,11 +110,11 @@ services:
|
||||
ports:
|
||||
- "3001:80"
|
||||
depends_on:
|
||||
backend:
|
||||
gateway:
|
||||
condition: service_healthy
|
||||
environment:
|
||||
<<: *common-env
|
||||
VITE_API_BASE_URL: http://backend:8084
|
||||
VITE_API_BASE_URL: http://gateway:8080
|
||||
healthcheck:
|
||||
test: ["CMD", "curl", "-f", "http://localhost:80"]
|
||||
interval: 30s
|
||||
|
||||
Reference in New Issue
Block a user