Skip to content

Commit

Permalink
add script execution from docker-entrypoint.d folder (runatlantis#3666)
Browse files Browse the repository at this point in the history
Co-authored-by: PePe Amengual <jose.amengual@gmail.com>
  • Loading branch information
2 people authored and ijames-gc committed Feb 13, 2024
1 parent b0947be commit 41247b1
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,29 @@ if ! whoami > /dev/null 2>&1; then
fi
fi

# If we need to install some tools at entrypoint level, we can add shell scripts
# in folder /docker-entrypoint.d/ with extension .sh and this scripts will be executed
# at entrypount level.
if /usr/bin/find "/docker-entrypoint.d/" -mindepth 1 -maxdepth 1 -type f -print -quit 2>/dev/null | read v; then
echo "/docker-entrypoint.d/ is not empty, will attempt to perform script execition"
echo "Looking for shell scripts in /docker-entrypoint.d/"
find "/docker-entrypoint.d/" -follow -type f -print | sort -V | while read -r f; do
case "$f" in
*.sh)
if [ -x "$f" ]; then
echo "Launching $f";
"$f"
else
# warn on shell scripts without exec bit
echo "Ignoring $f, not executable";
fi
;;
*) echo "Ignoring $f";;
esac
done
echo "Configuration complete; ready for start up"
else
echo "No files found in /docker-entrypoint.d/, skipping"
fi

exec "$@"

0 comments on commit 41247b1

Please sign in to comment.