docker: Add entrypoint.sh

Apparently I forgot to add this file in previous commits - the initial
shape is provided by @valberg, I added some defaults for
POSTGRES_{HOST,PORT}.
This commit is contained in:
Thomas Jespersen 2021-02-09 22:48:53 +01:00
parent 9093b393f1
commit 6857bc69b5
Signed by untrusted user: laumann
GPG key ID: 85C9FB9C4405C282
2 changed files with 22 additions and 1 deletions

View file

@ -39,5 +39,5 @@ RUN mkdir /app/static && chown www:www /app/static
ARG BUILD ARG BUILD
ENV BUILD ${BUILD} ENV BUILD ${BUILD}
ENTRYPOINT ["/entrypoint.sh"] ENTRYPOINT ["./entrypoint.sh"]
CMD ["uvicorn", "config.asgi:application", "--host", "0.0.0.0", "--port", "8080", "--workers", "3", "--lifespan", "off"] CMD ["uvicorn", "config.asgi:application", "--host", "0.0.0.0", "--port", "8080", "--workers", "3", "--lifespan", "off"]

21
entrypoint.sh Executable file
View file

@ -0,0 +1,21 @@
#!/bin/sh
echo "Waiting for postgres..."
POSTGRES_PORT=${POSTGRES_PORT:-5432}
POSTGRES_HOST=${POSTGRES_HOST:-localhost}
while ! nc -z "$POSTGRES_HOST" "$POSTGRES_PORT"; do
sleep 0.1
done
echo "PostgreSQL started"
# Only migrate and collectstatic if we are NOT in development
if [ -z "$DEBUG" ]; then
python manage.py migrate
python manage.py collectstatic --no-input;
fi
exec "$@"