version: "3.8"

services:
  laravel.test:
    build:
      context: ./vendor/laravel/sail/runtimes/8.2
      dockerfile: Dockerfile
      args:
        WWWGROUP: "${WWWGROUP}"
    image: sail-8.2/app
    extra_hosts:
      - "host.docker.internal:host-gateway"
    ports:
      - "${APP_PORT:-80}:80"
      - "${VITE_PORT:-5173}:${VITE_PORT:-5173}"
    environment:
      WWWUSER: "${WWWUSER}"
      LARAVEL_SAIL: 1
      XDEBUG_MODE: "${SAIL_XDEBUG_MODE:-off}"
      XDEBUG_CONFIG: "${SAIL_XDEBUG_CONFIG:-client_host=host.docker.internal}"
      IGNITION_LOCAL_SITES_PATH: "${PWD}"
      APP_NAME: "${APP_NAME}"
      APP_ENV: "${APP_ENV}"
      APP_KEY: "${APP_KEY}"
      APP_DEBUG: "${APP_DEBUG}"
      APP_URL: "${APP_URL}"
      LOG_CHANNEL: "${LOG_CHANNEL}"
      LOG_DEPRECATIONS_CHANNEL: "${LOG_DEPRECATIONS_CHANNEL}"
      LOG_LEVEL: "${LOG_LEVEL}"
      VITE_API_BASE_URL: "${VITE_API_BASE_URL}"
      VITE_KM_HOME_URL: "${VITE_KM_HOME_URL}"
      VITE_LOGIN_URL: "${VITE_LOGIN_URL}"
      VITE_BASE_URL: "${VITE_BASE_URL}"
      VITE_PATH_DATABASE: "${VITE_PATH_DATABASE}"
      VITE_PATH_DESIGNGUIDE: "${VITE_PATH_DESIGNGUIDE}"
      VITE_PATH_DRILLING: "${VITE_PATH_DRILLING}"
      VITE_PATH_GIS: "${VITE_PATH_GIS}"
      VITE_PATH_ELEARNING: "${VITE_PATH_ELEARNING}"
      VITE_PATH_TOOLS: "${VITE_PATH_TOOLS}"
      VITE_PATH_PROJECTFEEDBACK: "${VITE_PATH_PROJECTFEEDBACK}"
      VITE_PATH_DEFAULT: "${VITE_PATH_DEFAULT}"
      VITE_PATH_PERMISSION: "${VITE_PATH_PERMISSION}"
      DB_CONNECTION: "${DB_CONNECTION}"
      DB_HOST: "${DB_HOST}"
      DB_PORT: "${DB_PORT}"
      DB_DATABASE: "${DB_DATABASE}"
      DB_USERNAME: "${DB_USERNAME}"
      DB_PASSWORD: "${DB_PASSWORD}"
      DB_KMDB_CONNECTION: "${DB_KMDB_CONNECTION}"
      DB_KMDB_HOST: "${DB_KMDB_HOST}"
      DB_KMDB_DATABASE: "${DB_KMDB_DATABASE}"
      DB_KMDB_USERNAME: "${DB_KMDB_USERNAME}"
      DB_KMDB_PASSWORD: "${DB_KMDB_PASSWORD}"
      MONGO_DB_HOST: "${MONGO_DB_HOST}"
      MONGO_DB_PORT: "${MONGO_DB_PORT}"
      MONGO_DB_DATABASE: "${MONGO_DB_DATABASE}"
      BROADCAST_DRIVER: "${BROADCAST_DRIVER}"
      CACHE_DRIVER: "${CACHE_DRIVER}"
      FILESYSTEM_DISK: "${FILESYSTEM_DISK}"
      QUEUE_CONNECTION: "${QUEUE_CONNECTION}"
      SESSION_DRIVER: "${SESSION_DRIVER}"
      SESSION_LIFETIME: "${SESSION_LIFETIME}"
      MEMCACHED_HOST: "${MEMCACHED_HOST}"
      REDIS_HOST: "${REDIS_HOST}"
      REDIS_PASSWORD: "${REDIS_PASSWORD}"
      REDIS_PORT: "${REDIS_PORT}"
      MAIL_MAILER: "${MAIL_MAILER}"
      MAIL_HOST: "${MAIL_HOST}"
      MAIL_PORT: "${MAIL_PORT}"
      MAIL_USERNAME: "${MAIL_USERNAME}"
      MAIL_PASSWORD: "${MAIL_PASSWORD}"
      MAIL_ENCRYPTION: "${MAIL_ENCRYPTION}"
      MAIL_FROM_ADDRESS: "${MAIL_FROM_ADDRESS}"
      MAIL_FROM_NAME: "${MAIL_FROM_NAME}"
      MAILGUN_DOMAIN: "${MAILGUN_DOMAIN}"
      MAILGUN_SECRET: "${MAILGUN_SECRET}"
      MAIL_EHLO_DOMAIN: "${MAIL_EHLO_DOMAIN}"
      AWS_ACCESS_KEY_ID: "${AWS_ACCESS_KEY_ID}"
      AWS_SECRET_ACCESS_KEY: "${AWS_SECRET_ACCESS_KEY}"
      AWS_DEFAULT_REGION: "${AWS_DEFAULT_REGION}"
      AWS_BUCKET: "${AWS_BUCKET}"
      AWS_USE_PATH_STYLE_ENDPOINT: "${AWS_USE_PATH_STYLE_ENDPOINT}"
      PUSHER_APP_ID: "${PUSHER_APP_ID}"
      PUSHER_APP_KEY: "${PUSHER_APP_KEY}"
      PUSHER_APP_SECRET: "${PUSHER_APP_SECRET}"
      PUSHER_APP_CLUSTER: "${PUSHER_APP_CLUSTER}"
      VITE_PUSHER_APP_KEY: "${VITE_PUSHER_APP_KEY}"
      VITE_PUSHER_HOST: "${VITE_PUSHER_HOST}"
      VITE_PUSHER_PORT: "${VITE_PUSHER_PORT}"
      VITE_PUSHER_SCHEME: "${VITE_PUSHER_SCHEME}"
      VITE_PUSHER_APP_CLUSTER: "${VITE_PUSHER_APP_CLUSTER}"
      DEVTOOLS_EDITOR: "${DEVTOOLS_EDITOR}"
      JWT_SECRET: "${JWT_SECRET}"
      JWT_ALGO: "${JWT_ALGO}"
    volumes:
      - ".:/var/www/html"
    networks:
      - sail
    depends_on:
      - mysql
      - redis
      - selenium
      - mailpit

  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_USER: "${DB_USERNAME}"
      MYSQL_PASSWORD: "${DB_PASSWORD}"
      MYSQL_ALLOW_EMPTY_PASSWORD: 1
    volumes:
      - "sail-mysql:/var/lib/mysql"
      - "./vendor/laravel/sail/database/mysql/create-testing-database.sh:/docker-entrypoint-initdb.d/10-create-testing-database.sh"
    networks:
      - sail
    healthcheck:
      test:
        - CMD
        - mysqladmin
        - ping
        - "-p${DB_PASSWORD}"
      retries: 3
      timeout: 5s

  redis:
    image: "redis:alpine"
    ports:
      - "${FORWARD_REDIS_PORT:-6379}:6379"
    volumes:
      - "sail-redis:/data"
    networks:
      - sail
    healthcheck:
      test:
        - CMD
        - redis-cli
        - ping
      retries: 3
      timeout: 5s

  selenium:
    image: seleniarm/standalone-chromium
    extra_hosts:
      - "host.docker.internal:host-gateway"
    volumes:
      - "/dev/shm:/dev/shm"
    networks:
      - sail

  mailpit:
    image: "axllent/mailpit:latest"
    ports:
      - "${FORWARD_MAILPIT_PORT:-1025}:1025"
      - "${FORWARD_MAILPIT_DASHBOARD_PORT:-8025}:8025"
    networks:
      - sail

networks:
  sail:
    driver: bridge

volumes:
  sail-mysql:
    driver: local
  sail-redis:
    driver: local
