From d863f85304902dfed98c5ad289011097ef6b4778 Mon Sep 17 00:00:00 2001 From: "Brian M. Long" Date: Thu, 21 May 2026 20:14:21 -0400 Subject: [PATCH] added ENTRYPOINT_EXEC --- Containerfile | 1 + README.md | 3 +++ src/main/containerd/entrypoint.sh | 9 +++++++-- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/Containerfile b/Containerfile index b0c7ed6..68a2903 100644 --- a/Containerfile +++ b/Containerfile @@ -3,6 +3,7 @@ FROM ${os.image.prefix}${os.image.name}:${os.image.version}${os.image.suffix} ENV SKIP_ENTRYPOINT_SCRIPTS=false ENV VERBOSE=true +ENV ENTRYPOINT_EXEC= # these are effectively immutable; provided to be used by extending images # the entrypoint will re-set these in case they are changed diff --git a/README.md b/README.md index 0fedf88..79032be 100644 --- a/README.md +++ b/README.md @@ -15,6 +15,8 @@ The following tools are available. This image provides an entrypoint script that executes other entrypoint scripts, before executing the `CMD` (if provided). It will execute any executable `.sh` scripts added to the path described by the `CONTAINERD_ENTRYPOINT_PATH` environment variable. It will execute them in default sort order, so the use of numerical prefixes (`00_first.sh` or `99_last.sh`) may be wise. +You may also provide an `ENTRYPOINT_EXEC` to prefix all `CMD` executions in the entrypoint. For instance, you could use `ENTRYPOINT_EXEC=java` so container executions would always be executing `java`. + ### Extensible Certificate Authority This image detects files in the path described by the `CACERT_INSTALL_PATH` environment variable. If a file is found, it will treat it as a certificate and add it to the trusted certificates in all supported contexts. @@ -26,6 +28,7 @@ This image detects files in the path described by the `CACERT_INSTALL_PATH` envi | Name | Default | Mutable | | ---------------------------- | --------------- |:-------:| | `SKIP_ENTRYPOINT_SCRIPTS` | `false` | Yes | +| `ENTRYPOINT_EXEC` | *none* | Yes | | `VERBOSE` | `true` | Yes | | `CONTAINERD_ENTRYPOINT_PATH` | *not important* | No | | `CACERT_INSTALL_PATH` | *not important* | No | diff --git a/src/main/containerd/entrypoint.sh b/src/main/containerd/entrypoint.sh index d605a8a..8b93d8c 100644 --- a/src/main/containerd/entrypoint.sh +++ b/src/main/containerd/entrypoint.sh @@ -35,7 +35,12 @@ if ! find ${CACERT_INSTALL_PATH}/ -maxdepth 0 -empty | read JUNK; then update-ca-certificates fi -if [[ ! -z $1 ]]; then +if [[ -z ${ENTRYPOINT_EXEC} ]]; then + if [[ ! -z $1 ]]; then + ifecho "Executing command ..." + exec "$@" + fi +else ifecho "Executing command ..." - exec "$@" + exec "${ENTRYPOINT_EXEC} $@" fi