services:
  web:
    image: nginx:alpine
    container_name: projectKiln-nginx
    ports:
      - "5700:80"
    volumes:
      - ./:/var/www
      - ./default.conf:/etc/nginx/conf.d/default.conf
    depends_on:
      php:
        condition: service_healthy
    restart: unless-stopped

  php:
    build:
      context: .
      args:
        PUID: ${PUID:-1000}
        PGID: ${PGID:-1000}
    container_name: projectKiln-php
    volumes:
      - ./:/var/www
    healthcheck:
      test: ["CMD-SHELL", "php -r 'exit(@fsockopen(\"127.0.0.1\", 9000) ? 0 : 1);'"]
      interval: 5s
      timeout: 3s
      retries: 12
      start_period: 5s
    restart: unless-stopped

  mysql:
    image: mysql:8.4
    container_name: projectKiln-mysql
    environment:
      MYSQL_ROOT_PASSWORD: demo1234.
      MYSQL_DATABASE: project_kiln_db
      MYSQL_USER: user
      MYSQL_PASSWORD: demo1234
    command:
      [
        "--character-set-server=utf8mb4",
        "--collation-server=utf8mb4_0900_bin"
      ]
    volumes:
      - mysql_data:/var/lib/mysql
    restart: unless-stopped

  phpmyadmin:
    image: phpmyadmin:latest
    container_name: projectKiln-phpmyadmin
    ports:
      - "5710:80"
    environment:
      PMA_HOST: mysql
      PMA_PORT: 3306
    depends_on:
      - mysql
    restart: unless-stopped

  swagger:
    image: swaggerapi/swagger-ui
    container_name: projectKiln-swagger
    ports:
      - "5720:8080"
    environment:
      SWAGGER_JSON_URL: http://localhost:5700/api/openapi.php
    depends_on:
      - web
    restart: unless-stopped
volumes:
  mysql_data:
