From e74cc41869c0782145506ea59ca1de9a51dcd3ec Mon Sep 17 00:00:00 2001
From: Bartek Wrona <wrona@syncad.com>
Date: Wed, 24 Jan 2024 20:31:54 +0100
Subject: [PATCH] Improved Gitlab healtchecks integration to the app container
 performing setup.

---
 templates/test_jobs.gitlab-ci.yml | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/templates/test_jobs.gitlab-ci.yml b/templates/test_jobs.gitlab-ci.yml
index 9db4586..d283c61 100644
--- a/templates/test_jobs.gitlab-ci.yml
+++ b/templates/test_jobs.gitlab-ci.yml
@@ -91,6 +91,19 @@ include:
         # intentionally use setup way chosed in haf_api_node compose scripts
         POSTGRES_URL: "postgresql://haf_admin@haf-instance/haf_block_log"
       command: ["install_app"]
+      entrypoint:
+        - '/bin/bash'
+        - '-c'
+        - |
+          set -xeuo pipefail
+          echo "Attempting to perform application setup..."
+          # pass control to the default image entrypoint
+          "./docker_entrypoint.sh" "$@"
+          echo "Application setup completed, starting to listed app port to satisfy Gitlab health checker..."
+          # Once setup completed, just listen on container/app port to satisfy GitlabCI HealthChecker
+          nc -v -l -p $(echo "${HAF_APP_PORT}")
+        # arg $0 should be explicitly passed when using 'bash -c' entrypoints
+        - '/bin/bash'
 
     - name: ${HAF_APP_IMAGE}
       alias: app
-- 
GitLab