networks:
  sysnet:
    driver: bridge
    ipam:
      driver: default
      config:
        - subnet: 172.29.0.0/16

services:
  bind:
    image: ${BIND_IMAGE_TAG:-argus-bind9:latest}
    container_name: argus-bind-sys
    networks:
      sysnet:
        ipv4_address: 172.29.0.2
    volumes:
      - ./private:/private
    restart: unless-stopped

  master:
    image: ${MASTER_IMAGE_TAG:-argus-master:latest}
    container_name: argus-master-sys
    depends_on:
      - bind
    environment:
      - OFFLINE_THRESHOLD_SECONDS=6
      - ONLINE_THRESHOLD_SECONDS=2
      - SCHEDULER_INTERVAL_SECONDS=1
      - ARGUS_BUILD_UID=${ARGUS_BUILD_UID:-2133}
      - ARGUS_BUILD_GID=${ARGUS_BUILD_GID:-2015}
    ports:
      - "32300:3000"
    volumes:
      - ./private/argus/master:/private/argus/master
      - ./private/argus/metric/prometheus:/private/argus/metric/prometheus
      - ./private/argus/etc:/private/argus/etc
    networks:
      sysnet:
        ipv4_address: 172.29.0.10
    restart: unless-stopped

  es:
    image: argus-elasticsearch:latest
    container_name: argus-es-sys
    environment:
      - discovery.type=single-node
      - xpack.security.enabled=false
      - ES_JAVA_OPTS=-Xms512m -Xmx512m
      - ARGUS_BUILD_UID=${ARGUS_BUILD_UID:-2133}
      - ARGUS_BUILD_GID=${ARGUS_BUILD_GID:-2015}
    volumes:
      - ./private/argus/log/elasticsearch:/private/argus/log/elasticsearch
      - ./private/argus/etc:/private/argus/etc
    ports:
      - "9200:9200"
    restart: unless-stopped
    networks:
      sysnet:
        ipv4_address: 172.29.0.3

  kibana:
    image: argus-kibana:latest
    container_name: argus-kibana-sys
    environment:
      - ELASTICSEARCH_HOSTS=http://es.log.argus.com:9200
      - ARGUS_BUILD_UID=${ARGUS_BUILD_UID:-2133}
      - ARGUS_BUILD_GID=${ARGUS_BUILD_GID:-2015}
    volumes:
      - ./private/argus/log/kibana:/private/argus/log/kibana
      - ./private/argus/etc:/private/argus/etc
    depends_on:
      - es
    ports:
      - "5601:5601"
    restart: unless-stopped
    networks:
      sysnet:
        ipv4_address: 172.29.0.4

  node-a:
    image: ubuntu:22.04
    container_name: argus-node-a
    hostname: dev-yyrshare-nbnyx10-cp2f-pod-0
    depends_on:
      - master
      - bind
      - es
    environment:
      - MASTER_ENDPOINT=http://master.argus.com:3000
      - REPORT_INTERVAL_SECONDS=2
      - ARGUS_BUILD_UID=${ARGUS_BUILD_UID:-2133}
      - ARGUS_BUILD_GID=${ARGUS_BUILD_GID:-2015}
      - ES_HOST=es
      - ES_PORT=9200
      - CLUSTER=local
      - RACK=dev
    volumes:
      - ./private-nodea/argus/agent/dev-yyrshare-nbnyx10-cp2f-pod-0:/private/argus/agent/dev-yyrshare-nbnyx10-cp2f-pod-0
      - ../../agent/dist/argus-agent:/usr/local/bin/argus-agent:ro
      - ./scripts/node_entrypoint.sh:/usr/local/bin/node-entrypoint.sh:ro
      - ../../log/fluent-bit/build/start-fluent-bit.sh:/assets/start-fluent-bit.sh:ro
      - ../../log/fluent-bit/build/etc:/assets/fluent-bit/etc:ro
      - ../../log/fluent-bit/build/packages:/assets/fluent-bit/packages:ro
    entrypoint:
      - /usr/local/bin/node-entrypoint.sh
    dns:
      - 172.29.0.2
    ports:
      - "2020:2020"
    restart: unless-stopped
    networks:
      - sysnet

  node-b:
    image: ubuntu:22.04
    container_name: argus-node-b
    hostname: dev-yyrshare-uuuu10-ep2f-pod-0
    depends_on:
      - master
      - bind
      - es
    environment:
      - MASTER_ENDPOINT=http://master.argus.com:3000
      - REPORT_INTERVAL_SECONDS=2
      - ARGUS_BUILD_UID=${ARGUS_BUILD_UID:-2133}
      - ARGUS_BUILD_GID=${ARGUS_BUILD_GID:-2015}
      - ES_HOST=es
      - ES_PORT=9200
      - CLUSTER=local
      - RACK=dev
    volumes:
      - ./private-nodeb/argus/agent/dev-yyrshare-uuuu10-ep2f-pod-0:/private/argus/agent/dev-yyrshare-uuuu10-ep2f-pod-0
      - ../../agent/dist/argus-agent:/usr/local/bin/argus-agent:ro
      - ./scripts/node_entrypoint.sh:/usr/local/bin/node-entrypoint.sh:ro
      - ../../log/fluent-bit/build/start-fluent-bit.sh:/assets/start-fluent-bit.sh:ro
      - ../../log/fluent-bit/build/etc:/assets/fluent-bit/etc:ro
      - ../../log/fluent-bit/build/packages:/assets/fluent-bit/packages:ro
    entrypoint:
      - /usr/local/bin/node-entrypoint.sh
    dns:
      - 172.29.0.2
    ports:
      - "2021:2020"
    restart: unless-stopped
    networks:
      - sysnet

  ftp:
    image: argus-metric-ftp:latest
    container_name: argus-ftp
    restart: unless-stopped
    environment:
      - TZ=Asia/Shanghai
      - FTP_BASE_PATH=/private/argus/ftp
      - FTP_PASSWORD=${FTP_PASSWORD:-ZGClab1234!}
      - DOMAIN=${FTP_DOMAIN:-ftp.metric.argus.com}
      - ARGUS_BUILD_UID=${ARGUS_BUILD_UID:-2133}
      - ARGUS_BUILD_GID=${ARGUS_BUILD_GID:-2015}
    ports:
      - "${FTP_PORT:-21}:21"
      - "${FTP_DATA_PORT:-20}:20"
      - "21100-21110:21100-21110"
    volumes:
      - ./private/argus/metric/ftp:/private/argus/ftp
      - ./private/argus/etc:/private/argus/etc
      - /etc/localtime:/etc/localtime:ro
      - /etc/timezone:/etc/timezone:ro
    networks:
      sysnet:
        ipv4_address: 172.29.0.40
    logging:
      driver: "json-file"
      options:
        max-size: "10m"
        max-file: "3"

  prometheus:
    image: argus-metric-prometheus:latest
    container_name: argus-prometheus
    restart: unless-stopped
    environment:
      - TZ=Asia/Shanghai
      - PROMETHEUS_BASE_PATH=/private/argus/metric/prometheus
      - ARGUS_BUILD_UID=${ARGUS_BUILD_UID:-2133}
      - ARGUS_BUILD_GID=${ARGUS_BUILD_GID:-2015}
    ports:
      - "${PROMETHEUS_PORT:-9090}:9090"
    volumes:
      - ./private/argus/metric/prometheus:/private/argus/metric/prometheus
      - ./private/argus/etc:/private/argus/etc
      - /etc/localtime:/etc/localtime:ro
      - /etc/timezone:/etc/timezone:ro
    networks:
      sysnet:
        ipv4_address: 172.29.0.41
    logging:
      driver: "json-file"
      options:
        max-size: "10m"
        max-file: "3"

  grafana:
    image: argus-metric-grafana:latest
    container_name: argus-grafana
    restart: unless-stopped
    environment:
      - TZ=Asia/Shanghai
      - GRAFANA_BASE_PATH=/private/argus/metric/grafana
      - ARGUS_BUILD_UID=${ARGUS_BUILD_UID:-2133}
      - ARGUS_BUILD_GID=${ARGUS_BUILD_GID:-2015}
      - GF_SERVER_HTTP_PORT=3000
      - GF_LOG_LEVEL=warn
      - GF_LOG_MODE=console
      - GF_PATHS_PROVISIONING=/private/argus/metric/grafana/provisioning
      - GF_AUTH_ANONYMOUS_ENABLED=true
      - GF_AUTH_ANONYMOUS_ORG_ROLE=Viewer
    ports:
      - "${GRAFANA_PORT:-3000}:3000"
    volumes:
      - ./private/argus/metric/grafana:/private/argus/metric/grafana
      - ./private/argus/etc:/private/argus/etc
      - /etc/localtime:/etc/localtime:ro
      - /etc/timezone:/etc/timezone:ro
    networks:
      sysnet:
        ipv4_address: 172.29.0.42
    depends_on:
      - prometheus
    logging:
      driver: "json-file"
      options:
        max-size: "10m"
        max-file: "3"

  test-node:
    image: ubuntu:22.04
    container_name: argus-metric-test-node
    hostname: test-metric-node-001
    restart: unless-stopped
    privileged: true
    depends_on:
      - ftp
      - prometheus
    environment:
      - TZ=Asia/Shanghai
      - DEBIAN_FRONTEND=noninteractive
      - FTP_DOMAIN=${FTP_DOMAIN:-ftp.metric.argus.com}
      - FTP_SERVER=${FTP_SERVER:-172.29.0.40}
      - FTP_USER=${FTP_USER:-ftpuser}
      - FTP_PASSWORD=${FTP_PASSWORD:-ZGClab1234!}
      - FTP_PORT=${FTP_PORT:-21}
      - ARGUS_BUILD_UID=${ARGUS_BUILD_UID:-2133}
      - ARGUS_BUILD_GID=${ARGUS_BUILD_GID:-2015}
      - METRIC_NODE_ROLE=cpu
    volumes:
      - ./private/argus/agent:/private/argus/agent
      - ./scripts/metric/test-node-entrypoint.sh:/usr/local/bin/metric-test-node-entrypoint.sh:ro
      - /etc/localtime:/etc/localtime:ro
      - /etc/timezone:/etc/timezone:ro
    entrypoint:
      - /usr/local/bin/metric-test-node-entrypoint.sh
    command:
      - sleep
      - infinity
    networks:
      sysnet:
        ipv4_address: 172.29.0.50
    logging:
      driver: "json-file"
      options:
        max-size: "10m"
        max-file: "3"

  test-gpu-node:
    profiles: ["gpu"]
    image: nvidia/cuda:12.2.2-runtime-ubuntu22.04
    container_name: argus-metric-test-gpu-node
    hostname: test-metric-gpu-node-001
    restart: unless-stopped
    privileged: true
    runtime: nvidia
    deploy:
      resources:
        reservations:
          devices:
            - driver: nvidia
              count: all
              capabilities: 
                - gpu
    depends_on:
      - ftp
      - prometheus
    environment:
      - TZ=Asia/Shanghai
      - DEBIAN_FRONTEND=noninteractive
      - NVIDIA_VISIBLE_DEVICES=all
      - NVIDIA_DRIVER_CAPABILITIES=compute,utility
      - GPU_MODE=gpu
      - ARGUS_BUILD_UID=${ARGUS_BUILD_UID:-2133}
      - ARGUS_BUILD_GID=${ARGUS_BUILD_GID:-2015}
      - METRIC_NODE_ROLE=gpu
    volumes:
      - ./private/argus/agent:/private/argus/agent
      - ./scripts/metric/test-node-entrypoint.sh:/usr/local/bin/metric-test-node-entrypoint.sh:ro
      - /etc/localtime:/etc/localtime:ro
      - /etc/timezone:/etc/timezone:ro
    entrypoint:
      - /usr/local/bin/metric-test-node-entrypoint.sh
    command:
      - sleep
      - infinity
    networks:
      sysnet:
        ipv4_address: 172.29.0.51
    logging:
      driver: "json-file"
      options:
        max-size: "10m"
        max-file: "3"
