From 15454e36868a9f1285a494cd63e3d286c5b5d8ad Mon Sep 17 00:00:00 2001 From: Michael Housh Date: Fri, 7 Nov 2025 13:18:57 -0500 Subject: [PATCH] feat: Adds entrypoint.sh script to docker to allow attaching to a shell inside the container. --- docker/Dockerfile | 4 +++- docker/entrypoint.sh | 19 +++++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) create mode 100644 docker/entrypoint.sh diff --git a/docker/Dockerfile b/docker/Dockerfile index a08ac1d..ffd7155 100755 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -55,6 +55,8 @@ RUN export DEBIAN_FRONTEND=nointeractive DEBCONF_NOINTERACTIVE_SEEN=true && \ && rm -r /var/lib/apt/lists/* COPY --from=build /staging/hpa /usr/local/bin +COPY docker/entrypoint.sh /entrypoint.sh +RUN chmod +x /entrypoint.sh # Setup volumes RUN mkdir /config && \ @@ -67,5 +69,5 @@ RUN mkdir /config && \ VOLUME /config /consults /playbook /template -ENTRYPOINT [ "/usr/local/bin/hpa" ] +ENTRYPOINT [ "/entrypoint.sh" ] CMD ["--help"] diff --git a/docker/entrypoint.sh b/docker/entrypoint.sh new file mode 100644 index 0000000..2d7dad8 --- /dev/null +++ b/docker/entrypoint.sh @@ -0,0 +1,19 @@ +#!/bin/bash + +# Allows to attach to a shell inside the container, otherwise run the 'hpa' script +# with the given arguments. +# +while [[ $# -gt 0 ]]; do + if [[ $1 == "/bin/bash" ]] || [[ $1 == "bash" ]]; then + shift + /bin/bash "$@" + exit $? + elif [[ $1 == "/bin/sh" ]] || [[ $1 == "sh" ]]; then + shift + /bin/sh "$@" + exit $? + else + /usr/local/bin/hpa "$@" + fi + shift +done