From d6d7dd1bd7e730200a739a623827abdbdb95edc8 Mon Sep 17 00:00:00 2001 From: kartnico Date: Sun, 26 Dec 2021 18:48:06 +0100 Subject: [PATCH 1/3] feat(ng): manage docker heathcheck in ng state --- docker/compose/ng.sls | 6 ++++++ docs/README.rst | 25 +++++++++++++++++++++++++ pillar.example | 25 +++++++++++++++++++++++++ 3 files changed, 56 insertions(+) diff --git a/docker/compose/ng.sls b/docker/compose/ng.sls index f82f381e..e6e18a3e 100644 --- a/docker/compose/ng.sls +++ b/docker/compose/ng.sls @@ -49,6 +49,12 @@ docker-compose-ng-{{ id }}-running: {%- if 'user' in container %} - user: {{ container.user }} {%- endif %} + {%- if 'healthcheck' in container and container.healthcheck is iterable %} + - healthcheck: + {%- for variable, value in container.healthcheck.items() %} + - {{ variable }}: {{ value }} + {%- endfor %} + {%- endif %} {%- if 'environment' in container and container.environment is iterable %} - environment: {%- for variable, value in container.environment.items() %} diff --git a/docs/README.rst b/docs/README.rst index d81fe5a0..c3448bf4 100644 --- a/docs/README.rst +++ b/docs/README.rst @@ -212,6 +212,31 @@ To use this formula, you might target a host with the following pillar: working_dir: '/var/www/html' volume_driver: 'local' userns_mode: 'host' + dashy: + image: 'lissy93/dashy:latest' + container_name: 'dashy' + networks: + - frontend + restart: unless-stopped + environment: + NODE_ENV: "production" + ports: + - "4000:80" + volumes: + - /srv/docker-registry/dashy:/app/public + cap_drop: + - ALL + cap_add: + - CHOWN + - SETGID + - SETUID + - DAC_OVERRIDE + - NET_BIND_SERVICE + healthcheck: + test: ['CMD', 'node', '/app/services/healthcheck'] + interval: {{ 90e9 | int }} # 1m30s + timeout: {{ 10e9 | int }} # 5s + retries: 3 Then you would target a host with the following states: diff --git a/pillar.example b/pillar.example index d2e6ef71..e9b5cb3c 100644 --- a/pillar.example +++ b/pillar.example @@ -171,6 +171,31 @@ docker: restart: "always" tty: true stdin_open: true + dashy: + image: 'lissy93/dashy:latest' + container_name: 'dashy' + networks: + - frontend + restart: unless-stopped + environment: + NODE_ENV: "production" + ports: + - "4000:80" + volumes: + - /srv/docker-registry/dashy:/app/public + cap_drop: + - ALL + cap_add: + - CHOWN + - SETGID + - SETUID + - DAC_OVERRIDE + - NET_BIND_SERVICE + healthcheck: + test: ['CMD', 'node', '/app/services/healthcheck'] + interval: {{ 90e9 | int }} # 1m30s + timeout: {{ 10e9 | int }} # 5s + retries: 3 swarm: # Per https://docs.saltstack.com/en/latest/ref/modules/all/salt.modules.swarm.html From 0966f86fdebde0519d1b916496c03127f47c23df Mon Sep 17 00:00:00 2001 From: kartnico Date: Sun, 26 Dec 2021 19:06:54 +0100 Subject: [PATCH 2/3] fix(ng): correct indent --- docs/README.rst | 2 +- pillar.example | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/README.rst b/docs/README.rst index c3448bf4..9eb94588 100644 --- a/docs/README.rst +++ b/docs/README.rst @@ -221,7 +221,7 @@ To use this formula, you might target a host with the following pillar: environment: NODE_ENV: "production" ports: - - "4000:80" + - "4000:80" volumes: - /srv/docker-registry/dashy:/app/public cap_drop: diff --git a/pillar.example b/pillar.example index e9b5cb3c..e5dfda98 100644 --- a/pillar.example +++ b/pillar.example @@ -180,7 +180,7 @@ docker: environment: NODE_ENV: "production" ports: - - "4000:80" + - "4000:80" volumes: - /srv/docker-registry/dashy:/app/public cap_drop: From 74f8af84d0af93df7078dd00521b134dac117a39 Mon Sep 17 00:00:00 2001 From: kartnico Date: Sat, 15 Jan 2022 14:59:26 +0100 Subject: [PATCH 3/3] fix(ng): manage healthcheck items with json format --- docker/compose/ng.sls | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/docker/compose/ng.sls b/docker/compose/ng.sls index e6e18a3e..b4763136 100644 --- a/docker/compose/ng.sls +++ b/docker/compose/ng.sls @@ -50,10 +50,7 @@ docker-compose-ng-{{ id }}-running: - user: {{ container.user }} {%- endif %} {%- if 'healthcheck' in container and container.healthcheck is iterable %} - - healthcheck: - {%- for variable, value in container.healthcheck.items() %} - - {{ variable }}: {{ value }} - {%- endfor %} + - healthcheck: {{ container.healthcheck|unique|json }} {%- endif %} {%- if 'environment' in container and container.environment is iterable %} - environment: