version: '3.6'

services:
  haproxy:
    image: haproxytech/haproxy-debian:{{ haproxy_version }}
    volumes:
      - {{ haproxy_cert_dir }}:{{ haproxy_cert_dir }}:ro
      - /etc/haproxy:/usr/local/etc/haproxy:ro
    ports:
      - target: {{ haproxy_default_port }}
        published: {{ haproxy_default_port }}
        protocol: tcp
        mode: host
      - target: {{ haproxy_ssl_port }}
        published: {{ haproxy_ssl_port }}
        protocol: tcp
        mode: host
      - target: {{ haproxy_admin_port }}
        published: {{ haproxy_admin_port }}
        protocol: tcp
        mode: host
    dns: [127.0.0.11]
    deploy:
      mode: replicated
      replicas: 1
      placement:
        constraints: [node.role == manager]
      restart_policy:
        condition: on-failure
        delay: 20s
        max_attempts: 5
        window: 120s
      resources:
        limits:
          cpus: '2.0'
          memory: 768M
        reservations:
          cpus: '1.0'
          memory: 384M
{% if docker_log_to_journal %}
    logging:
      driver: 'journald'
{% endif %}