services:
  laravel.test:
    build:
      context: ./vendor/laravel/sail/runtimes/8.2
      dockerfile: Dockerfile
      args:
        WWWGROUP: '${WWWGROUP}'
    image: sail-8.2/app
    restart: unless-stopped
    extra_hosts:
      - 'host.docker.internal:host-gateway'
    ports:
      - '3000:80'
    environment:
      WWWUSER: '${WWWUSER}'
      LARAVEL_SAIL: 1
      APP_ENV: '${APP_ENV:-local}'
      APP_DEBUG: '${APP_DEBUG:-true}'
    volumes:
      - '.:/var/www/html'
    networks:
      - sail
    depends_on:
      mysql:
        condition: service_healthy
    healthcheck:
      test: ["CMD", "curl", "-f", "http://localhost:80"]
      interval: 10s
      timeout: 5s
      retries: 3

  mysql:
      image: 'mysql/mysql-server:8.0'
      ports:
          - '${FORWARD_DB_PORT:-3306}:3306'
      environment:
          MYSQL_ROOT_PASSWORD: '${DB_PASSWORD}'
          MYSQL_ROOT_HOST: "%"
          MYSQL_DATABASE: '${DB_DATABASE}'
          MYSQL_ALLOW_EMPTY_PASSWORD: 'yes'
      volumes:
          - 'sail-mysql:/var/lib/mysql'
      networks:
          - sail
      command: --max_allowed_packet=512M --default-authentication-plugin=mysql_native_password
      healthcheck:
          test: ["CMD", "mysqladmin", "ping", "-p${DB_PASSWORD}"]
          retries: 3
          timeout: 5s

  phpmyadmin:
      image: phpmyadmin:latest
      ports:
          - '${FORWARD_PHPMYADMIN_PORT:-8888}:80'
      environment:
          PMA_HOST: mysql
          PMA_USER: root
          PMA_PASSWORD: '${DB_PASSWORD}'
          UPLOAD_LIMIT: 300M
      networks:
          - sail
      depends_on:
          - mysql

networks:
  sail:
    driver: bridge

volumes:
  sail-mysql:
    driver: local