diff --git a/Dockerfile b/Dockerfile index 4609512..1cda8a0 100644 --- a/Dockerfile +++ b/Dockerfile @@ -20,4 +20,5 @@ COPY --from=build "/sslh/sslh-select" "/usr/local/bin/sslh" RUN apk --no-cache add libconfig pcre2 -ENTRYPOINT [ "/usr/local/bin/sslh" ] +COPY "./container-entrypoint.sh" "/init" +ENTRYPOINT [ "/init" ] diff --git a/container-entrypoint.sh b/container-entrypoint.sh new file mode 100755 index 0000000..cabc783 --- /dev/null +++ b/container-entrypoint.sh @@ -0,0 +1,24 @@ +#!/bin/sh +# SPDX-License-Identifier: GPL2-or-later +# +# Copyright (C) 2023 Olliver Schinagl +# +# A beginning user should be able to docker run image bash (or sh) without +# needing to learn about --entrypoint +# https://github.com/docker-library/official-images#consistency + +set -eu + +bin='sslh' + +# run command if it is not starting with a "-" and is an executable in PATH +if [ "${#}" -le 0 ] || \ + [ "${1#-}" != "${1}" ] || \ + [ -d "${1}" ] || \ + ! command -v "${1}" > '/dev/null' 2>&1; then + entrypoint='true' +fi + +exec ${entrypoint:+${bin}} "${@}" + +exit 0