31ee0d4ece
- 更新 docker-compose.yml 添加网关服务 - 更新后端 Dockerfile 支持多模块构建 - 更新网关 Dockerfile 支持多模块构建 - 前端 API 请求现在通过网关路由到后端
164 lines
3.9 KiB
YAML
164 lines
3.9 KiB
YAML
version: '3.8'
|
|
|
|
x-common-env: &common-env
|
|
TZ: Asia/Shanghai
|
|
LANG: zh_CN.UTF-8
|
|
|
|
services:
|
|
# PostgreSQL数据库服务
|
|
postgres:
|
|
image: postgres:15-alpine
|
|
container_name: novalon-postgres
|
|
environment:
|
|
<<: *common-env
|
|
POSTGRES_DB: manage_system
|
|
POSTGRES_USER: novalon
|
|
POSTGRES_PASSWORD: novalon123
|
|
POSTGRES_INITDB_ARGS: "--encoding=UTF8 --locale=zh_CN.UTF-8"
|
|
ports:
|
|
- "55432:5432"
|
|
volumes:
|
|
- postgres_data:/var/lib/postgresql/data
|
|
- ./novalon-manage-api/manage-db/src/main/resources/db/migration:/docker-entrypoint-initdb.d
|
|
healthcheck:
|
|
test: ["CMD-SHELL", "pg_isready -U novalon -d manage_system"]
|
|
interval: 10s
|
|
timeout: 5s
|
|
retries: 5
|
|
start_period: 30s
|
|
networks:
|
|
- 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:
|
|
context: ./novalon-manage-api
|
|
dockerfile: Dockerfile
|
|
args:
|
|
- BUILD_VERSION=${BUILD_VERSION:-latest}
|
|
container_name: novalon-backend
|
|
environment:
|
|
<<: *common-env
|
|
SPRING_PROFILES_ACTIVE: docker
|
|
SPRING_R2DBC_URL: r2dbc:postgresql://postgres:5432/manage_system
|
|
SPRING_R2DBC_USERNAME: novalon
|
|
SPRING_R2DBC_PASSWORD: novalon123
|
|
SPRING_JACKSON_TIME_ZONE: Asia/Shanghai
|
|
MANAGEMENT_ENDPOINTS_WEB_EXPOSURE_INCLUDE: health,info,metrics
|
|
ports:
|
|
- "8084:8084"
|
|
depends_on:
|
|
postgres:
|
|
condition: service_healthy
|
|
healthcheck:
|
|
test: ["CMD", "curl", "-f", "http://localhost:8084/actuator/health"]
|
|
interval: 30s
|
|
timeout: 10s
|
|
retries: 3
|
|
start_period: 60s
|
|
networks:
|
|
- novalon-network
|
|
restart: unless-stopped
|
|
logging:
|
|
driver: "json-file"
|
|
options:
|
|
max-size: "10m"
|
|
max-file: "3"
|
|
|
|
# 前端Web服务
|
|
frontend:
|
|
build:
|
|
context: ./novalon-manage-web
|
|
dockerfile: Dockerfile
|
|
args:
|
|
- BUILD_VERSION=${BUILD_VERSION:-latest}
|
|
container_name: novalon-frontend
|
|
ports:
|
|
- "3001:80"
|
|
depends_on:
|
|
gateway:
|
|
condition: service_healthy
|
|
environment:
|
|
<<: *common-env
|
|
VITE_API_BASE_URL: http://gateway:8080
|
|
healthcheck:
|
|
test: ["CMD", "curl", "-f", "http://localhost:80"]
|
|
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"
|
|
|
|
# Redis缓存服务(可选)
|
|
redis:
|
|
image: redis:7-alpine
|
|
container_name: novalon-redis
|
|
environment:
|
|
<<: *common-env
|
|
ports:
|
|
- "6379:6379"
|
|
command: redis-server --appendonly yes --requirepass novalon123
|
|
volumes:
|
|
- redis_data:/data
|
|
healthcheck:
|
|
test: ["CMD", "redis-cli", "ping"]
|
|
interval: 10s
|
|
timeout: 3s
|
|
retries: 5
|
|
networks:
|
|
- novalon-network
|
|
restart: unless-stopped
|
|
|
|
volumes:
|
|
postgres_data:
|
|
driver: local
|
|
redis_data:
|
|
driver: local
|
|
|
|
networks:
|
|
novalon-network:
|
|
driver: bridge
|
|
ipam:
|
|
config:
|
|
- subnet: 172.20.0.0/16 |