services:
  php:
    build:
      context: .
      dockerfile: docker/php/Dockerfile
    container_name: fifa-championship-php
    working_dir: /var/www/html
    command: php artisan serve --host=0.0.0.0 --port=8000
    volumes:
      - ./:/var/www/html
    ports:
      - "8000:8000"
    depends_on:
      - mysql
    tty: true

  mysql:
    image: mysql:8.4
    container_name: fifa-championship-mysql
    restart: unless-stopped
    environment:
      MYSQL_DATABASE: ${DB_DATABASE:-fifa_championship}
      MYSQL_USER: ${DB_USERNAME:-fifa_user}
      MYSQL_PASSWORD: ${DB_PASSWORD:-secret}
      MYSQL_ROOT_PASSWORD: ${DB_ROOT_PASSWORD:-root}
    ports:
      - "3306:3306"
    volumes:
      - mysql_data:/var/lib/mysql
    healthcheck:
      test: ["CMD", "mysqladmin", "ping", "-h", "127.0.0.1", "-p${DB_ROOT_PASSWORD:-root}"]
      interval: 10s
      timeout: 5s
      retries: 5

volumes:
  mysql_data:
