Skip to content

Commit

Permalink
Merge pull request #409 from VasekPurchart/docker-entrypoint
Browse files Browse the repository at this point in the history
Allow to specify Docker entrypoint using parameters
  • Loading branch information
alcohol committed Apr 7, 2017
2 parents dd146a5 + c408669 commit e2f8b9a
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
33 changes: 33 additions & 0 deletions bin/docker-entrypoint.sh
Original file line number Diff line number Diff line change
@@ -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 "$@"

0 comments on commit e2f8b9a

Please sign in to comment.