Files
novalon-manage-system/docker-compose.test.yml
T

123 lines
2.9 KiB
YAML

version: '3.8'
services:
# PostgreSQL 数据库(用于测试)
postgres:
image: postgres:15-alpine
container_name: novalon-test-db
environment:
POSTGRES_DB: novalon_test
POSTGRES_USER: novalon
POSTGRES_PASSWORD: novalon123
ports:
- "5432:5432"
volumes:
- postgres_test_data:/var/lib/postgresql/data
healthcheck:
test: ["CMD-SHELL", "pg_isready -U novalon -d novalon_test"]
interval: 10s
timeout: 5s
retries: 5
networks:
- novalon-test-network
# Redis 缓存(可选)
redis:
image: redis:7-alpine
container_name: novalon-test-redis
ports:
- "6379:6379"
healthcheck:
test: ["CMD", "redis-cli", "ping"]
interval: 10s
timeout: 5s
retries: 5
networks:
- novalon-test-network
# 后端服务
backend:
build:
context: ./novalon-manage-api
dockerfile: Dockerfile
container_name: novalon-test-backend
environment:
SPRING_PROFILES_ACTIVE: test
SPRING_R2DBC_URL: r2dbc:postgresql://postgres:5432/novalon_test
SPRING_R2DBC_USERNAME: novalon
SPRING_R2DBC_PASSWORD: novalon123
SPRING_FLYWAY_URL: jdbc:postgresql://postgres:5432/novalon_test
SPRING_FLYWAY_USER: novalon
SPRING_FLYWAY_PASSWORD: novalon123
SPRING_DATA_REDIS_HOST: redis
SPRING_DATA_REDIS_PORT: 6379
ports:
- "8084:8084"
depends_on:
postgres:
condition: service_healthy
redis:
condition: service_healthy
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:8084/actuator/health"]
interval: 30s
timeout: 10s
retries: 5
start_period: 60s
networks:
- novalon-test-network
# 网关服务
gateway:
build:
context: ./novalon-manage-api/manage-gateway
dockerfile: Dockerfile
container_name: novalon-test-gateway
environment:
SPRING_PROFILES_ACTIVE: test
BACKEND_SERVICE_URL: http://backend:8084
SPRING_DATA_REDIS_HOST: redis
SPRING_DATA_REDIS_PORT: 6379
ports:
- "8080:8080"
depends_on:
backend:
condition: service_healthy
redis:
condition: service_healthy
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:8080/actuator/health"]
interval: 30s
timeout: 10s
retries: 5
start_period: 30s
networks:
- novalon-test-network
# 前端服务(开发模式)
frontend:
build:
context: ./novalon-manage-web
dockerfile: Dockerfile.dev
container_name: novalon-test-frontend
environment:
VITE_API_BASE_URL: http://gateway:8080
ports:
- "3002:3002"
volumes:
- ./novalon-manage-web:/app
- /app/node_modules
depends_on:
gateway:
condition: service_healthy
networks:
- novalon-test-network
volumes:
postgres_test_data:
driver: local
networks:
novalon-test-network:
driver: bridge