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