services:
  ours-rp-soak:
    image: ${RPKI_IMAGE:-ours-rp-runtime-arm64:dev}
    platform: ${RPKI_PLATFORM:-linux/arm64}
    container_name: ${COMPOSE_PROJECT_NAME:-ours-rp-arm64}-soak
    env_file:
      - ../.env
    environment:
      PACKAGE_ROOT: /opt/ours-rp
      ENV_FILE: /opt/ours-rp/.env
      RUN_ROOT: /var/lib/ours-rp
      BIN_DIR: /opt/ours-rp/bin
      FIXTURE_DIR: /opt/ours-rp/fixtures
    volumes:
      - ../.env:/opt/ours-rp/.env:ro
      - ${HOST_DATA_DIR:-/var/lib/ours-rp-arm64}/state:/var/lib/ours-rp/state
      - ${HOST_DATA_DIR:-/var/lib/ours-rp-arm64}/runs:/var/lib/ours-rp/runs
      - ${HOST_DATA_DIR:-/var/lib/ours-rp-arm64}/logs:/var/lib/ours-rp/logs
      - ${HOST_DATA_DIR:-/var/lib/ours-rp-arm64}/tmp:/var/lib/ours-rp/tmp
    restart: ${SOAK_RESTART_POLICY:-unless-stopped}
    profiles:
      - core

  artifact-metrics:
    image: ${RPKI_IMAGE:-ours-rp-runtime-arm64:dev}
    platform: ${RPKI_PLATFORM:-linux/arm64}
    container_name: ${COMPOSE_PROJECT_NAME:-ours-rp-arm64}-artifact-metrics
    env_file:
      - ../.env
    command:
      - /opt/ours-rp/bin/rpki_artifact_metrics
      - --run-root
      - /var/lib/ours-rp
      - --listen
      - 0.0.0.0:9556
      - --poll-secs
      - ${METRICS_POLL_SECS:-10}
      - --instance
      - ${METRICS_INSTANCE:-arm64-installer}
    ports:
      - "${METRICS_PORT:-9556}:9556"
    volumes:
      - ${HOST_DATA_DIR:-/var/lib/ours-rp-arm64}/state:/var/lib/ours-rp/state:ro
      - ${HOST_DATA_DIR:-/var/lib/ours-rp-arm64}/runs:/var/lib/ours-rp/runs:ro
      - ${HOST_DATA_DIR:-/var/lib/ours-rp-arm64}/logs:/var/lib/ours-rp/logs:ro
    restart: unless-stopped
    profiles:
      - sidecar

  prometheus:
    image: ${PROMETHEUS_IMAGE:-prom/prometheus:v2.55.1}
    platform: ${MONITOR_PLATFORM:-linux/arm64}
    container_name: ${COMPOSE_PROJECT_NAME:-ours-rp-arm64}-prometheus
    command:
      - --config.file=/etc/prometheus/prometheus.yml
      - --storage.tsdb.path=/prometheus
      - --storage.tsdb.retention.time=${PROMETHEUS_RETENTION:-7d}
      - --web.enable-lifecycle
    depends_on:
      - artifact-metrics
    user: "0:0"
    ports:
      - "${PROMETHEUS_PORT:-9090}:9090"
    volumes:
      - ./prometheus.yml:/etc/prometheus/prometheus.yml:ro
      - ${HOST_DATA_DIR:-/var/lib/ours-rp-arm64}/prometheus:/prometheus
    restart: unless-stopped
    profiles:
      - monitor

  grafana:
    image: ${GRAFANA_IMAGE:-grafana/grafana:11.3.1}
    platform: ${MONITOR_PLATFORM:-linux/arm64}
    container_name: ${COMPOSE_PROJECT_NAME:-ours-rp-arm64}-grafana
    depends_on:
      - prometheus
    user: "0:0"
    ports:
      - "${GRAFANA_PORT:-3000}:3000"
    environment:
      GF_SECURITY_ADMIN_USER: ${GRAFANA_ADMIN_USER:-admin}
      GF_SECURITY_ADMIN_PASSWORD: ${GRAFANA_ADMIN_PASSWORD:-admin}
      GF_USERS_ALLOW_SIGN_UP: "false"
    volumes:
      - ${HOST_DATA_DIR:-/var/lib/ours-rp-arm64}/grafana:/var/lib/grafana
      - ./grafana/provisioning:/etc/grafana/provisioning:ro
      - ./grafana/dashboards:/var/lib/grafana/dashboards:ro
    restart: unless-stopped
    profiles:
      - monitor
