Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/avoid-npm-start' into command-op…
Browse files Browse the repository at this point in the history
…tion-on-14-and-16
  • Loading branch information
pacostas committed Oct 17, 2022
2 parents c6edecd + 7479cc1 commit 72896d2
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 0 deletions.
1 change: 1 addition & 0 deletions 18/Dockerfile.c8s
Original file line number Diff line number Diff line change
Expand Up @@ -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/ /
Expand Down
1 change: 1 addition & 0 deletions 18/Dockerfile.fedora
Original file line number Diff line number Diff line change
Expand Up @@ -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/ /
Expand Down
18 changes: 18 additions & 0 deletions 18/s2i/bin/init-wrapper
Original file line number Diff line number Diff line change
@@ -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
3 changes: 3 additions & 0 deletions 18/s2i/bin/run
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 72896d2

Please sign in to comment.