This is an automated email from the ASF dual-hosted git repository.

jstastnycz pushed a commit to branch kie-issues_747
in repository 
https://gitbox.apache.org/repos/asf/incubator-kie-kogito-pipelines.git


The following commit(s) were added to refs/heads/kie-issues_747 by this push:
     new e0c76ab5 provide separate script wait-for-docker.sh
e0c76ab5 is described below

commit e0c76ab5a1e44ca37fee7086fe3430e7c3d1f647
Author: jstastny-cz <[email protected]>
AuthorDate: Thu Dec 7 07:53:25 2023 +0100

    provide separate script wait-for-docker.sh
---
 apache-nodes/Dockerfile.kogito-ci-build              |  8 ++++++--
 apache-nodes/start-docker.sh                         | 20 ++------------------
 apache-nodes/wait-for-docker.sh                      |  4 ++++
 .../{start-docker.sh => wait-for-process.sh}         | 18 +++---------------
 4 files changed, 15 insertions(+), 35 deletions(-)

diff --git a/apache-nodes/Dockerfile.kogito-ci-build 
b/apache-nodes/Dockerfile.kogito-ci-build
index fbe793b7..10455c9a 100644
--- a/apache-nodes/Dockerfile.kogito-ci-build
+++ b/apache-nodes/Dockerfile.kogito-ci-build
@@ -157,10 +157,14 @@ ENV CONTAINER_ENGINE_TLS_OPTIONS=""
 WORKDIR /project/directory
 
 USER root
-COPY start-docker.sh entrypoint.sh /usr/local/bin/
+COPY start-docker.sh wait-for-docker.sh wait-for-process.sh entrypoint.sh 
/usr/local/bin/
 RUN chmod +x /usr/local/bin/start-docker.sh \
-       /usr/local/bin/entrypoint.sh
+       /usr/local/bin/entrypoint.sh \
+  /usr/local/bin/wait-for-docker.sh \
+  /usr/local/bin/wait-for-process.sh
 USER nonrootuser
 
+RUN echo "source wait-for-docker.sh" >> ~/.profile
+
 ENTRYPOINT ["entrypoint.sh"]
 CMD ["bash"]
diff --git a/apache-nodes/start-docker.sh b/apache-nodes/start-docker.sh
index bebdf338..9b1422d9 100755
--- a/apache-nodes/start-docker.sh
+++ b/apache-nodes/start-docker.sh
@@ -1,31 +1,15 @@
 #!/bin/bash
 source /opt/bash-utils/logger.sh
 
-function wait_for_process () {
-    local max_time_wait=30
-    local process_name="$1"
-    local waited_sec=0
-    while ! pgrep "$process_name" >/dev/null && ((waited_sec < 
max_time_wait)); do
-        INFO "Process $process_name is not running yet. Retrying in 1 seconds"
-        INFO "Waited $waited_sec seconds of $max_time_wait seconds"
-        sleep 1
-        ((waited_sec=waited_sec+1))
-        if ((waited_sec >= max_time_wait)); then
-            return 1
-        fi
-    done
-    sudo chown root:docker /var/run/docker.sock
-    return 0
-}
-
 INFO "Starting supervisor"
 sudo bash -c "/usr/bin/supervisord >> /dev/null 2>&1" &
 
 INFO "Waiting for docker to be running"
-wait_for_process dockerd
+source wait-for-docker.sh
 if [ $? -ne 0 ]; then
     ERROR "dockerd is not running after max time"
     exit 1
 else
+    sudo chown root:docker /var/run/docker.sock
     INFO "dockerd is running"
 fi
\ No newline at end of file
diff --git a/apache-nodes/wait-for-docker.sh b/apache-nodes/wait-for-docker.sh
new file mode 100644
index 00000000..ee636f9c
--- /dev/null
+++ b/apache-nodes/wait-for-docker.sh
@@ -0,0 +1,4 @@
+#!/bin/bash
+source wait-for-process.sh
+
+wait_for_process dockerd
\ No newline at end of file
diff --git a/apache-nodes/start-docker.sh b/apache-nodes/wait-for-process.sh
old mode 100755
new mode 100644
similarity index 62%
copy from apache-nodes/start-docker.sh
copy to apache-nodes/wait-for-process.sh
index bebdf338..9cfc0a8d
--- a/apache-nodes/start-docker.sh
+++ b/apache-nodes/wait-for-process.sh
@@ -1,6 +1,6 @@
 #!/bin/bash
 source /opt/bash-utils/logger.sh
-
+set -e
 function wait_for_process () {
     local max_time_wait=30
     local process_name="$1"
@@ -14,18 +14,6 @@ function wait_for_process () {
             return 1
         fi
     done
-    sudo chown root:docker /var/run/docker.sock
+    INFO "Process $process_name successfully started."
     return 0
-}
-
-INFO "Starting supervisor"
-sudo bash -c "/usr/bin/supervisord >> /dev/null 2>&1" &
-
-INFO "Waiting for docker to be running"
-wait_for_process dockerd
-if [ $? -ne 0 ]; then
-    ERROR "dockerd is not running after max time"
-    exit 1
-else
-    INFO "dockerd is running"
-fi
\ No newline at end of file
+}
\ No newline at end of file


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to