diff --git a/defaults/main.yml b/defaults/main.yml index abb8105..99e1a54 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -28,9 +28,11 @@ shinyproxy_log_retention: 10 shinyproxy_default_apps: True # Shinyproxy as docker service shinyproxy_docker_image: 'openanalytics/shinyproxy:latest' +shinyproxy_as_docker_stack_name: 'shinyproxy' shinyproxy_as_docker_service_name: 'shinyproxy' -shinyproxy_as_docker_src_dir: /srv/{{ shinyproxy_as_docker_service_name }}_service +shinyproxy_as_docker_src_dir: /srv/{{ shinyproxy_as_docker_stack_name }}_service shinyproxy_docker_network: 'shinyproxy' +shinyproxy_docker_swarm_behind_haproxy: True shinyproxy_docker_swarm_replicas: 1 shinyproxy_docker_mount_conf_file: True shinyproxy_docker_log_to_journal: True diff --git a/tasks/shinyproxy_docker_service.yml b/tasks/shinyproxy_docker_service.yml index 6a247c2..0e437fb 100644 --- a/tasks/shinyproxy_docker_service.yml +++ b/tasks/shinyproxy_docker_service.yml @@ -44,7 +44,7 @@ - name: Start the shinyproxy stack docker_stack: - name: shinyproxy + name: '{{ shinyproxy_as_docker_stack_name }}' state: present compose: - '{{ shinyproxy_as_docker_src_dir }}/docker-shinyproxy-stack.yml' diff --git a/templates/shinyproxy-2-conf.yml.j2 b/templates/shinyproxy-2-conf.yml.j2 index ff92ac0..dad0e46 100644 --- a/templates/shinyproxy-2-conf.yml.j2 +++ b/templates/shinyproxy-2-conf.yml.j2 @@ -85,7 +85,7 @@ proxy: {% if shinyproxy_as_docker_service %} {% if shinyproxy_container_backend == 'docker-swarm' %} - container-network: {{ shinyproxy_as_docker_service_name }}_{{ shinyproxy_docker_network }} + container-network: {{ shinyproxy_as_docker_stack_name }}_{{ shinyproxy_docker_network }} {% else %} diff --git a/templates/shinyproxy-docker-compose.yml.j2 b/templates/shinyproxy-docker-compose.yml.j2 index 56b2656..176bee3 100644 --- a/templates/shinyproxy-docker-compose.yml.j2 +++ b/templates/shinyproxy-docker-compose.yml.j2 @@ -1,7 +1,7 @@ version: '3.8' networks: -{% if shinyproxy_container_backend == 'docker-swarm' %} +{% if shinyproxy_container_backend == 'docker-swarm' and shinyproxy_docker_swarm_behind_haproxy %} haproxy-public: external: true {% endif %} @@ -23,6 +23,13 @@ services: {% endif %} {% else %} image: {{ shinyproxy_docker_image }} +{% if not shinyproxy_docker_swarm_behind_haproxy %} + ports: + - {{ shinyproxy_http_port }}:{{ shinyproxy_http_port }} +{% if shinyproxy_expose_prometheus and shinyproxy_version is version_compare('2.5.0', '>=') %} + - {{ shinyproxy_prometheus_port }}:{{ shinyproxy_prometheus_port }} +{% endif %} +{% endif %} {% endif %} volumes: - /var/run/docker.sock:/var/run/docker.sock @@ -37,14 +44,16 @@ services: {% endif %} networks: - {{ shinyproxy_docker_network }} -{% if shinyproxy_container_backend == 'docker-swarm' %} +{% if shinyproxy_container_backend == 'docker-swarm' and shinyproxy_docker_swarm_behind_haproxy %} - haproxy-public {% endif %} {% if shinyproxy_container_backend == 'docker-swarm' %} deploy: mode: replicated replicas: {{ shinyproxy_docker_swarm_replicas }} +{% if shinyproxy_docker_swarm_behind_haproxy %} endpoint_mode: dnsrr +{% endif %} placement: constraints: [node.role == manager] restart_policy: