From 9e33d22e01c7240a80ba86a576ecab3906807dfe Mon Sep 17 00:00:00 2001 From: MarcoMC Date: Thu, 26 Jan 2023 09:42:27 -0500 Subject: [PATCH 1/7] Add optional console healthcheck on local builds --- .../docker-compose.yml/service/console.yml.twig | 8 ++++++++ ...oint.dynamic.sh => entrypoint.dynamic.sh.twig} | 13 +++++++++++++ .../image/console/root/healthcheck.test.sh.twig | 14 ++++++++++++++ src/_base/harness/attributes/common.yml | 15 +++++++++++++++ .../harness/attributes/environment/local.yml | 5 ++++- src/_base/harness/config/confd.yml | 2 ++ src/_base/harness/scripts/enable.sh.twig | 3 ++- src/akeneo/harness/config/confd.yml | 2 ++ src/magento1/harness/config/confd.yml | 2 ++ src/magento2/harness/config/confd.yml | 2 ++ .../docker-compose.yml/service/console.yml.twig | 8 ++++++++ .../harness/attributes/environment/local.yml | 3 +++ src/spryker/harness/config/confd.yml | 2 ++ src/symfony/harness/config/confd.yml | 2 ++ src/wordpress/harness/config/confd.yml | 2 ++ 15 files changed, 81 insertions(+), 2 deletions(-) rename src/_base/docker/image/console/root/{entrypoint.dynamic.sh => entrypoint.dynamic.sh.twig} (84%) create mode 100755 src/_base/docker/image/console/root/healthcheck.test.sh.twig diff --git a/src/_base/_twig/docker-compose.yml/service/console.yml.twig b/src/_base/_twig/docker-compose.yml/service/console.yml.twig index 6a1325832..68e4b1087 100644 --- a/src/_base/_twig/docker-compose.yml/service/console.yml.twig +++ b/src/_base/_twig/docker-compose.yml/service/console.yml.twig @@ -8,6 +8,14 @@ context: ./ dockerfile: .my127ws/docker/image/console/Dockerfile {% if @('app.build') == 'dynamic' %} +{% if @('console.healthcheck.enabled') %} + healthcheck: + test: {{ to_nice_yaml( @('console.healthcheck.test.command'), 2, 8) | raw }} + start_period: {{ @('console.healthcheck.start_period') }} + interval: {{ @('console.healthcheck.interval') }} + timeout: {{ @('console.healthcheck.timeout') }} + retries: {{ @('console.healthcheck.retries') }} +{% endif %} entrypoint: [/entrypoint.dynamic.sh] command: [sleep, infinity] volumes: diff --git a/src/_base/docker/image/console/root/entrypoint.dynamic.sh b/src/_base/docker/image/console/root/entrypoint.dynamic.sh.twig similarity index 84% rename from src/_base/docker/image/console/root/entrypoint.dynamic.sh rename to src/_base/docker/image/console/root/entrypoint.dynamic.sh.twig index 4acc8c5c3..e16ecd495 100755 --- a/src/_base/docker/image/console/root/entrypoint.dynamic.sh +++ b/src/_base/docker/image/console/root/entrypoint.dynamic.sh.twig @@ -47,10 +47,23 @@ resolve_volume_mount_strategy() fi } +healthcheck_action() +{ + + # run any command required which result can be monitored by Docker's HEALTHCHECK + {% for step in @('console.healthcheck.action.steps') -%} + {{ step|raw }} + {% else -%} + echo "No healthcheck action steps declared" + {% endfor %} + +} + bootstrap() { resolve_volume_mount_strategy setup_app_volume_permissions + healthcheck_action } bootstrap diff --git a/src/_base/docker/image/console/root/healthcheck.test.sh.twig b/src/_base/docker/image/console/root/healthcheck.test.sh.twig new file mode 100755 index 000000000..c6efdc980 --- /dev/null +++ b/src/_base/docker/image/console/root/healthcheck.test.sh.twig @@ -0,0 +1,14 @@ +#!/bin/bash + +healthcheck_test() +{ + # run any command required which result can be monitored by Docker's HEALTHCHECK + {% for step in @('console.healthcheck.test.steps') -%} + {{ step|raw }} + {% else -%} + echo "No healthcheck test steps declared" + {% endfor %} + +} + +healthcheck_test diff --git a/src/_base/harness/attributes/common.yml b/src/_base/harness/attributes/common.yml index b8a8b4779..f27610854 100644 --- a/src/_base/harness/attributes/common.yml +++ b/src/_base/harness/attributes/common.yml @@ -297,6 +297,21 @@ attributes.default: steps: [] console: + healthcheck: + # we want that enabled only for local builds + enabled: false + action: + steps: + - echo 'Entrypoint tasks completed' > /tmp/HEALTHCHECK.txt + test: + script: /healthcheck.test.sh + command: ['CMD', 'bash', = @('console.healthcheck.test.script')] + steps: + - find /tmp/HEALTHCHECK.txt + start_period: 5s + interval: 5s + timeout: 3s + retries: 10 entrypoint: steps: [] diff --git a/src/_base/harness/attributes/environment/local.yml b/src/_base/harness/attributes/environment/local.yml index 41505a544..32df8174a 100644 --- a/src/_base/harness/attributes/environment/local.yml +++ b/src/_base/harness/attributes/environment/local.yml @@ -3,4 +3,7 @@ attributes: app: build: dynamic mode: development - version: develop \ No newline at end of file + version: develop + console: + healthcheck: + enabled: true diff --git a/src/_base/harness/config/confd.yml b/src/_base/harness/config/confd.yml index 550aacec2..a1562ff54 100644 --- a/src/_base/harness/config/confd.yml +++ b/src/_base/harness/config/confd.yml @@ -3,6 +3,8 @@ confd('harness:/'): # base templates - { src: docker/image/console/Dockerfile } - { src: docker/image/console/root/entrypoint.sh } + - { src: docker/image/console/root/entrypoint.dynamic.sh } + - { src: docker/image/console/root/healthcheck.test.sh } - { src: docker/image/console/root/home/build/.my.cnf } - { src: docker/image/console/root/lib/task/database/import.sh } - { src: docker/image/console/root/lib/task/build/frontend.sh } diff --git a/src/_base/harness/scripts/enable.sh.twig b/src/_base/harness/scripts/enable.sh.twig index b047664d6..7ea4bb1e3 100755 --- a/src/_base/harness/scripts/enable.sh.twig +++ b/src/_base/harness/scripts/enable.sh.twig @@ -85,7 +85,8 @@ dynamic_console() find .my127ws/docker/image/ -type d ! -perm u+rwx,go+rx,o-w -exec chmod u+rwx,go+rx,o-w {} + - passthru docker-compose up --build -d console + passthru docker-compose up --build -d console --wait + # docker-compose will wait for `console` to be in healty status if healthcheck is enabled passthru docker-compose exec -T -u build console app build if [ "$USE_MUTAGEN" = yes ]; then diff --git a/src/akeneo/harness/config/confd.yml b/src/akeneo/harness/config/confd.yml index d342e4697..c5269a0e5 100644 --- a/src/akeneo/harness/config/confd.yml +++ b/src/akeneo/harness/config/confd.yml @@ -3,6 +3,8 @@ confd('harness:/'): # base templates - { src: docker/image/console/Dockerfile } - { src: docker/image/console/root/entrypoint.sh } + - { src: docker/image/console/root/entrypoint.dynamic.sh } + - { src: docker/image/console/root/healthcheck.test.sh } - { src: docker/image/console/root/home/build/.my.cnf } - { src: docker/image/console/root/lib/task/database/import.sh } - { src: docker/image/console/root/lib/task/build/frontend.sh } diff --git a/src/magento1/harness/config/confd.yml b/src/magento1/harness/config/confd.yml index 8ee0040c0..5033daf2b 100644 --- a/src/magento1/harness/config/confd.yml +++ b/src/magento1/harness/config/confd.yml @@ -3,6 +3,8 @@ confd('harness:/'): # base templates - { src: docker/image/console/Dockerfile } - { src: docker/image/console/root/entrypoint.sh } + - { src: docker/image/console/root/entrypoint.dynamic.sh } + - { src: docker/image/console/root/healthcheck.test.sh } - { src: docker/image/console/root/home/build/.my.cnf } - { src: docker/image/console/root/lib/task/database/import.sh } - { src: docker/image/console/root/lib/task/build/frontend.sh } diff --git a/src/magento2/harness/config/confd.yml b/src/magento2/harness/config/confd.yml index 87a09309c..f7f63c59a 100644 --- a/src/magento2/harness/config/confd.yml +++ b/src/magento2/harness/config/confd.yml @@ -3,6 +3,8 @@ confd('harness:/'): # base templates - { src: docker/image/console/Dockerfile } - { src: docker/image/console/root/entrypoint.sh } + - { src: docker/image/console/root/entrypoint.dynamic.sh } + - { src: docker/image/console/root/healthcheck.test.sh } - { src: docker/image/console/root/home/build/.my.cnf } - { src: docker/image/console/root/lib/task/database/import.sh } - { src: docker/image/console/root/lib/task/build/frontend.sh } diff --git a/src/spryker/_twig/docker-compose.yml/service/console.yml.twig b/src/spryker/_twig/docker-compose.yml/service/console.yml.twig index 154fc6bda..f01f43bfb 100644 --- a/src/spryker/_twig/docker-compose.yml/service/console.yml.twig +++ b/src/spryker/_twig/docker-compose.yml/service/console.yml.twig @@ -8,6 +8,14 @@ context: ./ dockerfile: .my127ws/docker/image/console/Dockerfile {% if @('app.build') == 'dynamic' %} +{% if @('console.healthcheck.enabled') %} + healthcheck: + test: {{ to_nice_yaml( @('console.healthcheck.test.command'), 2, 8) | raw }} + start_period: {{ @('console.healthcheck.start_period') }} + interval: {{ @('console.healthcheck.interval') }} + timeout: {{ @('console.healthcheck.timeout') }} + retries: {{ @('console.healthcheck.retries') }} +{% endif %} image: {{ @('workspace.name') ~ '-console:dev' }} entrypoint: [/entrypoint.dynamic.sh] command: [sleep, infinity] diff --git a/src/spryker/harness/attributes/environment/local.yml b/src/spryker/harness/attributes/environment/local.yml index 340d633ec..e5baa56d9 100644 --- a/src/spryker/harness/attributes/environment/local.yml +++ b/src/spryker/harness/attributes/environment/local.yml @@ -5,3 +5,6 @@ attributes: build: dynamic mode: development version: develop + console: + healthcheck: + enabled: true diff --git a/src/spryker/harness/config/confd.yml b/src/spryker/harness/config/confd.yml index 953071f62..447fc86df 100644 --- a/src/spryker/harness/config/confd.yml +++ b/src/spryker/harness/config/confd.yml @@ -3,6 +3,8 @@ confd('harness:/'): # base templates - { src: docker/image/console/Dockerfile } - { src: docker/image/console/root/entrypoint.sh } + - { src: docker/image/console/root/entrypoint.dynamic.sh } + - { src: docker/image/console/root/healthcheck.test.sh } - { src: docker/image/console/root/home/build/.my.cnf } - { src: docker/image/console/root/lib/task/database/import.sh } - { src: docker/image/console/root/lib/task/build/frontend.sh } diff --git a/src/symfony/harness/config/confd.yml b/src/symfony/harness/config/confd.yml index d34379088..d17f66fe8 100644 --- a/src/symfony/harness/config/confd.yml +++ b/src/symfony/harness/config/confd.yml @@ -3,6 +3,8 @@ confd('harness:/'): # base templates - { src: docker/image/console/Dockerfile } - { src: docker/image/console/root/entrypoint.sh } + - { src: docker/image/console/root/entrypoint.dynamic.sh } + - { src: docker/image/console/root/healthcheck.test.sh } - { src: docker/image/console/root/home/build/.my.cnf } - { src: docker/image/console/root/lib/task/database/import.sh } - { src: docker/image/console/root/lib/task/build/frontend.sh } diff --git a/src/wordpress/harness/config/confd.yml b/src/wordpress/harness/config/confd.yml index e29928424..85c43cec2 100644 --- a/src/wordpress/harness/config/confd.yml +++ b/src/wordpress/harness/config/confd.yml @@ -3,6 +3,8 @@ confd('harness:/'): # base templates - { src: docker/image/console/Dockerfile } - { src: docker/image/console/root/entrypoint.sh } + - { src: docker/image/console/root/entrypoint.dynamic.sh } + - { src: docker/image/console/root/healthcheck.test.sh } - { src: docker/image/console/root/home/build/.my.cnf } - { src: docker/image/console/root/lib/task/database/import.sh } - { src: docker/image/console/root/lib/task/build/frontend.sh } From 208e0b0ce00b4a68a71d307833679ac899496180 Mon Sep 17 00:00:00 2001 From: MarcoMC Date: Thu, 26 Jan 2023 10:02:16 -0500 Subject: [PATCH 2/7] Add a CHANGELOG to track new additions --- src/_base/CHANGELOG.md | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 src/_base/CHANGELOG.md diff --git a/src/_base/CHANGELOG.md b/src/_base/CHANGELOG.md new file mode 100644 index 000000000..c496057cd --- /dev/null +++ b/src/_base/CHANGELOG.md @@ -0,0 +1,15 @@ +# CHANGELOG + +## 1.5.0 - 20230126 + +### Added attributes + +* `attribute('console.healthcheck.enabled')` - Defaults to `true` only for local builds +* `attribute('console.healthcheck.action.steps')` - Steps necessary to create a measurable condition to test later +* `attribute('console.healthcheck.test.script')` - The path to the script that will host the health checks steps +* `attribute('console.healthcheck.test.command')` - The command in array format that will run the healthcheck - Defaults to the test script path +* `attribute('console.healthcheck.test.steps')` - Steps necessary to test the measurable condition to determine the health of the container +* `attribute('console.healthcheck.test.start_period')` - Defaults to 5s +* `attribute('console.healthcheck.test.interval')` - Defaults to 5s +* `attribute('console.healthcheck.test.timeout')` - Defaults to 3s +* `attribute('console.healthcheck.test.retries')` - Defaults to 10 From a398961918f18cd2bec54adc5aa7d58478c2c83b Mon Sep 17 00:00:00 2001 From: MarcoMC Date: Thu, 26 Jan 2023 15:12:32 -0500 Subject: [PATCH 3/7] Use `app state` for console's healthcheck --- src/_base/CHANGELOG.md | 6 ++---- .../docker-compose.yml/service/console.yml.twig | 4 ++-- ...point.dynamic.sh.twig => entrypoint.dynamic.sh} | 13 ------------- .../docker/image/console/root/entrypoint.sh.twig | 6 ++++++ .../image/console/root/healthcheck.test.sh.twig | 14 -------------- src/_base/harness/attributes/common.yml | 12 ++++-------- src/_base/harness/config/confd.yml | 3 +-- src/akeneo/harness/config/confd.yml | 3 +-- src/magento1/harness/config/confd.yml | 3 +-- src/magento2/harness/config/confd.yml | 3 +-- .../docker-compose.yml/service/console.yml.twig | 4 ++-- src/spryker/harness/config/confd.yml | 3 +-- src/symfony/harness/config/confd.yml | 3 +-- src/wordpress/harness/config/confd.yml | 3 +-- 14 files changed, 23 insertions(+), 57 deletions(-) rename src/_base/docker/image/console/root/{entrypoint.dynamic.sh.twig => entrypoint.dynamic.sh} (84%) mode change 100755 => 100644 delete mode 100755 src/_base/docker/image/console/root/healthcheck.test.sh.twig diff --git a/src/_base/CHANGELOG.md b/src/_base/CHANGELOG.md index c496057cd..1ab913201 100644 --- a/src/_base/CHANGELOG.md +++ b/src/_base/CHANGELOG.md @@ -4,11 +4,9 @@ ### Added attributes +* `attribute('console.stete.steps')` - Steps necessary to test the health of the console container * `attribute('console.healthcheck.enabled')` - Defaults to `true` only for local builds -* `attribute('console.healthcheck.action.steps')` - Steps necessary to create a measurable condition to test later -* `attribute('console.healthcheck.test.script')` - The path to the script that will host the health checks steps -* `attribute('console.healthcheck.test.command')` - The command in array format that will run the healthcheck - Defaults to the test script path -* `attribute('console.healthcheck.test.steps')` - Steps necessary to test the measurable condition to determine the health of the container +* `attribute('console.healthcheck.test')` - The command in array format that will run the healthcheck - Defaults to ['CMD', 'app', 'state'] * `attribute('console.healthcheck.test.start_period')` - Defaults to 5s * `attribute('console.healthcheck.test.interval')` - Defaults to 5s * `attribute('console.healthcheck.test.timeout')` - Defaults to 3s diff --git a/src/_base/_twig/docker-compose.yml/service/console.yml.twig b/src/_base/_twig/docker-compose.yml/service/console.yml.twig index 68e4b1087..17f5ae228 100644 --- a/src/_base/_twig/docker-compose.yml/service/console.yml.twig +++ b/src/_base/_twig/docker-compose.yml/service/console.yml.twig @@ -7,15 +7,15 @@ build: context: ./ dockerfile: .my127ws/docker/image/console/Dockerfile -{% if @('app.build') == 'dynamic' %} {% if @('console.healthcheck.enabled') %} healthcheck: - test: {{ to_nice_yaml( @('console.healthcheck.test.command'), 2, 8) | raw }} + test: {{ to_nice_yaml( @('console.healthcheck.test'), 2, 8) | raw }} start_period: {{ @('console.healthcheck.start_period') }} interval: {{ @('console.healthcheck.interval') }} timeout: {{ @('console.healthcheck.timeout') }} retries: {{ @('console.healthcheck.retries') }} {% endif %} +{% if @('app.build') == 'dynamic' %} entrypoint: [/entrypoint.dynamic.sh] command: [sleep, infinity] volumes: diff --git a/src/_base/docker/image/console/root/entrypoint.dynamic.sh.twig b/src/_base/docker/image/console/root/entrypoint.dynamic.sh old mode 100755 new mode 100644 similarity index 84% rename from src/_base/docker/image/console/root/entrypoint.dynamic.sh.twig rename to src/_base/docker/image/console/root/entrypoint.dynamic.sh index e16ecd495..4acc8c5c3 --- a/src/_base/docker/image/console/root/entrypoint.dynamic.sh.twig +++ b/src/_base/docker/image/console/root/entrypoint.dynamic.sh @@ -47,23 +47,10 @@ resolve_volume_mount_strategy() fi } -healthcheck_action() -{ - - # run any command required which result can be monitored by Docker's HEALTHCHECK - {% for step in @('console.healthcheck.action.steps') -%} - {{ step|raw }} - {% else -%} - echo "No healthcheck action steps declared" - {% endfor %} - -} - bootstrap() { resolve_volume_mount_strategy setup_app_volume_permissions - healthcheck_action } bootstrap diff --git a/src/_base/docker/image/console/root/entrypoint.sh.twig b/src/_base/docker/image/console/root/entrypoint.sh.twig index 8c8b35af9..063813c09 100755 --- a/src/_base/docker/image/console/root/entrypoint.sh.twig +++ b/src/_base/docker/image/console/root/entrypoint.sh.twig @@ -36,10 +36,16 @@ run_steps() fi } +healthcheck_checkpoint() +{ + echo 'Entrypoint tasks completed: console has started' > /run/started +} + bootstrap() { setup_app_networking run_steps + healthcheck_checkpoint } bootstrap diff --git a/src/_base/docker/image/console/root/healthcheck.test.sh.twig b/src/_base/docker/image/console/root/healthcheck.test.sh.twig deleted file mode 100755 index c6efdc980..000000000 --- a/src/_base/docker/image/console/root/healthcheck.test.sh.twig +++ /dev/null @@ -1,14 +0,0 @@ -#!/bin/bash - -healthcheck_test() -{ - # run any command required which result can be monitored by Docker's HEALTHCHECK - {% for step in @('console.healthcheck.test.steps') -%} - {{ step|raw }} - {% else -%} - echo "No healthcheck test steps declared" - {% endfor %} - -} - -healthcheck_test diff --git a/src/_base/harness/attributes/common.yml b/src/_base/harness/attributes/common.yml index f27610854..de77af227 100644 --- a/src/_base/harness/attributes/common.yml +++ b/src/_base/harness/attributes/common.yml @@ -297,17 +297,13 @@ attributes.default: steps: [] console: + state: + steps: + - if [[ -f /run/started ]]; then cat /run/started; else return 1; fi healthcheck: # we want that enabled only for local builds enabled: false - action: - steps: - - echo 'Entrypoint tasks completed' > /tmp/HEALTHCHECK.txt - test: - script: /healthcheck.test.sh - command: ['CMD', 'bash', = @('console.healthcheck.test.script')] - steps: - - find /tmp/HEALTHCHECK.txt + test: ['CMD', 'app', 'state'] start_period: 5s interval: 5s timeout: 3s diff --git a/src/_base/harness/config/confd.yml b/src/_base/harness/config/confd.yml index a1562ff54..be9df75f4 100644 --- a/src/_base/harness/config/confd.yml +++ b/src/_base/harness/config/confd.yml @@ -3,8 +3,6 @@ confd('harness:/'): # base templates - { src: docker/image/console/Dockerfile } - { src: docker/image/console/root/entrypoint.sh } - - { src: docker/image/console/root/entrypoint.dynamic.sh } - - { src: docker/image/console/root/healthcheck.test.sh } - { src: docker/image/console/root/home/build/.my.cnf } - { src: docker/image/console/root/lib/task/database/import.sh } - { src: docker/image/console/root/lib/task/build/frontend.sh } @@ -14,6 +12,7 @@ confd('harness:/'): - { src: docker/image/console/root/lib/task/install.sh } - { src: docker/image/console/root/lib/task/migrate.sh } - { src: docker/image/console/root/lib/task/rabbitmq/vhosts.sh } + - { src: docker/image/console/root/lib/task/state.sh } - { src: docker/image/console/root/lib/task/welcome.sh } - { src: docker/image/console/root/usr/local/etc/php/php.ini } - { src: docker/image/console/root/usr/local/etc/php/conf.d/docker-php-ext-blackfire.ini } diff --git a/src/akeneo/harness/config/confd.yml b/src/akeneo/harness/config/confd.yml index c5269a0e5..bb587321e 100644 --- a/src/akeneo/harness/config/confd.yml +++ b/src/akeneo/harness/config/confd.yml @@ -3,8 +3,6 @@ confd('harness:/'): # base templates - { src: docker/image/console/Dockerfile } - { src: docker/image/console/root/entrypoint.sh } - - { src: docker/image/console/root/entrypoint.dynamic.sh } - - { src: docker/image/console/root/healthcheck.test.sh } - { src: docker/image/console/root/home/build/.my.cnf } - { src: docker/image/console/root/lib/task/database/import.sh } - { src: docker/image/console/root/lib/task/build/frontend.sh } @@ -14,6 +12,7 @@ confd('harness:/'): - { src: docker/image/console/root/lib/task/install.sh } - { src: docker/image/console/root/lib/task/migrate.sh } - { src: docker/image/console/root/lib/task/rabbitmq/vhosts.sh } + - { src: docker/image/console/root/lib/task/state.sh } - { src: docker/image/console/root/lib/task/welcome.sh } - { src: docker/image/console/root/usr/local/etc/php/php.ini } - { src: docker/image/console/root/usr/local/etc/php/conf.d/docker-php-ext-blackfire.ini } diff --git a/src/magento1/harness/config/confd.yml b/src/magento1/harness/config/confd.yml index 5033daf2b..5db5dfdea 100644 --- a/src/magento1/harness/config/confd.yml +++ b/src/magento1/harness/config/confd.yml @@ -3,8 +3,6 @@ confd('harness:/'): # base templates - { src: docker/image/console/Dockerfile } - { src: docker/image/console/root/entrypoint.sh } - - { src: docker/image/console/root/entrypoint.dynamic.sh } - - { src: docker/image/console/root/healthcheck.test.sh } - { src: docker/image/console/root/home/build/.my.cnf } - { src: docker/image/console/root/lib/task/database/import.sh } - { src: docker/image/console/root/lib/task/build/frontend.sh } @@ -14,6 +12,7 @@ confd('harness:/'): - { src: docker/image/console/root/lib/task/install.sh } - { src: docker/image/console/root/lib/task/migrate.sh } - { src: docker/image/console/root/lib/task/rabbitmq/vhosts.sh } + - { src: docker/image/console/root/lib/task/state.sh } - { src: docker/image/console/root/lib/task/welcome.sh } - { src: docker/image/console/root/usr/local/etc/php/php.ini } - { src: docker/image/console/root/usr/local/etc/php/conf.d/docker-php-ext-blackfire.ini } diff --git a/src/magento2/harness/config/confd.yml b/src/magento2/harness/config/confd.yml index f7f63c59a..15dfca49f 100644 --- a/src/magento2/harness/config/confd.yml +++ b/src/magento2/harness/config/confd.yml @@ -3,8 +3,6 @@ confd('harness:/'): # base templates - { src: docker/image/console/Dockerfile } - { src: docker/image/console/root/entrypoint.sh } - - { src: docker/image/console/root/entrypoint.dynamic.sh } - - { src: docker/image/console/root/healthcheck.test.sh } - { src: docker/image/console/root/home/build/.my.cnf } - { src: docker/image/console/root/lib/task/database/import.sh } - { src: docker/image/console/root/lib/task/build/frontend.sh } @@ -14,6 +12,7 @@ confd('harness:/'): - { src: docker/image/console/root/lib/task/install.sh } - { src: docker/image/console/root/lib/task/migrate.sh } - { src: docker/image/console/root/lib/task/rabbitmq/vhosts.sh } + - { src: docker/image/console/root/lib/task/state.sh } - { src: docker/image/console/root/lib/task/welcome.sh } - { src: docker/image/console/root/usr/local/etc/php/php.ini } - { src: docker/image/console/root/usr/local/etc/php/conf.d/docker-php-ext-blackfire.ini } diff --git a/src/spryker/_twig/docker-compose.yml/service/console.yml.twig b/src/spryker/_twig/docker-compose.yml/service/console.yml.twig index f01f43bfb..744be95e3 100644 --- a/src/spryker/_twig/docker-compose.yml/service/console.yml.twig +++ b/src/spryker/_twig/docker-compose.yml/service/console.yml.twig @@ -7,15 +7,15 @@ build: context: ./ dockerfile: .my127ws/docker/image/console/Dockerfile -{% if @('app.build') == 'dynamic' %} {% if @('console.healthcheck.enabled') %} healthcheck: - test: {{ to_nice_yaml( @('console.healthcheck.test.command'), 2, 8) | raw }} + test: {{ to_nice_yaml( @('console.healthcheck.test'), 2, 8) | raw }} start_period: {{ @('console.healthcheck.start_period') }} interval: {{ @('console.healthcheck.interval') }} timeout: {{ @('console.healthcheck.timeout') }} retries: {{ @('console.healthcheck.retries') }} {% endif %} +{% if @('app.build') == 'dynamic' %} image: {{ @('workspace.name') ~ '-console:dev' }} entrypoint: [/entrypoint.dynamic.sh] command: [sleep, infinity] diff --git a/src/spryker/harness/config/confd.yml b/src/spryker/harness/config/confd.yml index 447fc86df..0e864f2b3 100644 --- a/src/spryker/harness/config/confd.yml +++ b/src/spryker/harness/config/confd.yml @@ -3,8 +3,6 @@ confd('harness:/'): # base templates - { src: docker/image/console/Dockerfile } - { src: docker/image/console/root/entrypoint.sh } - - { src: docker/image/console/root/entrypoint.dynamic.sh } - - { src: docker/image/console/root/healthcheck.test.sh } - { src: docker/image/console/root/home/build/.my.cnf } - { src: docker/image/console/root/lib/task/database/import.sh } - { src: docker/image/console/root/lib/task/build/frontend.sh } @@ -14,6 +12,7 @@ confd('harness:/'): - { src: docker/image/console/root/lib/task/install.sh } - { src: docker/image/console/root/lib/task/migrate.sh } - { src: docker/image/console/root/lib/task/rabbitmq/vhosts.sh } + - { src: docker/image/console/root/lib/task/state.sh } - { src: docker/image/console/root/lib/task/welcome.sh } - { src: docker/image/console/root/usr/local/etc/php/php.ini } - { src: docker/image/console/root/usr/local/etc/php/conf.d/docker-php-ext-blackfire.ini } diff --git a/src/symfony/harness/config/confd.yml b/src/symfony/harness/config/confd.yml index d17f66fe8..b9ed7a720 100644 --- a/src/symfony/harness/config/confd.yml +++ b/src/symfony/harness/config/confd.yml @@ -3,8 +3,6 @@ confd('harness:/'): # base templates - { src: docker/image/console/Dockerfile } - { src: docker/image/console/root/entrypoint.sh } - - { src: docker/image/console/root/entrypoint.dynamic.sh } - - { src: docker/image/console/root/healthcheck.test.sh } - { src: docker/image/console/root/home/build/.my.cnf } - { src: docker/image/console/root/lib/task/database/import.sh } - { src: docker/image/console/root/lib/task/build/frontend.sh } @@ -14,6 +12,7 @@ confd('harness:/'): - { src: docker/image/console/root/lib/task/install.sh } - { src: docker/image/console/root/lib/task/migrate.sh } - { src: docker/image/console/root/lib/task/rabbitmq/vhosts.sh } + - { src: docker/image/console/root/lib/task/state.sh } - { src: docker/image/console/root/lib/task/welcome.sh } - { src: docker/image/console/root/usr/local/etc/php/php.ini } - { src: docker/image/console/root/usr/local/etc/php/conf.d/docker-php-ext-blackfire.ini } diff --git a/src/wordpress/harness/config/confd.yml b/src/wordpress/harness/config/confd.yml index 85c43cec2..b3e4a74f3 100644 --- a/src/wordpress/harness/config/confd.yml +++ b/src/wordpress/harness/config/confd.yml @@ -3,8 +3,6 @@ confd('harness:/'): # base templates - { src: docker/image/console/Dockerfile } - { src: docker/image/console/root/entrypoint.sh } - - { src: docker/image/console/root/entrypoint.dynamic.sh } - - { src: docker/image/console/root/healthcheck.test.sh } - { src: docker/image/console/root/home/build/.my.cnf } - { src: docker/image/console/root/lib/task/database/import.sh } - { src: docker/image/console/root/lib/task/build/frontend.sh } @@ -14,6 +12,7 @@ confd('harness:/'): - { src: docker/image/console/root/lib/task/install.sh } - { src: docker/image/console/root/lib/task/migrate.sh } - { src: docker/image/console/root/lib/task/rabbitmq/vhosts.sh } + - { src: docker/image/console/root/lib/task/state.sh } - { src: docker/image/console/root/lib/task/welcome.sh } - { src: docker/image/console/root/usr/local/etc/php/php.ini } - { src: docker/image/console/root/usr/local/etc/php/conf.d/docker-php-ext-blackfire.ini } From b2ab4ba6bdb181dccd15d0cb617f8c66c302b852 Mon Sep 17 00:00:00 2001 From: MarcoMC Date: Thu, 26 Jan 2023 15:15:39 -0500 Subject: [PATCH 4/7] Fix typo in CHANGELOG --- src/_base/CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/_base/CHANGELOG.md b/src/_base/CHANGELOG.md index 1ab913201..b9fde5c09 100644 --- a/src/_base/CHANGELOG.md +++ b/src/_base/CHANGELOG.md @@ -4,7 +4,7 @@ ### Added attributes -* `attribute('console.stete.steps')` - Steps necessary to test the health of the console container +* `attribute('console.state.steps')` - Steps necessary to test the health of the console container * `attribute('console.healthcheck.enabled')` - Defaults to `true` only for local builds * `attribute('console.healthcheck.test')` - The command in array format that will run the healthcheck - Defaults to ['CMD', 'app', 'state'] * `attribute('console.healthcheck.test.start_period')` - Defaults to 5s From d94d638e087bfa91d019802ee20000822317260b Mon Sep 17 00:00:00 2001 From: MarcoMC Date: Thu, 26 Jan 2023 15:21:25 -0500 Subject: [PATCH 5/7] move state.sh to a TWIG template --- .../image/console/root/lib/task/state.sh | 8 -------- .../image/console/root/lib/task/state.sh.twig | 20 +++++++++++++++++++ 2 files changed, 20 insertions(+), 8 deletions(-) delete mode 100644 src/_base/docker/image/console/root/lib/task/state.sh create mode 100644 src/_base/docker/image/console/root/lib/task/state.sh.twig diff --git a/src/_base/docker/image/console/root/lib/task/state.sh b/src/_base/docker/image/console/root/lib/task/state.sh deleted file mode 100644 index c0e00419c..000000000 --- a/src/_base/docker/image/console/root/lib/task/state.sh +++ /dev/null @@ -1,8 +0,0 @@ -#!/bin/bash - -function task_state() -{ - task database:available - - echo "Ready!" -} diff --git a/src/_base/docker/image/console/root/lib/task/state.sh.twig b/src/_base/docker/image/console/root/lib/task/state.sh.twig new file mode 100644 index 000000000..140fda665 --- /dev/null +++ b/src/_base/docker/image/console/root/lib/task/state.sh.twig @@ -0,0 +1,20 @@ +#!/bin/bash + +function test_ok() +{ + # run any command required which result can be monitored by Docker's HEALTHCHECK + {% for step in @('console.state.steps') -%} + {{ step|raw }} + {% else -%} + echo "No state test steps declared" + {% endfor %} + +} + +function task_state() +{ + if ! test_ok; then + echo "Console is not ready: test steps failed!" + return 1 + fi +} From cd5cef1b72c2b1b1b1da803b3fbbf559de84f5ce Mon Sep 17 00:00:00 2001 From: Marco MC Date: Fri, 27 Jan 2023 09:08:15 -0500 Subject: [PATCH 6/7] Update src/_base/docker/image/console/root/lib/task/state.sh.twig Co-authored-by: andytson-inviqa --- src/_base/docker/image/console/root/lib/task/state.sh.twig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/_base/docker/image/console/root/lib/task/state.sh.twig b/src/_base/docker/image/console/root/lib/task/state.sh.twig index 140fda665..38d5fb26d 100644 --- a/src/_base/docker/image/console/root/lib/task/state.sh.twig +++ b/src/_base/docker/image/console/root/lib/task/state.sh.twig @@ -6,7 +6,7 @@ function test_ok() {% for step in @('console.state.steps') -%} {{ step|raw }} {% else -%} - echo "No state test steps declared" + : {% endfor %} } From 32e383ec9520e43bff222cd7128e1e34de30f4e0 Mon Sep 17 00:00:00 2001 From: Marco MC Date: Fri, 27 Jan 2023 09:08:24 -0500 Subject: [PATCH 7/7] Update src/_base/harness/scripts/enable.sh.twig Co-authored-by: andytson-inviqa --- src/_base/harness/scripts/enable.sh.twig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/_base/harness/scripts/enable.sh.twig b/src/_base/harness/scripts/enable.sh.twig index 7ea4bb1e3..ad7559e66 100755 --- a/src/_base/harness/scripts/enable.sh.twig +++ b/src/_base/harness/scripts/enable.sh.twig @@ -85,8 +85,8 @@ dynamic_console() find .my127ws/docker/image/ -type d ! -perm u+rwx,go+rx,o-w -exec chmod u+rwx,go+rx,o-w {} + - passthru docker-compose up --build -d console --wait # docker-compose will wait for `console` to be in healty status if healthcheck is enabled + passthru docker-compose up --build -d console --wait passthru docker-compose exec -T -u build console app build if [ "$USE_MUTAGEN" = yes ]; then