diff --git a/api/Dockerfile b/api/Dockerfile index 47d4aebe9..5fb8b41fe 100644 --- a/api/Dockerfile +++ b/api/Dockerfile @@ -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"] diff --git a/api/compose/django/dev-entrypoint.sh b/api/compose/django/dev-entrypoint.sh deleted file mode 100755 index 18b36f947..000000000 --- a/api/compose/django/dev-entrypoint.sh +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/sh - -set -e - -exec "$@" diff --git a/api/compose/django/entrypoint.sh b/api/compose/django/entrypoint.sh deleted file mode 100755 index 21137fcbf..000000000 --- a/api/compose/django/entrypoint.sh +++ /dev/null @@ -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 "$@" diff --git a/api/config/settings/common.py b/api/config/settings/common.py index a9258f6a8..315cb3c79 100644 --- a/api/config/settings/common.py +++ b/api/config/settings/common.py @@ -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: diff --git a/changes/changelog.d/entrypoint.misc b/changes/changelog.d/entrypoint.misc new file mode 100644 index 000000000..8cbf72ef9 --- /dev/null +++ b/changes/changelog.d/entrypoint.misc @@ -0,0 +1 @@ +Move database url composition from custom script to django settings diff --git a/dev.yml b/dev.yml index 4ef770323..9e336ddd4 100644 --- a/dev.yml +++ b/dev.yml @@ -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/"