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

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

commit a56c8776f81da06c10aa11502190820223de8330
Author: jstastny-cz <[email protected]>
AuthorDate: Mon Nov 13 12:02:30 2023 +0100

    Run docker inside kogito-ci-build container
---
 apache-nodes/Dockerfile.kogito-ci-build | 26 +++++++++++++-------------
 apache-nodes/entrypoint.sh              |  7 +++++++
 apache-nodes/start-docker.sh            | 31 +++++++++++++++++++++++++++++++
 3 files changed, 51 insertions(+), 13 deletions(-)

diff --git a/apache-nodes/Dockerfile.kogito-ci-build 
b/apache-nodes/Dockerfile.kogito-ci-build
index 1c94ab50..38786225 100644
--- a/apache-nodes/Dockerfile.kogito-ci-build
+++ b/apache-nodes/Dockerfile.kogito-ci-build
@@ -1,4 +1,4 @@
-FROM ubuntu:latest
+FROM cruizba/ubuntu-dind:latest
 
 SHELL ["/bin/bash", "-c"]
 
@@ -62,18 +62,9 @@ RUN groupadd -g 910 nonrootuser && useradd -u 910 -g 910 -s 
/bin/bash -m nonroot
   echo "nonrootuser ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers
 
 # Docker
-RUN apt install -y ca-certificates curl gnupg lvm2 && \
-  install -m 0755 -d /etc/apt/keyrings && \
-  curl -fsSL https://download.docker.com/linux/ubuntu/gpg | gpg --dearmor -o 
/etc/apt/keyrings/docker.gpg && \
-  chmod a+r /etc/apt/keyrings/docker.gpg && \
-  echo \
-    "deb [arch="$(dpkg --print-architecture)" 
signed-by=/etc/apt/keyrings/docker.gpg] 
https://download.docker.com/linux/ubuntu \
-    "$(. /etc/os-release && echo "$VERSION_CODENAME")" stable" | \
-    sudo tee /etc/apt/sources.list.d/docker.list > /dev/null && \
-  apt update && \
-  apt install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin 
docker-compose-plugin && \
-  apt clean all && \
-  update-alternatives --install /usr/local/bin/docker-compose docker-compose 
/usr/libexec/docker/cli-plugins/docker-compose 1
+RUN groupadd docker && \
+  usermod -aG docker nonrootuser && \
+  newgrp docker
 
 USER nonrootuser
 
@@ -149,3 +140,12 @@ ENV CONTAINER_ENGINE="docker"
 ENV CONTAINER_ENGINE_TLS_OPTIONS=""
 
 WORKDIR /project/directory
+
+USER root
+COPY start-docker.sh entrypoint.sh /usr/local/bin/
+RUN chmod +x /usr/local/bin/start-docker.sh \
+       /usr/local/bin/entrypoint.sh
+USER nonrootuser
+
+ENTRYPOINT ["entrypoint.sh"]
+CMD ["bash"]
\ No newline at end of file
diff --git a/apache-nodes/entrypoint.sh b/apache-nodes/entrypoint.sh
new file mode 100755
index 00000000..1ac2c0ad
--- /dev/null
+++ b/apache-nodes/entrypoint.sh
@@ -0,0 +1,7 @@
+#!/bin/bash
+
+# Start docker
+start-docker.sh
+
+# Execute specified command
+"$@"
\ No newline at end of file
diff --git a/apache-nodes/start-docker.sh b/apache-nodes/start-docker.sh
new file mode 100755
index 00000000..bebdf338
--- /dev/null
+++ b/apache-nodes/start-docker.sh
@@ -0,0 +1,31 @@
+#!/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
+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


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

Reply via email to