services:
  gpt-load:
    image: ghcr.io/tbphp/gpt-load:latest
    # build:
    #   context: .
    #   dockerfile: Dockerfile
    container_name: gpt-load
    ports:
      - "${PORT:-3001}:${PORT:-3001}"
    env_file:
      - .env
    restart: always
    stop_grace_period: ${SERVER_GRACEFUL_SHUTDOWN_TIMEOUT:-10}s
    depends_on:
      mysql:
        condition: service_healthy
        restart: true
      redis:
        condition: service_healthy
        restart: true
    healthcheck:
      test: wget -q --spider -T 10 -O /dev/null http://localhost:${PORT:-3001}/health
      interval: 30s
      timeout: 10s
      retries: 3
      start_period: 40s

  mysql:
    image: mysql:8.2
    container_name: gpt-load-mysql
    restart: always
    # ports:
    #   - "3306:3306"
    environment:
      MYSQL_ROOT_PASSWORD: 123456
      MYSQL_DATABASE: gpt_load
    volumes:
      - mysql_data:/var/lib/mysql
    healthcheck:
      test: ["CMD", "mysqladmin", "ping", "-h", "localhost"]
      interval: 5s
      timeout: 5s
      retries: 10

  redis:
    image: redis:latest
    container_name: gpt-load-redis
    restart: always
    # ports:
    #   - "6379:6379"
    healthcheck:
      test: ["CMD", "redis-cli", "ping"]
      interval: 5s
      timeout: 3s
      retries: 3

volumes:
  mysql_data:
