diff --git a/.dockerignore b/.dockerignore index 799025e..9391b47 100644 --- a/.dockerignore +++ b/.dockerignore @@ -7,3 +7,5 @@ .pytest_cache .mypy_cache /.idea +.tox +.make-cache \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index 93bf9fb..ebd3ee2 100644 --- a/Dockerfile +++ b/Dockerfile @@ -49,18 +49,21 @@ RUN chown $USER_NAME $STORAGE_DIR ARG EXTRA_PACKAGES="wsgi_cors_middleware" RUN pip install ${EXTRA_PACKAGES} -USER $USER_NAME - WORKDIR /app ENV UWSGI_MODULE "giftless.wsgi_entrypoint" ARG PORT=5000 EXPOSE $PORT +# embed the default port into docker-entrypoint.sh, and make it executable +RUN set -eu ;\ + de=scripts/docker-entrypoint.sh ;\ + sed -i "/^default_port=/s/5000/$PORT/" "$de" ;\ + chmod +x "$de" + +USER $USER_NAME + +ENTRYPOINT ["tini", "--", "scripts/docker-entrypoint.sh"] -ENTRYPOINT ["tini", "uwsgi", "--"] # TODO remove this STOPSIGNAL override after uwsgi>=2.1 STOPSIGNAL SIGQUIT - -CMD ["-s", "127.0.0.1:${PORT}", "-M", "-T", "--threads", "2", "-p", "2", \ - "--manage-script-name", "--callable", "app"] diff --git a/scripts/docker-entrypoint.sh b/scripts/docker-entrypoint.sh new file mode 100644 index 0000000..793cd09 --- /dev/null +++ b/scripts/docker-entrypoint.sh @@ -0,0 +1,9 @@ +#!/bin/sh +default_port=5000 +if [ $# -eq 0 ]; then + # listen on localhost:PORT by default + exec uwsgi -s "127.0.0.1:$default_port" -M -T --threads 2 -p 2 --manage-script-name --callable app +else + # use custom arguments + exec uwsgi "$@" +fi \ No newline at end of file