version: '3.8'

services:
  server:
    build: .
    container_name: media-manager-server
    restart: unless-stopped
    ports:
      - "3000:3000"
    environment:
      - NODE_ENV=production
      - TZ=Asia/Shanghai
      - PORT=3000
      - DB_HOST=mysql
      - DB_PORT=3306
      - DB_USERNAME=media_manager
      - DB_PASSWORD=${DB_PASSWORD:-changeme}
      - DB_DATABASE=media_manager
      - REDIS_HOST=redis
      - REDIS_PORT=6379
      - JWT_SECRET=${JWT_SECRET:-your-super-secret-key-change-in-production}
      - ENCRYPTION_KEY=${ENCRYPTION_KEY:-your-encryption-key-32-chars-long!}
    volumes:
      - ./uploads:/app/uploads
      - ./logs:/app/logs
    depends_on:
      - mysql
      - redis
    networks:
      - media-manager-network

  mysql:
    image: mysql:8.0
    container_name: media-manager-mysql
    restart: unless-stopped
    command: --default-time-zone=+08:00
    environment:
      - TZ=Asia/Shanghai
      - MYSQL_ROOT_PASSWORD=${MYSQL_ROOT_PASSWORD:-rootpassword}
      - MYSQL_DATABASE=media_manager
      - MYSQL_USER=media_manager
      - MYSQL_PASSWORD=${DB_PASSWORD:-changeme}
    volumes:
      - mysql-data:/var/lib/mysql
      - ../database/schema.sql:/docker-entrypoint-initdb.d/schema.sql
    ports:
      - "3306:3306"
    networks:
      - media-manager-network

  redis:
    image: redis:7-alpine
    container_name: media-manager-redis
    restart: unless-stopped
    command: redis-server --appendonly yes
    volumes:
      - redis-data:/data
    ports:
      - "6379:6379"
    networks:
      - media-manager-network

volumes:
  mysql-data:
  redis-data:

networks:
  media-manager-network:
    driver: bridge
