diff --git a/Dockerfile b/Dockerfile index 56cca8fc..fc95cb88 100644 --- a/Dockerfile +++ b/Dockerfile @@ -41,4 +41,4 @@ VOLUME ["/composer", "/build"] CMD ["--ansi", "-vvv", "build", "/build/satis.json", "/build/output"] -ENTRYPOINT ["/sbin/tini", "--", "/satis/bin/satis"] +ENTRYPOINT ["/satis/bin/docker-entrypoint.sh"] diff --git a/bin/docker-entrypoint.sh b/bin/docker-entrypoint.sh new file mode 100755 index 00000000..8f0fa1e1 --- /dev/null +++ b/bin/docker-entrypoint.sh @@ -0,0 +1,33 @@ +#!/bin/sh +set -e + +isCommand() { + for cmd in \ + "add" \ + "build" \ + "help" \ + "init" \ + "list" \ + "purge" + do + if [ -z "${cmd#"$1"}" ]; then + return 0 + fi + done + + return 1 +} + +# check if the first argument passed in looks like a flag +if [ "$(printf %c "$1")" = '-' ]; then + set -- /sbin/tini -- /satis/bin/satis "$@" +# check if the first argument passed in is satis +elif [ "$1" = 'satis' ]; then + shift + set -- /sbin/tini -- /satis/bin/satis "$@" +# check if the first argument passed in matches a known command +elif isCommand "$1"; then + set -- /sbin/tini -- /satis/bin/satis "$@" +fi + +exec "$@"