services:

  # printService:
  #   image: harbor.inner.xcastle.net/screen/print-service:{{$printServiceVersion}}
  #   container_name: printService
  #   restart: unless-stopped
  #   stop_grace_period: 1s
  #   network_mode: host
  #   pid: host
  #   volumes:
  #     - '/dev:/dev:ro,rslave'
  #     - '/run:/run:ro,rslave'
  #     - '/data:/data'
  
  algorithmService:
    image: harbor.inner.xcastle.net/screen/algorithm-python:cpu-{{$algorithmServiceVersion}}
    container_name: algorithmService
    restart: unless-stopped
    stop_grace_period: 1s
    network_mode: host
    pid: host
    privileged: true
    volumes:
      - '/run/udev:/run/udev:ro'
      - '/data:/data'
      - '/data/algorithmService/weights:/app/algorithm/weights'
      - '/data/algorithmService/libs:/app/algorithm/libs'
 
  nodeExporter:
    image: harbor.inner.xcastle.net/base/node-exporter:v1.9.0
    container_name: nodeExporter
    restart: unless-stopped
    stop_grace_period: 1s
    command:
      - '--path.rootfs=/host'
    network_mode: host
    pid: host
    volumes:
      - '/:/host:ro,rslave'
    logging:
      driver: "none"

  nodeExporterPush:
    image: harbor.inner.xcastle.net/base/alpine:3.21-curl
    container_name: nodeExporterPush
    restart: unless-stopped
    stop_grace_period: 1s
    network_mode: host
    pid: host
    environment:
      screenNum: "{{$screenNum}}"
      interval: 15
      enpointUrl: "https://pushgateway.inner.xcastle.net/metrics/job/screen/instance/"
      metricUrl: "http://localhost:9100/metrics"
    command: >
      sh -c "while true; do
        echo -n $(date '+%Y-%m-%d %H:%M:%S')
        curl -s -w ' status:%{http_code}, time:%{time_total}s' -H 'Authorization: Basic dHhyeTp0eHJ5MjAyNQ==' -X POST --data-binary @<(curl -s $${metricUrl}) $${enpointUrl}screen-$${screenNum}
        echo ''
        sleep $${interval}
      done"
