version: "3.8"

services:
  demo-app:
    image: demo-app:1.0
    container_name: demo-app
    restart: always
    build:
      context: .
      dockerfile: Dockerfile
    environment:
      - DB_HOST=mysql
      - DB_USERNAME=root
      - DB_PASSWORD=123456
      - REDIS_HOST=redis
      - AI_HOST=localhost
      - AI_PORT=5001
      - AI_KEY=app-0iWrwSYdTczCmRmtVNhfjWnq
      - SPRING_SERVLET_MULTIPART_MAX_FILE_SIZE=50MB
      - SPRING_SERVLET_MULTIPART_MAX_REQUEST_SIZE=50MB
    volumes:
      - ./uploads:/app/uploads
      - ./logs:/app/logs
      - ./img:/app/img
    ports:
      - "8080:8080"
    depends_on:
      - mysql
      - redis

  mysql:
    image: mysql:8.0
    container_name: mysql
    restart: always
    ports:
      - "3306:3306"
    environment:
      - MYSQL_ROOT_PASSWORD=123456
      - MYSQL_DATABASE=knowledge_management_system
      - MYSQL_CHARSET=utf8mb4
      - MYSQL_COLLATION=utf8mb4_unicode_ci
    volumes:
      - mysql-data:/var/lib/mysql
      - ./src/main/resources/sql/knowledge_management_system.sql:/docker-entrypoint-initdb.d/init.sql
      - ./mysql-conf:/etc/mysql/conf.d

  redis:
    image: redis:6.0
    container_name: redis
    restart: always
    ports:
      - "6379:6379"
    volumes:
      - redis-data:/data
    command: redis-server --appendonly yes

volumes:
  mysql-data:
  redis-data: