services:
  db:
    image: mysql:8.4
    restart: unless-stopped
    environment:
      MYSQL_ROOT_PASSWORD: rootpass
      MYSQL_DATABASE: django_wow
      MYSQL_USER: novawow
      MYSQL_PASSWORD: novawow_pass
    volumes:
      - db_data:/var/lib/mysql
      - ./docker/mysql-init.sql:/docker-entrypoint-initdb.d/init.sql:ro
    healthcheck:
      test: ["CMD", "mysqladmin", "ping", "-h", "localhost", "-prootpass"]
      interval: 5s
      timeout: 5s
      retries: 20

  web:
    build: .
    restart: unless-stopped
    # Secretos de la app (Stripe, SumUp, SOAP, email, SECRET_KEY...) desde .env
    env_file:
      - path: .env
        required: false
    # Las variables de BD las fija compose para apuntar al servicio 'db'
    environment:
      DJANGO_DEBUG: "False"
      DB_HOST: db
      DB_PORT: "3306"
      DB_USER: novawow
      DB_PASSWORD: novawow_pass
      DB_NAME_DEFAULT: django_wow
      DB_NAME_AUTH: acore_auth
      DB_NAME_CHARACTERS: acore_characters
      DB_NAME_WORLD: acore_world
    ports:
      - "8000:8000"
    depends_on:
      db:
        condition: service_healthy

volumes:
  db_data:
