chore: Move database url composition from custom script to django settings

Part-of: <https://dev.funkwhale.audio/funkwhale/funkwhale/-/merge_requests/2313>
This commit is contained in:
Georg Krause 2023-01-10 13:20:14 +01:00 committed by Marge
parent 165011ff6d
commit 62653a2f62
6 changed files with 10 additions and 25 deletions

View File

@ -112,5 +112,4 @@ RUN set -eux; \
ENV CACHE_URL="redis://redis:6379/0"
ENV CELERY_BROKER_URL="redis://redis:6379/0"
ENTRYPOINT ["./compose/django/entrypoint.sh"]
CMD ["./compose/django/server.sh"]

View File

@ -1,5 +0,0 @@
#!/bin/sh
set -e
exec "$@"

View File

@ -1,17 +0,0 @@
#!/bin/sh
set -e
# This entrypoint is used to play nicely with the current cookiecutter configuration.
# Since docker-compose relies heavily on environment variables itself for configuration, we'd have to define multiple
# environment variables just to support cookiecutter out of the box. That makes no sense, so this little entrypoint
# does all this for us.
if [ -z "$DATABASE_URL" ]; then
# the official postgres image uses 'postgres' as default user if not set explicitly.
if [ -z "$POSTGRES_ENV_POSTGRES_USER" ]; then
export POSTGRES_ENV_POSTGRES_USER=postgres
fi
export DATABASE_URL="postgres://$POSTGRES_ENV_POSTGRES_USER:$POSTGRES_ENV_POSTGRES_PASSWORD@postgres:5432/$POSTGRES_ENV_POSTGRES_USER"
fi
exec "$@"

View File

@ -369,7 +369,15 @@ vars().update(EMAIL_CONFIG)
# DATABASE CONFIGURATION
# ------------------------------------------------------------------------------
# See: https://docs.djangoproject.com/en/dev/ref/settings/#databases
DATABASE_URL = env.db("DATABASE_URL")
DATABASE_USER = env.str("POSTGRES_ENV_POSTGRES_USER", "postgres")
DATABASE_PASSWORD = env.str("POSTGRES_ENV_POSTGRES_PASSWORD")
DATABASE_NAME = env.str("POSTGRES_ENV_POSTGRES_USER")
DATABASE_HOST = "postgres"
DATABASE_PORT = 5432
DATABASE_URL = env.db(
"DATABASE_URL",
f"postgres://{DATABASE_USER}:{DATABASE_PASSWORD}@{DATABASE_HOST}:{DATABASE_PORT}/{DATABASE_NAME}",
)
"""
The URL used to connect to the PostgreSQL database. Examples:

View File

@ -0,0 +1 @@
Move database url composition from custom script to django settings

View File

@ -54,7 +54,6 @@ services:
args:
install_dev_deps: 1
image: funkwhale-api
entrypoint: compose/django/dev-entrypoint.sh
command: >
bash -c "python manage.py collectstatic --no-input
&& uvicorn --reload config.asgi:application --host 0.0.0.0 --port 5000 --reload-dir config/ --reload-dir=funkwhale_api/"