version: '3.8' services: # MySQL数据库 mysql: image: mysql:8.0 container_name: emotion-mysql restart: unless-stopped environment: MYSQL_ROOT_PASSWORD: 123456 MYSQL_DATABASE: emotion_museum MYSQL_USER: emotion MYSQL_PASSWORD: emotion123 TZ: Asia/Shanghai ports: - "3306:3306" volumes: - mysql_data:/var/lib/mysql - ./backend/mysql_emotion_museum_final.sql:/docker-entrypoint-initdb.d/init.sql - ./deploy/mysql/conf.d:/etc/mysql/conf.d command: --default-authentication-plugin=mysql_native_password networks: - emotion-network # Redis缓存 redis: image: redis:7-alpine container_name: emotion-redis restart: unless-stopped ports: - "6379:6379" volumes: - redis_data:/data - ./deploy/redis/redis.conf:/usr/local/etc/redis/redis.conf command: redis-server /usr/local/etc/redis/redis.conf networks: - emotion-network # Nacos注册中心 nacos: image: nacos/nacos-server:v2.2.0 container_name: emotion-nacos restart: unless-stopped environment: MODE: standalone SPRING_DATASOURCE_PLATFORM: mysql MYSQL_SERVICE_HOST: mysql MYSQL_SERVICE_DB_NAME: nacos_config MYSQL_SERVICE_PORT: 3306 MYSQL_SERVICE_USER: root MYSQL_SERVICE_PASSWORD: 123456 MYSQL_SERVICE_DB_PARAM: characterEncoding=utf8&connectTimeout=1000&socketTimeout=3000&autoReconnect=true&useSSL=false&allowPublicKeyRetrieval=true JVM_XMS: 512m JVM_XMX: 512m JVM_XMN: 256m ports: - "8848:8848" - "9848:9848" volumes: - nacos_data:/home/nacos/data - nacos_logs:/home/nacos/logs depends_on: - mysql networks: - emotion-network # 网关服务 gateway: build: context: ./backend dockerfile: ./emotion-gateway/Dockerfile container_name: emotion-gateway restart: unless-stopped ports: - "9000:9000" environment: SPRING_PROFILES_ACTIVE: docker NACOS_SERVER_ADDR: nacos:8848 MYSQL_HOST: mysql MYSQL_PORT: 3306 REDIS_HOST: redis REDIS_PORT: 6379 depends_on: - mysql - redis - nacos networks: - emotion-network # AI服务 ai-service: build: context: ./backend dockerfile: ./emotion-ai/Dockerfile container_name: emotion-ai restart: unless-stopped ports: - "9002:9002" environment: SPRING_PROFILES_ACTIVE: docker NACOS_SERVER_ADDR: nacos:8848 MYSQL_HOST: mysql MYSQL_PORT: 3306 REDIS_HOST: redis REDIS_PORT: 6379 depends_on: - mysql - redis - nacos networks: - emotion-network # 用户服务 user-service: build: context: ./backend dockerfile: ./emotion-user/Dockerfile container_name: emotion-user restart: unless-stopped ports: - "9001:9001" environment: SPRING_PROFILES_ACTIVE: docker NACOS_SERVER_ADDR: nacos:8848 MYSQL_HOST: mysql MYSQL_PORT: 3306 REDIS_HOST: redis REDIS_PORT: 6379 depends_on: - mysql - redis - nacos networks: - emotion-network # 前端应用 web: build: context: ./web dockerfile: Dockerfile container_name: emotion-web restart: unless-stopped ports: - "3000:80" depends_on: - gateway networks: - emotion-network # Nginx反向代理 nginx: image: nginx:alpine container_name: emotion-nginx restart: unless-stopped ports: - "80:80" - "443:443" volumes: - ./deploy/nginx/nginx.conf:/etc/nginx/nginx.conf - ./deploy/nginx/conf.d:/etc/nginx/conf.d - ./deploy/nginx/ssl:/etc/nginx/ssl - nginx_logs:/var/log/nginx depends_on: - web - gateway networks: - emotion-network volumes: mysql_data: redis_data: nacos_data: nacos_logs: nginx_logs: networks: emotion-network: driver: bridge