version: '3.6'

{% set clustered = (cluster_replacement is defined and cluster_replacement) or (cluster_check is defined and cluster_check) %}

services:
  {{ conductor_service }}:
    environment:
      - CONFIG_PROP={{ conductor_config }}
    image: "{{ conductor_image }}"
    networks:
      - {{ conductor_network }}
    deploy:
      mode: replicated
      replicas: {{ conductor_replicas }}
{% if infrastructure != 'local' %}
      placement:
        constraints: [node.role == worker]
{% endif %}
      restart_policy:
        condition: on-failure
        delay: 5s
        window: 120s
    configs:
      - source: swarm-config
        target: /app/config/{{ conductor_config }}

    logging:
      driver: "journald"

  {{ conductor_ui_service }}:
    environment:
      - WF_SERVER={{ conductor_service_url }}
{% if conductor_auth is defined %}
      - AUTH_CONFIG_PATH=/app/config/auth.config
{% endif %}
    image: "{{ conductor_ui_image }}"
    networks:
      - {{ conductor_network }}
{% if conductor_auth is defined %}
    configs:
      - source: auth-config
        target: /app/config/auth.config
{% endif %}
    deploy:
      mode: replicated
      replicas: {{ conductor_ui_replicas }}
{% if infrastructure != 'local' %}
      placement:
        constraints: [node.role == worker]
{% endif %}
      restart_policy:
        condition: on-failure
        delay: 5s
        window: 120s

networks:
   {{ conductor_network }}:

configs:
   swarm-config:
     file: ./{{ conductor_config }}
{% if conductor_auth is defined %}
   auth-config:
     file: ./auth.cfg
{% endif %}
