name: {{ network }}

volumes:
  {% for service in services %}
  hoprd-{{ network }}-{{ service.node_suffix }}:
  {% endfor %}

x-envars: &envvars
  RUST_BACKTRACE: full
  HOPRD_CONFIGURATION_FILE_PATH: /app/hoprd.cfg.yaml
  HOPRD_API_PORT: 3001
  {% for key, value in envvars.items() %}
  {{ key }}: {{ value }}
  {% endfor %}

x-settings: &settings
  image: europe-west3-docker.pkg.dev/hoprassociation/docker-images/hoprd:{{ version|default("latest", true) }}
  restart: unless-stopped
  pull_policy: always
  stop_signal: SIGINT
  security_opt:
    - seccomp:unconfined
  deploy:
    resources:
      reservations:
        memory: 1g
      limits:
        memory: 2g
  logging:
    driver: json-file
    options:
      max-size: 1000M
      max-file: "5"
{% if network_names %}
  networks:
  {% for network_name in network_names %}
    - {{ network_name }}
  {% endfor %}
{% endif %}
  expose:
    - 3001
  environment:
    <<: *envvars

services:
  {% for service in services %}
  hoprd-{{ network }}-{{ service.node_suffix }}:
    <<: *settings
    container_name: hoprd-{{ network }}-{{ service.node_suffix }}
    volumes:
      - {{ service.folder }}/.hopr-configs/{{ network }}/hoprd-{{ network }}-{{ service.node_suffix }}.cfg.yaml:/app/hoprd.cfg.yaml
      - {{ service.folder }}/.hopr-ids/{{ network }}/hoprd-{{ network }}-{{ service.node_suffix }}.id:/app/hopr.id
      - hoprd-{{ network }}-{{ service.node_suffix }}:/app/hoprd-db
    ports:
      - {{ service.session_port }}:{{ service.session_port }}/tcp
      - {{ service.session_port }}:{{ service.session_port }}/udp
      - {{ service.network_port }}:{{ service.network_port }}/tcp
      - {{ service.network_port }}:{{ service.network_port }}/udp
  {% endfor %}

{% if networks %}
networks:
{{ networks_yaml }}
{% endif %}
