services:
  app:
    build: .
    image: clinic-system:latest
    restart: unless-stopped
    ports:
      - "8080:80"
    environment:
      APP_ENV: local
      APP_DEBUG: "true"
      DB_CONNECTION: landlord
      LANDLORD_DB_HOST: mysql
      LANDLORD_DB_DATABASE: clinic_landlord
      LANDLORD_DB_USERNAME: root
      LANDLORD_DB_PASSWORD: secret
      TENANT_DB_HOST: mysql
      TENANT_DB_USERNAME: root
      TENANT_DB_PASSWORD: secret
      REDIS_HOST: redis
      CACHE_STORE: redis
      SESSION_DRIVER: redis
      QUEUE_CONNECTION: redis
      MAIL_MAILER: smtp
      MAIL_HOST: mailpit
      MAIL_PORT: 1025
      CENTRAL_DOMAIN: clinic.test
    depends_on:
      mysql:
        condition: service_healthy
      redis:
        condition: service_started
    volumes:
      - ./storage:/var/www/html/storage

  mysql:
    image: mysql:8.0
    restart: unless-stopped
    environment:
      MYSQL_ROOT_PASSWORD: secret
      MYSQL_DATABASE: clinic_landlord
    ports:
      - "3306:3306"
    volumes:
      - mysql-data:/var/lib/mysql
    healthcheck:
      test: ["CMD", "mysqladmin", "ping", "-h", "localhost", "-uroot", "-psecret"]
      interval: 5s
      timeout: 3s
      retries: 20

  redis:
    image: redis:7-alpine
    restart: unless-stopped
    ports:
      - "6379:6379"

  mailpit:
    image: axllent/mailpit
    restart: unless-stopped
    ports:
      - "8025:8025"
      - "1025:1025"

volumes:
  mysql-data:
