shinyproxy as a docker service.
This commit is contained in:
parent
ced8ff4234
commit
fd111037cc
|
@ -1,6 +1,7 @@
|
||||||
---
|
---
|
||||||
# https://shinyproxy.io/
|
# https://shinyproxy.io/
|
||||||
shinyproxy_install: False
|
shinyproxy_install: True
|
||||||
|
shinyproxy_as_docker_service: False
|
||||||
shinyproxy_major_ver: 2
|
shinyproxy_major_ver: 2
|
||||||
shinyproxy_minor_ver: 3
|
shinyproxy_minor_ver: 3
|
||||||
shinyproxy_patch_ver: 1
|
shinyproxy_patch_ver: 1
|
||||||
|
@ -17,6 +18,11 @@ shinyproxy_http_port: 8080
|
||||||
# For logrotate. In days
|
# For logrotate. In days
|
||||||
shinyproxy_log_retention: 10
|
shinyproxy_log_retention: 10
|
||||||
shinyproxy_default_apps: True
|
shinyproxy_default_apps: True
|
||||||
|
# Shinyproxy as docker service
|
||||||
|
shinyproxy_as_docker_src_dir: /srv/shinyproxy_service
|
||||||
|
shinyproxy_as_docker_service_name: 'shinyproxy'
|
||||||
|
shinyproxy_docker_network: 'shinyproxy'
|
||||||
|
# Shinyproxy configuration
|
||||||
# docker, docker-swarm, kubernetes
|
# docker, docker-swarm, kubernetes
|
||||||
shinyproxy_container_backend: 'docker'
|
shinyproxy_container_backend: 'docker'
|
||||||
shinyproxy_docker_port: 2375
|
shinyproxy_docker_port: 2375
|
||||||
|
|
|
@ -17,6 +17,10 @@ galaxy_info:
|
||||||
versions:
|
versions:
|
||||||
- trusty
|
- trusty
|
||||||
- bionic
|
- bionic
|
||||||
|
- name: EL
|
||||||
|
versions:
|
||||||
|
- 7
|
||||||
|
- 8
|
||||||
|
|
||||||
galaxy_tags:
|
galaxy_tags:
|
||||||
- R
|
- R
|
||||||
|
|
|
@ -1,74 +1,5 @@
|
||||||
---
|
---
|
||||||
- block:
|
- import_tasks: shinyproxy_vm.yml
|
||||||
- name: Create the shinyproxy user
|
when: not shinyproxy_as_docker_service
|
||||||
user: name={{ shinyproxy_user }} home={{ shinyproxy_install_dir }} createhome=yes system=yes shell=/usr/sbin/nologin
|
- import_tasks: shinyproxy_docker_service.yml
|
||||||
|
when: shinyproxy_as_docker_service
|
||||||
- name: Download the shinyproxy jar
|
|
||||||
become: True
|
|
||||||
become_user: '{{ shinyproxy_user }}'
|
|
||||||
get_url: url={{ shinyproxy_url }} dest={{ shinyproxy_install_dir }}
|
|
||||||
|
|
||||||
- name: Set up a symlink to an unversioned app name
|
|
||||||
become: True
|
|
||||||
become_user: '{{ shinyproxy_user }}'
|
|
||||||
file: src={{ shinyproxy_install_dir }}/{{ shinyproxy_file_name }} dest={{ shinyproxy_install_dir }}/{{ shinyproxy_app_name }} state=link
|
|
||||||
|
|
||||||
- name: Install the shinyproxy configuration file when using version 2.x
|
|
||||||
template: src=shinyproxy-2-conf.yml.j2 dest={{ shinyproxy_install_dir }}/application.yml owner=root group={{ shinyproxy_user }} mode=0640
|
|
||||||
notify: Restart shinyproxy
|
|
||||||
when: shinyproxy_major_ver == 2
|
|
||||||
tags: [ 'shinyproxy', 'shinyproxy_conf', 'shinyproxy_images' ]
|
|
||||||
|
|
||||||
- name: Install the shinyproxy logrotate configuration
|
|
||||||
template: src=shinyproxy-logrotate.j2 dest=/etc/logrotate.d/shinyproxy owner=root group=root mode=0444
|
|
||||||
tags: [ 'shinyproxy', 'shinyproxy_conf' ]
|
|
||||||
|
|
||||||
- name: Install the upstart init file
|
|
||||||
template: src=upstart-shinyproxy.conf.j2 dest=/etc/init/shinyproxy.conf owner=root group=root mode=0644
|
|
||||||
when: ansible_service_mgr != 'systemd'
|
|
||||||
|
|
||||||
when:
|
|
||||||
- ansible_distribution_major_version < '16'
|
|
||||||
- shinyproxy_install | bool
|
|
||||||
tags: shinyproxy
|
|
||||||
|
|
||||||
- block:
|
|
||||||
- name: Install the shinyproxy deb package
|
|
||||||
apt:
|
|
||||||
deb: "https://www.shinyproxy.io/downloads/shinyproxy_{{ shinyproxy_version }}_amd64.deb"
|
|
||||||
state: present
|
|
||||||
|
|
||||||
- name: Install the shinyproxy configuration file when using version 2.x
|
|
||||||
template: src=shinyproxy-2-conf.yml.j2 dest=/etc/shinyproxy/application.yml owner=root group={{ shinyproxy_user }} mode=0640
|
|
||||||
notify: Restart shinyproxy
|
|
||||||
when: shinyproxy_major_ver == 2
|
|
||||||
tags: [ 'shinyproxy', 'shinyproxy_conf', 'shinyproxy_images' ]
|
|
||||||
|
|
||||||
when:
|
|
||||||
- ansible_distribution_file_variety == "Debian"
|
|
||||||
- ansible_distribution_major_version >= '16'
|
|
||||||
- shinyproxy_install | bool
|
|
||||||
tags: shinyproxy
|
|
||||||
|
|
||||||
- block:
|
|
||||||
- name: Ensure that the shinyproxy service is enabled and running
|
|
||||||
service: name=shinyproxy state=started enabled=yes
|
|
||||||
|
|
||||||
- name: Create the directory where to install the custom templates, if we want to use them
|
|
||||||
file: dest={{ shinyproxy_template_path }} state=directory
|
|
||||||
when: shinyproxy_custom_template | bool
|
|
||||||
|
|
||||||
- name: Create shinyproxy log directory
|
|
||||||
file: dest={{ shinyproxy_log_dir }} state=directory owner=shinyproxy mode=0750
|
|
||||||
|
|
||||||
- name: Pull the Docker images for the Shiny apps, when using Docker standalone
|
|
||||||
docker_image: name={{ item.docker_image }} pull=yes state={{ item.image_state | default('present') }} force=yes
|
|
||||||
with_items: '{{ shinyproxy_apps }}'
|
|
||||||
when:
|
|
||||||
- shinyproxy_apps is defined
|
|
||||||
- shinyproxy_container_backend == 'docker'
|
|
||||||
tags: [ 'shinyproxy', 'shinyproxy_images' ]
|
|
||||||
|
|
||||||
when: shinyproxy_install | bool
|
|
||||||
tags: shinyproxy
|
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,27 @@
|
||||||
|
---
|
||||||
|
- name: Manage the composition of shinyproxy as a docker swarm service
|
||||||
|
block:
|
||||||
|
- name: Create the directory where the dockerfile and the configuration file will be copied to
|
||||||
|
file: dest={{ shinyproxy_as_docker_src_dir }} state=directory
|
||||||
|
|
||||||
|
- name: Install the shinyproxy configuration file when using version 2.x
|
||||||
|
template: src=shinyproxy-2-conf.yml.j2 dest={{ shinyproxy_as_docker_src_dir }}/application.yml owner=root group=root mode=0400
|
||||||
|
|
||||||
|
- name: Install the shinyproxy docker file
|
||||||
|
template: src=Dockerfile.j2 dest={{ shinyproxy_as_docker_src_dir }}/Dockerfile owner=root group=root mode=0444
|
||||||
|
|
||||||
|
- name: Create the docker network used by shinyproxy
|
||||||
|
docker_network:
|
||||||
|
name: '{{ shinyproxy_docker_network }}'
|
||||||
|
driver: overlay
|
||||||
|
state: present
|
||||||
|
|
||||||
|
- name: Install the docker compose file
|
||||||
|
template: src=shinyproxy-docker-compose.yml.j2 dest={{ shinyproxy_as_docker_src_dir }}/docker-compose.yml
|
||||||
|
|
||||||
|
- name: Run the docker compose file to start the service
|
||||||
|
docker_compose:
|
||||||
|
project_src: '{{ shinyproxy_as_docker_src_dir }}'
|
||||||
|
build: yes
|
||||||
|
|
||||||
|
tags: [ 'shinyproxy', 'shinyproxy_docker', 'docker' ]
|
|
@ -0,0 +1,91 @@
|
||||||
|
---
|
||||||
|
- block:
|
||||||
|
- name: Create the shinyproxy user
|
||||||
|
user: name={{ shinyproxy_user }} home={{ shinyproxy_install_dir }} createhome=yes system=yes shell=/usr/sbin/nologin
|
||||||
|
|
||||||
|
- name: Download the shinyproxy jar
|
||||||
|
become: True
|
||||||
|
become_user: '{{ shinyproxy_user }}'
|
||||||
|
get_url: url={{ shinyproxy_url }} dest={{ shinyproxy_install_dir }}
|
||||||
|
|
||||||
|
- name: Set up a symlink to an unversioned app name
|
||||||
|
become: True
|
||||||
|
become_user: '{{ shinyproxy_user }}'
|
||||||
|
file: src={{ shinyproxy_install_dir }}/{{ shinyproxy_file_name }} dest={{ shinyproxy_install_dir }}/{{ shinyproxy_app_name }} state=link
|
||||||
|
|
||||||
|
- name: Install the shinyproxy configuration file when using version 2.x
|
||||||
|
template: src=shinyproxy-2-conf.yml.j2 dest={{ shinyproxy_install_dir }}/application.yml owner=root group={{ shinyproxy_user }} mode=0640
|
||||||
|
notify: Restart shinyproxy
|
||||||
|
when: shinyproxy_major_ver == 2
|
||||||
|
tags: [ 'shinyproxy', 'shinyproxy_conf', 'shinyproxy_images' ]
|
||||||
|
|
||||||
|
- name: Install the shinyproxy logrotate configuration
|
||||||
|
template: src=shinyproxy-logrotate.j2 dest=/etc/logrotate.d/shinyproxy owner=root group=root mode=0444
|
||||||
|
tags: [ 'shinyproxy', 'shinyproxy_conf' ]
|
||||||
|
|
||||||
|
- name: Install the upstart init file
|
||||||
|
template: src=upstart-shinyproxy.conf.j2 dest=/etc/init/shinyproxy.conf owner=root group=root mode=0644
|
||||||
|
when: ansible_service_mgr != 'systemd'
|
||||||
|
|
||||||
|
when:
|
||||||
|
- ansible_distribution_file_variety == "Debian"
|
||||||
|
- ansible_distribution_major_version < '16'
|
||||||
|
- shinyproxy_install | bool
|
||||||
|
tags: shinyproxy
|
||||||
|
|
||||||
|
- block:
|
||||||
|
- name: Install the shinyproxy deb package
|
||||||
|
apt:
|
||||||
|
deb: "https://www.shinyproxy.io/downloads/shinyproxy_{{ shinyproxy_version }}_amd64.deb"
|
||||||
|
state: present
|
||||||
|
|
||||||
|
when:
|
||||||
|
- ansible_distribution_file_variety == "Debian"
|
||||||
|
- ansible_distribution_major_version >= '16'
|
||||||
|
- shinyproxy_install | bool
|
||||||
|
tags: shinyproxy
|
||||||
|
|
||||||
|
- block:
|
||||||
|
- name: Install the shinyproxy EL package
|
||||||
|
yum:
|
||||||
|
pkg: "https://www.shinyproxy.io/downloads/shinyproxy_{{ shinyproxy_version }}_x86_64.rpm"
|
||||||
|
state: present
|
||||||
|
|
||||||
|
when:
|
||||||
|
- ansible_distribution_file_variety == "RedHat"
|
||||||
|
- shinyproxy_install | bool
|
||||||
|
tags: shinyproxy
|
||||||
|
|
||||||
|
- name: Shinyproxy configuration when using the package
|
||||||
|
block:
|
||||||
|
- name: Install the shinyproxy configuration file when using version 2.x
|
||||||
|
template: src=shinyproxy-2-conf.yml.j2 dest=/etc/shinyproxy/application.yml owner=root group={{ shinyproxy_user }} mode=0640
|
||||||
|
notify: Restart shinyproxy
|
||||||
|
when: shinyproxy_major_ver == 2
|
||||||
|
|
||||||
|
when:
|
||||||
|
- ansible_distribution_major_version >= '16' or ansible_distribution_file_variety == "RedHat"
|
||||||
|
- shinyproxy_install | bool
|
||||||
|
tags: [ 'shinyproxy', 'shinyproxy_conf', 'shinyproxy_images' ]
|
||||||
|
|
||||||
|
- block:
|
||||||
|
- name: Ensure that the shinyproxy service is enabled and running
|
||||||
|
service: name=shinyproxy state=started enabled=yes
|
||||||
|
|
||||||
|
- name: Create the directory where to install the custom templates, if we want to use them
|
||||||
|
file: dest={{ shinyproxy_template_path }} state=directory
|
||||||
|
when: shinyproxy_custom_template | bool
|
||||||
|
|
||||||
|
- name: Create shinyproxy log directory
|
||||||
|
file: dest={{ shinyproxy_log_dir }} state=directory owner=shinyproxy mode=0750
|
||||||
|
|
||||||
|
- name: Pull the Docker images for the Shiny apps, when using Docker standalone
|
||||||
|
docker_image: name={{ item.docker_image }} pull=yes state={{ item.image_state | default('present') }} force=yes
|
||||||
|
with_items: '{{ shinyproxy_apps }}'
|
||||||
|
when:
|
||||||
|
- shinyproxy_apps is defined
|
||||||
|
- shinyproxy_container_backend == 'docker'
|
||||||
|
tags: [ 'shinyproxy', 'shinyproxy_images' ]
|
||||||
|
|
||||||
|
when: shinyproxy_install | bool
|
||||||
|
tags: shinyproxy
|
|
@ -0,0 +1,8 @@
|
||||||
|
FROM openjdk:8-jre
|
||||||
|
|
||||||
|
RUN mkdir -p {{ shinyproxy_install_dir }}
|
||||||
|
RUN wget {{ shinyproxy_url }} -O {{ shinyproxy_install_dir }}/shinyproxy.jar
|
||||||
|
COPY application.yml {{ shinyproxy_install_dir }}/application.yml
|
||||||
|
|
||||||
|
WORKDIR {{ shinyproxy_install_dir }}
|
||||||
|
CMD ["java", "-jar", "{{ shinyproxy_install_dir }}/shinyproxy.jar"]
|
|
@ -32,6 +32,7 @@ proxy:
|
||||||
manager-dn: {{ shinyproxy_ldap_admin }}
|
manager-dn: {{ shinyproxy_ldap_admin }}
|
||||||
manager-password: {{ shinyproxy_ldap_admin_pwd }}
|
manager-password: {{ shinyproxy_ldap_admin_pwd }}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
{% if shinyproxy_container_backend == 'docker' or shinyproxy_container_backend == 'docker-swarm' }
|
||||||
docker:
|
docker:
|
||||||
container-memory-request: {{ shinyproxy_docker_memory_request }}
|
container-memory-request: {{ shinyproxy_docker_memory_request }}
|
||||||
container-memory-limit: {{ shinyproxy_docker_memory_limit }}
|
container-memory-limit: {{ shinyproxy_docker_memory_limit }}
|
||||||
|
@ -40,7 +41,12 @@ proxy:
|
||||||
url: {{ shinyproxy_docker_url }}
|
url: {{ shinyproxy_docker_url }}
|
||||||
container-protocol: {{ shinyproxy_docker_protocol }}
|
container-protocol: {{ shinyproxy_docker_protocol }}
|
||||||
port-range-start: {{ shinyproxy_docker_port_range_start }}
|
port-range-start: {{ shinyproxy_docker_port_range_start }}
|
||||||
|
{% if shinyproxy_as_docker_service %}
|
||||||
|
internal-networking: true
|
||||||
|
{% else %}
|
||||||
internal-networking: {{ shinyproxy_docker_internal_networking }}
|
internal-networking: {{ shinyproxy_docker_internal_networking }}
|
||||||
|
{% endif %}
|
||||||
|
{% endif %}
|
||||||
specs:
|
specs:
|
||||||
{% if shinyproxy_default_apps %}
|
{% if shinyproxy_default_apps %}
|
||||||
- id: 01_hello
|
- id: 01_hello
|
||||||
|
@ -60,6 +66,9 @@ proxy:
|
||||||
container-cmd: ["R", "-e {{ app.cmd }}"]
|
container-cmd: ["R", "-e {{ app.cmd }}"]
|
||||||
container-image: {{ app.docker_image }}
|
container-image: {{ app.docker_image }}
|
||||||
container-memory: {{ app.docker_memory | default('2g') }}
|
container-memory: {{ app.docker_memory | default('2g') }}
|
||||||
|
{% if shinyproxy_as_docker_service %}
|
||||||
|
container-network: {{ shinyproxy_docker_network }}
|
||||||
|
{% endif %}
|
||||||
{% if app.groups is defined %}
|
{% if app.groups is defined %}
|
||||||
groups: {{ app.groups }}
|
groups: {{ app.groups }}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
|
@ -0,0 +1,26 @@
|
||||||
|
version: '3.8'
|
||||||
|
|
||||||
|
services:
|
||||||
|
shinyproxy:
|
||||||
|
build: .
|
||||||
|
volumes:
|
||||||
|
- /var/run/docker.sock:/var/run/docker.sock
|
||||||
|
ports:
|
||||||
|
- '{{ shinyproxy_http_port }}':'{{ shinyproxy_http_port }}'
|
||||||
|
networks:
|
||||||
|
- '{{ shinyproxy_docker_network }}'
|
||||||
|
deploy:
|
||||||
|
mode: replicated
|
||||||
|
replicas: 1
|
||||||
|
placement:
|
||||||
|
constraints: [node.role == manager]
|
||||||
|
restart_policy:
|
||||||
|
condition: on-failure
|
||||||
|
delay: 5s
|
||||||
|
max_attempts: 3
|
||||||
|
window: 120s
|
||||||
|
|
||||||
|
networks:
|
||||||
|
'{{ shinyproxy_docker_network }}':
|
||||||
|
driver: overlay
|
||||||
|
attachable: true
|
Loading…
Reference in New Issue