services:
  app:
    build:
      context: .
      dockerfile: Dockerfile
    restart: unless-stopped
    depends_on:
      mysql:
        condition: service_healthy
    env_file:
      - .env
    environment:
      APP_ENV: production
      APP_DEBUG: "false"
      APP_URL: http://localhost:8082
      DB_CONNECTION: mysql
      DB_HOST: mysql
      DB_PORT: "3306"
      DB_DATABASE: ${MYSQL_APP_DATABASE:-labkesda}
      DB_USERNAME: ${MYSQL_APP_USER:-labkesda}
      DB_PASSWORD: ${MYSQL_APP_PASSWORD:-labkesda_password}
      RUN_SEED_ON_START: ${RUN_SEED_ON_START:-true}
    ports:
      - "8082:80"
    volumes:
      - app_storage:/var/www/html/storage

  mysql:
    image: mysql:8.4
    restart: unless-stopped
    environment:
      MYSQL_DATABASE: ${MYSQL_APP_DATABASE:-labkesda}
      MYSQL_USER: ${MYSQL_APP_USER:-labkesda}
      MYSQL_PASSWORD: ${MYSQL_APP_PASSWORD:-labkesda_password}
      MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASSWORD:-root_password}
      TZ: Asia/Jakarta
    healthcheck:
      test: ["CMD-SHELL", "mysqladmin ping -h 127.0.0.1 -uroot -p$$MYSQL_ROOT_PASSWORD --silent"]
      interval: 10s
      timeout: 5s
      retries: 10
      start_period: 30s
    volumes:
      - mysql_data:/var/lib/mysql

volumes:
  app_storage:
  mysql_data:
