services:
  app:
    image: php:8.2-apache
    container_name: webgis_project_app
    ports:
      - "8080:80"
    environment:
      DB_HOST: db
      DB_USER: webgis
      DB_PASSWORD: webgis_password
      DB_NAME: webgis_project
    volumes:
      - ./:/var/www/html
    command: >
      bash -lc "docker-php-ext-install mysqli pdo pdo_mysql
      && a2enmod rewrite
      && mkdir -p /var/www/html/02/uploads /var/www/html/05/assets/uploads /var/www/html/05/uploads/bukti
      && chown -R www-data:www-data /var/www/html/02/uploads /var/www/html/05/assets/uploads /var/www/html/05/uploads
      && apache2-foreground"
    depends_on:
      db:
        condition: service_healthy

  db:
    image: mariadb:10.11
    container_name: webgis_project_db
    restart: unless-stopped
    environment:
      MARIADB_ROOT_PASSWORD: root_password
      MARIADB_DATABASE: webgis_project
      MARIADB_USER: webgis
      MARIADB_PASSWORD: webgis_password
    volumes:
      - webgis_project_db:/var/lib/mysql
    healthcheck:
      test: ["CMD", "healthcheck.sh", "--connect", "--innodb_initialized"]
      interval: 10s
      timeout: 5s
      retries: 5

volumes:
  webgis_project_db:
