networks:
  app-shared-net:
    external: true
    name: app-shared-net
  telemetry-net:
    external: true
    name: telemetry-net

services:
  web:
    image: ghcr.io/${GITHUB_REPOSITORY:-mytheclipse/zeavis-edu}/web:main
    container_name: zeavis-web
    restart: always
    networks:
      - app-shared-net
      - telemetry-net
    env_file:
      - .env
    labels:
      traefik.enable: "true"
      traefik.http.routers.zeavis-web.rule: Host(`zeavisedu.asepharyana.my.id`)
      traefik.http.routers.zeavis-web.entrypoints: websecure
      traefik.http.routers.zeavis-web.tls: "true"
      traefik.http.routers.zeavis-web.tls.certresolver: cloudflare
      traefik.http.services.zeavis-web.loadbalancer.server.port: "80"

  api:
    image: ghcr.io/${GITHUB_REPOSITORY:-mytheclipse/zeavis-edu}/api:main
    container_name: zeavis-api
    restart: always
    networks:
      - app-shared-net
      - telemetry-net
    env_file:
      - .env
    environment:
      NODE_ENV: production
      API_PORT: "3000"
      WEB_APP_URL: https://zeavisedu.asepharyana.my.id
      ML_SERVICE_URL: ${ML_SERVICE_URL:-http://zeavis-ml:8000}
    ports:
      - "3000:3000"
    labels:
      traefik.enable: "true"
      traefik.http.routers.zeavis-api.rule: Host(`api-zeavisedu.asepharyana.my.id`)
      traefik.http.routers.zeavis-api.entrypoints: websecure
      traefik.http.routers.zeavis-api.tls: "true"
      traefik.http.routers.zeavis-api.tls.certresolver: cloudflare
      traefik.http.services.zeavis-api.loadbalancer.server.port: "3000"

  # Node Exporter — expose system metrics (CPU, RAM, disk) for Prometheus scraping
  node_exporter:
    image: prom/node-exporter:v1.8.2
    container_name: zeavis-node-exporter
    restart: unless-stopped
    ports:
      - "9100:9100"
    command:
      - "--path.rootfs=/host"
      - "--web.listen-address=:9100"
    volumes:
      - /:/host:ro,rslave
    pid: host
    networks:
      - app-shared-net
      - telemetry-net

  ml:
    image: ghcr.io/${GITHUB_REPOSITORY:-mytheclipse/zeavis-edu}/ml:main
    container_name: zeavis-ml
    restart: always
    networks:
      - app-shared-net
      - telemetry-net
    env_file:
      - .env
    environment:
      MODEL_PATH: /app/model/model.onnx
      MODEL_INPUT_SIZE: "224"
    ports:
      - "8000:8000"
    labels:
      traefik.enable: "true"
      traefik.http.routers.zeavis-ml.rule: Host(`ml-zeavisedu.asepharyana.my.id`)
      traefik.http.routers.zeavis-ml.entrypoints: websecure
      traefik.http.routers.zeavis-ml.tls: "true"
      traefik.http.routers.zeavis-ml.tls.certresolver: cloudflare
      traefik.http.services.zeavis-ml.loadbalancer.server.port: "8000"
