{%- macro q(v) -%}{{ (v|string|replace("$", "$$"))|tojson }}{%- endmacro -%}
status-api:
  image: {{ STATUS_API_DOCKER_IMAGE }}
  restart: unless-stopped
  read_only: true
  cap_drop: [ALL]
  security_opt: ["no-new-privileges:true"]
  tmpfs:
    - /tmp
  environment:
    STATUS_TITLE: {{ q(STATUS_TITLE) }}
    STATUS_CHECKS_FILE: "/config/checks.yml"
    STATUS_DATA_DIR: "/data"
    STATUS_FAIL_THRESHOLD: {{ q(STATUS_FAIL_THRESHOLD) }}
    STATUS_RETENTION_DAYS: {{ q(STATUS_RETENTION_DAYS) }}
    STATUS_MYSQL_PASSWORD: {{ q(STATUS_MYSQL_PASSWORD) }}
    STATUS_REDIS_PASSWORD: {{ q(STATUS_REDIS_PASSWORD) }}
  healthcheck:
    test: ["CMD", "python", "-c", "import socket; socket.create_connection(('127.0.0.1', 8000), 3).close()"]
    interval: 30s
    timeout: 5s
    retries: 3
    start_period: 20s
  volumes:
    - ../plugins/status/config:/config:ro
    - ../../data/status:/data
{%- for mount in iter_mounts(MOUNTS, "status-api") %}
    - {{ mount }}
{%- endfor %}
status-web:
  image: {{ STATUS_WEB_DOCKER_IMAGE }}
  restart: unless-stopped
  read_only: true
  cap_drop: [ALL]
  security_opt: ["no-new-privileges:true"]
  tmpfs:
    - /tmp
    - /var/cache/nginx
    - /var/cache/status-cache:uid=101,gid=101,mode=0755  # nginx (uid 101) must be able to write the stale-answer cache
    - /var/run
  healthcheck:
    test: ["CMD-SHELL", "wget -q -O /dev/null http://127.0.0.1:8080/ || exit 1"]
    interval: 30s
    timeout: 5s
    retries: 3
    start_period: 10s
{%- set web_mounts = iter_mounts(MOUNTS, "status-web")|list %}
{%- if web_mounts %}
  volumes:
{%- for mount in web_mounts %}
    - {{ mount }}
{%- endfor %}
{%- endif %}
