From 01f97154adc7fb46d36a7eea71d6c92b59e630d0 Mon Sep 17 00:00:00 2001 From: Phil Crockett Date: Tue, 5 Sep 2023 12:01:14 +0200 Subject: [PATCH] handle TTY sessions for better debuggability (#3) --- entrypoint.sh | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/entrypoint.sh b/entrypoint.sh index 03f4d00..87fe186 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -6,6 +6,20 @@ if [ "${#}" -eq 0 ]; then exit 1 fi +if tty --silent; then + # the user is likely trying to run an interactive shell in the container. example commands that + # might get us here: + # + # * docker compose run my-service /bin/bash + # * docker run --rm -it my-image /bin/bash + # * heroku run --app my-app -- /bin/bash + # + # we don't want to wait for the upstream app to start, etc. just execute the command (ex: + # `/bin/bash` above) and exit. + "${@}" + exit ${?} +fi + APP_PORT="${APP_PORT:-2000}" if [ "${APP_PORT}" -eq "${PORT}" ]; then