From 98a3ef416ca18c943e42e107ca5487cb414e9794 Mon Sep 17 00:00:00 2001 From: Costas Papastathis Date: Wed, 14 Sep 2022 17:55:56 +0300 Subject: [PATCH 1/5] fix: adding 18 tested images --- 18/Dockerfile.c8s | 1 + 18/Dockerfile.fedora | 1 + 18/s2i/bin/init-wrapper | 18 ++++++++++++++++++ 18/s2i/bin/run | 3 +++ 4 files changed, 23 insertions(+) create mode 100644 18/s2i/bin/init-wrapper diff --git a/18/Dockerfile.c8s b/18/Dockerfile.c8s index 24bab7be..60e4e3b7 100644 --- a/18/Dockerfile.c8s +++ b/18/Dockerfile.c8s @@ -65,6 +65,7 @@ RUN yum -y module enable nodejs:$NODEJS_VERSION && \ # Copy the S2I scripts from the specific language image to $STI_SCRIPTS_PATH COPY ./s2i/bin/ $STI_SCRIPTS_PATH +RUN chmod +x $STI_SCRIPTS_PATH/init-wrapper # Copy extra files to the image. COPY ./root/ / diff --git a/18/Dockerfile.fedora b/18/Dockerfile.fedora index 75d9b642..192c4613 100644 --- a/18/Dockerfile.fedora +++ b/18/Dockerfile.fedora @@ -58,6 +58,7 @@ RUN yum -y module enable nodejs:$NODEJS_VERSION && \ # Copy the S2I scripts from the specific language image to $STI_SCRIPTS_PATH COPY ./s2i/bin/ $STI_SCRIPTS_PATH +RUN chmod +x $STI_SCRIPTS_PATH/init-wrapper # Copy extra files to the image, including help file. COPY ./root/ / diff --git a/18/s2i/bin/init-wrapper b/18/s2i/bin/init-wrapper new file mode 100644 index 00000000..24e0d078 --- /dev/null +++ b/18/s2i/bin/init-wrapper @@ -0,0 +1,18 @@ +#!/bin/bash + +# Overview of how this script works: http://veithen.io/2014/11/16/sigterm-propagation.html +# Set a trap to kill the main app process when this +# init script receives SIGTERM or SIGINT +trap 'kill -s TERM $PID' TERM INT +# Execute the main application in the background +"$@" & +PID=$! +# wait command always terminates when trap is caught, even if the process hasn't finished yet +wait $PID +# Remove the trap and wait till the app process finishes completely +trap - TERM INT +# We wait again, since the first wait terminates when trap is caught +wait $PID +# Exit with the exit code of the app process +STATUS=$? +exit $STATUS \ No newline at end of file diff --git a/18/s2i/bin/run b/18/s2i/bin/run index ff566f55..c94ac202 100755 --- a/18/s2i/bin/run +++ b/18/s2i/bin/run @@ -20,6 +20,9 @@ run_node() { if [ "$DEV_MODE" == true ]; then echo "Launching via nodemon..." exec nodemon --inspect="$DEBUG_PORT" + elif [ -v NODE_CMD ]; then + echo "launching via init wrapper..." + exec ${STI_SCRIPTS_PATH}/init-wrapper $NODE_CMD else echo "Launching via npm..." exec npm run -d $NPM_RUN From d0ca42098f6b4ff0983f8287dfe14672c16e3232 Mon Sep 17 00:00:00 2001 From: Costas Papastathis Date: Wed, 21 Sep 2022 19:27:47 +0300 Subject: [PATCH 2/5] fix: adding 14 tested images --- 14/Dockerfile | 1 + 14/Dockerfile.fedora | 1 + 14/Dockerfile.rhel7 | 1 + 14/Dockerfile.rhel8 | 1 + 14/s2i/bin/init-wrapper | 18 ++++++++++++++++++ 14/s2i/bin/run | 3 +++ 6 files changed, 25 insertions(+) create mode 100644 14/s2i/bin/init-wrapper diff --git a/14/Dockerfile b/14/Dockerfile index 2e55cf1e..4a8b6dbd 100644 --- a/14/Dockerfile +++ b/14/Dockerfile @@ -63,6 +63,7 @@ RUN yum install -y centos-release-scl-rh && \ # Copy the S2I scripts from the specific language image to $STI_SCRIPTS_PATH COPY ./s2i/bin/ $STI_SCRIPTS_PATH +RUN chmod +x $STI_SCRIPTS_PATH/init-wrapper # Copy extra files to the image, including help file. COPY ./root/ / diff --git a/14/Dockerfile.fedora b/14/Dockerfile.fedora index a551abde..54311d26 100644 --- a/14/Dockerfile.fedora +++ b/14/Dockerfile.fedora @@ -58,6 +58,7 @@ RUN yum -y module enable nodejs:$NODEJS_VERSION && \ # Copy the S2I scripts from the specific language image to $STI_SCRIPTS_PATH COPY ./s2i/bin/ $STI_SCRIPTS_PATH +RUN chmod +x $STI_SCRIPTS_PATH/init-wrapper # Copy extra files to the image, including help file. COPY ./root/ / diff --git a/14/Dockerfile.rhel7 b/14/Dockerfile.rhel7 index 2e9879a2..68736a3f 100644 --- a/14/Dockerfile.rhel7 +++ b/14/Dockerfile.rhel7 @@ -67,6 +67,7 @@ RUN yum install -y yum-utils && \ # Copy the S2I scripts from the specific language image to $STI_SCRIPTS_PATH COPY ./s2i/bin/ $STI_SCRIPTS_PATH +RUN chmod +x $STI_SCRIPTS_PATH/init-wrapper # Copy extra files to the image. COPY ./root/ / diff --git a/14/Dockerfile.rhel8 b/14/Dockerfile.rhel8 index cbf89f4b..c632e56d 100644 --- a/14/Dockerfile.rhel8 +++ b/14/Dockerfile.rhel8 @@ -65,6 +65,7 @@ RUN yum -y module enable nodejs:$NODEJS_VERSION && \ # Copy the S2I scripts from the specific language image to $STI_SCRIPTS_PATH COPY ./s2i/bin/ $STI_SCRIPTS_PATH +RUN chmod +x $STI_SCRIPTS_PATH/init-wrapper # Copy extra files to the image. COPY ./root/ / diff --git a/14/s2i/bin/init-wrapper b/14/s2i/bin/init-wrapper new file mode 100644 index 00000000..24e0d078 --- /dev/null +++ b/14/s2i/bin/init-wrapper @@ -0,0 +1,18 @@ +#!/bin/bash + +# Overview of how this script works: http://veithen.io/2014/11/16/sigterm-propagation.html +# Set a trap to kill the main app process when this +# init script receives SIGTERM or SIGINT +trap 'kill -s TERM $PID' TERM INT +# Execute the main application in the background +"$@" & +PID=$! +# wait command always terminates when trap is caught, even if the process hasn't finished yet +wait $PID +# Remove the trap and wait till the app process finishes completely +trap - TERM INT +# We wait again, since the first wait terminates when trap is caught +wait $PID +# Exit with the exit code of the app process +STATUS=$? +exit $STATUS \ No newline at end of file diff --git a/14/s2i/bin/run b/14/s2i/bin/run index ff566f55..c94ac202 100755 --- a/14/s2i/bin/run +++ b/14/s2i/bin/run @@ -20,6 +20,9 @@ run_node() { if [ "$DEV_MODE" == true ]; then echo "Launching via nodemon..." exec nodemon --inspect="$DEBUG_PORT" + elif [ -v NODE_CMD ]; then + echo "launching via init wrapper..." + exec ${STI_SCRIPTS_PATH}/init-wrapper $NODE_CMD else echo "Launching via npm..." exec npm run -d $NPM_RUN From 6b20dccda9ae1a633efe5e364dfc10862596587c Mon Sep 17 00:00:00 2001 From: Costas Papastathis Date: Wed, 21 Sep 2022 19:28:33 +0300 Subject: [PATCH 3/5] fix: adding 14 minimal tested images --- 14-minimal/Dockerfile.rhel8 | 1 + 14-minimal/s2i/bin/init-wrapper | 18 ++++++++++++++++++ 14-minimal/s2i/bin/run | 3 +++ 3 files changed, 22 insertions(+) create mode 100644 14-minimal/s2i/bin/init-wrapper diff --git a/14-minimal/Dockerfile.rhel8 b/14-minimal/Dockerfile.rhel8 index 081daeef..b75686e9 100644 --- a/14-minimal/Dockerfile.rhel8 +++ b/14-minimal/Dockerfile.rhel8 @@ -58,6 +58,7 @@ RUN INSTALL_PKGS="nodejs nodejs-nodemon npm findutils tar" && \ rm -rf /mnt/rootfs/var/cache/* /mnt/rootfs/var/log/dnf* /mnt/rootfs/var/log/yum.* COPY ./s2i/bin/ /usr/libexec/s2i +RUN chmod +x /usr/libexec/s2i/init-wrapper # Copy extra files to the image. COPY ./root/ / diff --git a/14-minimal/s2i/bin/init-wrapper b/14-minimal/s2i/bin/init-wrapper new file mode 100644 index 00000000..24e0d078 --- /dev/null +++ b/14-minimal/s2i/bin/init-wrapper @@ -0,0 +1,18 @@ +#!/bin/bash + +# Overview of how this script works: http://veithen.io/2014/11/16/sigterm-propagation.html +# Set a trap to kill the main app process when this +# init script receives SIGTERM or SIGINT +trap 'kill -s TERM $PID' TERM INT +# Execute the main application in the background +"$@" & +PID=$! +# wait command always terminates when trap is caught, even if the process hasn't finished yet +wait $PID +# Remove the trap and wait till the app process finishes completely +trap - TERM INT +# We wait again, since the first wait terminates when trap is caught +wait $PID +# Exit with the exit code of the app process +STATUS=$? +exit $STATUS \ No newline at end of file diff --git a/14-minimal/s2i/bin/run b/14-minimal/s2i/bin/run index ff566f55..bfbd2c5e 100755 --- a/14-minimal/s2i/bin/run +++ b/14-minimal/s2i/bin/run @@ -20,6 +20,9 @@ run_node() { if [ "$DEV_MODE" == true ]; then echo "Launching via nodemon..." exec nodemon --inspect="$DEBUG_PORT" + elif [ -v NODE_CMD ]; then + echo "launching via init wrapper..." + exec /usr/libexec/s2i/init-wrapper $NODE_CMD else echo "Launching via npm..." exec npm run -d $NPM_RUN From 8998ca98ac76ce30cb834085a7b3e5c08223639d Mon Sep 17 00:00:00 2001 From: Costas Papastathis Date: Wed, 21 Sep 2022 19:29:15 +0300 Subject: [PATCH 4/5] fix: adding 16 tested images --- 16/Dockerfile.c9s | 1 + 16/Dockerfile.fedora | 1 + 16/Dockerfile.rhel8 | 1 + 16/Dockerfile.rhel9 | 1 + 16/s2i/bin/init-wrapper | 18 ++++++++++++++++++ 16/s2i/bin/run | 3 +++ 6 files changed, 25 insertions(+) create mode 100644 16/s2i/bin/init-wrapper diff --git a/16/Dockerfile.c9s b/16/Dockerfile.c9s index 8f2688fe..8628b517 100644 --- a/16/Dockerfile.c9s +++ b/16/Dockerfile.c9s @@ -64,6 +64,7 @@ RUN MODULE_DEPS="make gcc gcc-c++ git openssl-devel" && \ # Copy the S2I scripts from the specific language image to $STI_SCRIPTS_PATH COPY ./s2i/bin/ $STI_SCRIPTS_PATH +RUN chmod +x $STI_SCRIPTS_PATH/init-wrapper # Copy extra files to the image. COPY ./root/ / diff --git a/16/Dockerfile.fedora b/16/Dockerfile.fedora index bdb7988c..bd2296cf 100644 --- a/16/Dockerfile.fedora +++ b/16/Dockerfile.fedora @@ -58,6 +58,7 @@ RUN yum -y module enable nodejs:$NODEJS_VERSION && \ # Copy the S2I scripts from the specific language image to $STI_SCRIPTS_PATH COPY ./s2i/bin/ $STI_SCRIPTS_PATH +RUN chmod +x $STI_SCRIPTS_PATH/init-wrapper # Copy extra files to the image, including help file. COPY ./root/ / diff --git a/16/Dockerfile.rhel8 b/16/Dockerfile.rhel8 index 8c68cca2..81efa2eb 100644 --- a/16/Dockerfile.rhel8 +++ b/16/Dockerfile.rhel8 @@ -65,6 +65,7 @@ RUN yum -y module enable nodejs:$NODEJS_VERSION && \ # Copy the S2I scripts from the specific language image to $STI_SCRIPTS_PATH COPY ./s2i/bin/ $STI_SCRIPTS_PATH +RUN chmod +x $STI_SCRIPTS_PATH/init-wrapper # Copy extra files to the image. COPY ./root/ / diff --git a/16/Dockerfile.rhel9 b/16/Dockerfile.rhel9 index be84a020..786e846f 100644 --- a/16/Dockerfile.rhel9 +++ b/16/Dockerfile.rhel9 @@ -63,6 +63,7 @@ RUN MODULE_DEPS="make gcc gcc-c++ git openssl-devel" && \ # Copy the S2I scripts from the specific language image to $STI_SCRIPTS_PATH COPY ./s2i/bin/ $STI_SCRIPTS_PATH +RUN chmod +x $STI_SCRIPTS_PATH/init-wrapper # Copy extra files to the image. COPY ./root/ / diff --git a/16/s2i/bin/init-wrapper b/16/s2i/bin/init-wrapper new file mode 100644 index 00000000..24e0d078 --- /dev/null +++ b/16/s2i/bin/init-wrapper @@ -0,0 +1,18 @@ +#!/bin/bash + +# Overview of how this script works: http://veithen.io/2014/11/16/sigterm-propagation.html +# Set a trap to kill the main app process when this +# init script receives SIGTERM or SIGINT +trap 'kill -s TERM $PID' TERM INT +# Execute the main application in the background +"$@" & +PID=$! +# wait command always terminates when trap is caught, even if the process hasn't finished yet +wait $PID +# Remove the trap and wait till the app process finishes completely +trap - TERM INT +# We wait again, since the first wait terminates when trap is caught +wait $PID +# Exit with the exit code of the app process +STATUS=$? +exit $STATUS \ No newline at end of file diff --git a/16/s2i/bin/run b/16/s2i/bin/run index ff566f55..c94ac202 100755 --- a/16/s2i/bin/run +++ b/16/s2i/bin/run @@ -20,6 +20,9 @@ run_node() { if [ "$DEV_MODE" == true ]; then echo "Launching via nodemon..." exec nodemon --inspect="$DEBUG_PORT" + elif [ -v NODE_CMD ]; then + echo "launching via init wrapper..." + exec ${STI_SCRIPTS_PATH}/init-wrapper $NODE_CMD else echo "Launching via npm..." exec npm run -d $NPM_RUN From 7479cc11c145a5585072474f4164c212d3c9da55 Mon Sep 17 00:00:00 2001 From: Costas Papastathis Date: Wed, 21 Sep 2022 19:29:53 +0300 Subject: [PATCH 5/5] fix: adding 16 minimal tested images --- 16-minimal/Dockerfile.rhel8 | 1 + 16-minimal/Dockerfile.rhel9 | 1 + 16-minimal/s2i/bin/init-wrapper | 18 ++++++++++++++++++ 16-minimal/s2i/bin/run | 3 +++ 4 files changed, 23 insertions(+) create mode 100644 16-minimal/s2i/bin/init-wrapper diff --git a/16-minimal/Dockerfile.rhel8 b/16-minimal/Dockerfile.rhel8 index c2a58301..54f8aabe 100644 --- a/16-minimal/Dockerfile.rhel8 +++ b/16-minimal/Dockerfile.rhel8 @@ -59,6 +59,7 @@ RUN INSTALL_PKGS="nodejs nodejs-nodemon nodejs-full-i18n npm findutils tar" && \ rm -rf /mnt/rootfs/var/cache/* /mnt/rootfs/var/log/dnf* /mnt/rootfs/var/log/yum.* COPY ./s2i/bin/ /usr/libexec/s2i +RUN chmod +x /usr/libexec/s2i/init-wrapper # Copy extra files to the image. COPY ./root/ / diff --git a/16-minimal/Dockerfile.rhel9 b/16-minimal/Dockerfile.rhel9 index 80eff246..2ba6178e 100644 --- a/16-minimal/Dockerfile.rhel9 +++ b/16-minimal/Dockerfile.rhel9 @@ -57,6 +57,7 @@ RUN INSTALL_PKGS="nodejs nodejs-nodemon nodejs-full-i18n npm findutils tar" && \ rm -rf /mnt/rootfs/var/cache/* /mnt/rootfs/var/log/dnf* /mnt/rootfs/var/log/yum.* COPY ./s2i/bin/ /usr/libexec/s2i +RUN chmod +x /usr/libexec/s2i/init-wrapper # Copy extra files to the image. COPY ./root/ / diff --git a/16-minimal/s2i/bin/init-wrapper b/16-minimal/s2i/bin/init-wrapper new file mode 100644 index 00000000..24e0d078 --- /dev/null +++ b/16-minimal/s2i/bin/init-wrapper @@ -0,0 +1,18 @@ +#!/bin/bash + +# Overview of how this script works: http://veithen.io/2014/11/16/sigterm-propagation.html +# Set a trap to kill the main app process when this +# init script receives SIGTERM or SIGINT +trap 'kill -s TERM $PID' TERM INT +# Execute the main application in the background +"$@" & +PID=$! +# wait command always terminates when trap is caught, even if the process hasn't finished yet +wait $PID +# Remove the trap and wait till the app process finishes completely +trap - TERM INT +# We wait again, since the first wait terminates when trap is caught +wait $PID +# Exit with the exit code of the app process +STATUS=$? +exit $STATUS \ No newline at end of file diff --git a/16-minimal/s2i/bin/run b/16-minimal/s2i/bin/run index ff566f55..bfbd2c5e 100755 --- a/16-minimal/s2i/bin/run +++ b/16-minimal/s2i/bin/run @@ -20,6 +20,9 @@ run_node() { if [ "$DEV_MODE" == true ]; then echo "Launching via nodemon..." exec nodemon --inspect="$DEBUG_PORT" + elif [ -v NODE_CMD ]; then + echo "launching via init wrapper..." + exec /usr/libexec/s2i/init-wrapper $NODE_CMD else echo "Launching via npm..." exec npm run -d $NPM_RUN