services:
  app:
    build:
      context: ../../..
      dockerfile: Dockerfile
    container_name: match_12
    restart: unless-stopped
    ports:
      - "${APP_PORT:-8080}:80"
      - "${APP_SSL_PORT:-8443}:443"
      - "${REVERB_PORT:-8085}:8080"
    volumes:
      - ../../..:/var/www/html
      - storage_data:/var/www/html/storage
    depends_on:
      mysql:
        condition: service_healthy
    environment:
      - APP_ENV=production
      - APP_DEBUG=false
    healthcheck:
      test: ["CMD", "curl", "-f", "http://localhost/"]
      interval: 30s
      timeout: 10s
      retries: 3
      start_period: 30s

  mysql:
    image: mysql:8.0
    container_name: match_12_mysql
    restart: unless-stopped
    environment:
      MYSQL_DATABASE: "${DB_DATABASE:-match_12}"
      MYSQL_USER: "${DB_USERNAME:-match_12}"
      MYSQL_PASSWORD: "${DB_PASSWORD:-secret}"
      MYSQL_ROOT_PASSWORD: "${DB_ROOT_PASSWORD:-rootsecret}"
    volumes:
      - mysql_data:/var/lib/mysql
    ports:
      - "${DB_PORT:-3306}:3306"
    healthcheck:
      test: ["CMD", "mysqladmin", "ping", "-h", "localhost"]
      interval: 10s
      timeout: 5s
      retries: 5
      start_period: 30s

volumes:
  mysql_data:
    driver: local
  storage_data:
    driver: local
