From d8a5169f22969e3607fa76a6beef5261239b243d Mon Sep 17 00:00:00 2001 From: Sajith Sasidharan Date: Tue, 18 Jun 2024 13:52:00 -0500 Subject: [PATCH] Run the app using a helper script All so that uvicorn will use and print the same port that we specified with SDXLC_PORT when running `docker compose up`. --- Dockerfile | 5 +---- entrypoint.sh | 10 ++++++++++ 2 files changed, 11 insertions(+), 4 deletions(-) create mode 100755 entrypoint.sh diff --git a/Dockerfile b/Dockerfile index 97cc9fd..9cd7673 100644 --- a/Dockerfile +++ b/Dockerfile @@ -14,7 +14,4 @@ ENV VIRTUAL_ENV="/opt/venv" RUN pip3 install --no-cache-dir .[wsgi] -EXPOSE 8080 - -ENTRYPOINT ["python3"] -CMD ["-m", "uvicorn", "sdx_lc.app:asgi_app", "--host", "0.0.0.0", "--port", "8080"] +CMD ["./entrypoint.sh"] diff --git a/entrypoint.sh b/entrypoint.sh new file mode 100755 index 0000000..680265b --- /dev/null +++ b/entrypoint.sh @@ -0,0 +1,10 @@ +#! /bin/sh + +# A helper script that can be executed off docker, just so that +# uvicorn will print the right port number. Docker will not do +# environment variable substitution in CMD lines, so this script +# became necessary. + +set -eu + +python3 -m uvicorn sdx_lc.app:asgi_app --host 0.0.0.0 --port "$SDXLC_PORT"