version: '3.8' services: # MySQL数据库 mysql: image: mysql:8.0 container_name: smart-qa-mysql restart: unless-stopped environment: MYSQL_ROOT_PASSWORD: rootpassword MYSQL_DATABASE: smart_qa MYSQL_USER: appuser MYSQL_PASSWORD: apppassword MYSQL_CHARSET: utf8mb4 MYSQL_COLLATION: utf8mb4_unicode_ci ports: - "3306:3306" volumes: - mysql_data:/var/lib/mysql - ./docker/mysql/init:/docker-entrypoint-initdb.d - ./docker/mysql/conf.d:/etc/mysql/conf.d networks: - smart-qa-network healthcheck: test: ["CMD", "mysqladmin", "ping", "-h", "localhost"] timeout: 20s retries: 10 # PostgreSQL数据库 (用于向量存储) postgres: image: postgres:15 container_name: smart-qa-postgres restart: unless-stopped environment: POSTGRES_DB: smart_qa_vector POSTGRES_USER: vectoruser POSTGRES_PASSWORD: vectorpassword POSTGRES_INITDB_ARGS: "--encoding=UTF-8" ports: - "5432:5432" volumes: - postgres_data:/var/lib/postgresql/data - ./docker/postgres/init:/docker-entrypoint-initdb.d networks: - smart-qa-network healthcheck: test: ["CMD-SHELL", "pg_isready -U vectoruser -d smart_qa_vector"] interval: 30s timeout: 10s retries: 5 # Redis缓存 redis: image: redis:7-alpine container_name: smart-qa-redis restart: unless-stopped ports: - "6379:6379" volumes: - redis_data:/data - ./docker/redis/redis.conf:/etc/redis/redis.conf command: redis-server /etc/redis/redis.conf networks: - smart-qa-network healthcheck: test: ["CMD", "redis-cli", "ping"] interval: 30s timeout: 10s retries: 3 # 应用服务 app: image: smart-qa-app:v202511191435 container_name: smart-qa-app restart: unless-stopped ports: - "8080:8080" environment: # 数据库配置 - SPRING_DATASOURCE_MYSQL_URL=jdbc:mysql://mysql:3306/smart_qa?useSSL=false&allowPublicKeyRetrieval=true&serverTimezone=Asia/Shanghai - SPRING_DATASOURCE_MYSQL_USERNAME=appuser - SPRING_DATASOURCE_MYSQL_PASSWORD=apppassword - SPRING_DATASOURCE_PGSQL_URL=jdbc:postgresql://postgres:5432/smart_qa_vector - SPRING_DATASOURCE_PGSQL_USERNAME=vectoruser - SPRING_DATASOURCE_PGSQL_PASSWORD=vectorpassword # Redis配置 - SPRING_DATA_REDIS_HOST=redis - SPRING_DATA_REDIS_PORT=6379 # 应用配置 - SERVER_PORT=8080 - LOGGING_LEVEL_COM_ZHPB=INFO - FILE_UPLOAD_MAX_SIZE=100MB - FILE_UPLOAD_MAX_REQUEST_SIZE=100MB # 外部配置文件路径 - SPRING_CONFIG_LOCATION=file:/app/config/application.yml volumes: # 挂载配置文件 - ./config/application.yml:/app/config/application.yml:ro # 挂载上传文件目录 - uploads_data:/app/uploads # 挂载解压文件目录 - extracts_data:/app/extracts # 挂载日志目录 - logs_data:/app/logs depends_on: mysql: condition: service_healthy postgres: condition: service_healthy redis: condition: service_healthy networks: - smart-qa-network volumes: mysql_data: driver: local postgres_data: driver: local redis_data: driver: local uploads_data: driver: local extracts_data: driver: local logs_data: driver: local networks: smart-qa-network: driver: bridge