version: "3.8"

services:
  web:
    image: nginx:alpine
    container_name: air-quality-web
    ports:
      - "8080:80"
    volumes:
      - ./site:/usr/share/nginx/html:ro
      - ./nginx/default.conf:/etc/nginx/conf.d/default.conf:ro
    depends_on:
      - api
    restart: unless-stopped

  api:
    build: ./api
    # ports:
    #   - "3000:3000"
    container_name: air-quality-api
    depends_on:
      - db   # 👈 IMPORTANT
    restart: unless-stopped

  db:
    image: mariadb:10.5
    container_name: air-quality-db
    restart: unless-stopped
    environment:
      MYSQL_ROOT_PASSWORD: leman123
      MYSQL_DATABASE: air_quality
      MYSQL_USER: leman
      MYSQL_PASSWORD: leman123
    volumes:
      - db_data:/var/lib/mysql

  phpmyadmin:
    image: phpmyadmin/phpmyadmin
    container_name: air-quality-pma
    restart: unless-stopped
    ports:
      - "8081:80"
    environment:
      PMA_HOST: db
      PMA_PORT: 3306
    depends_on:
      - db

volumes:
  db_data: