diff --git a/.copilot/config.yml b/.copilot/config.yml new file mode 100644 index 00000000..152156bf --- /dev/null +++ b/.copilot/config.yml @@ -0,0 +1,4 @@ +repository: fft +builder: + name: paketobuildpacks/builder-jammy-full + version: 0.3.339 diff --git a/.copilot/image_build_run.sh b/.copilot/image_build_run.sh new file mode 100755 index 00000000..b87c0039 --- /dev/null +++ b/.copilot/image_build_run.sh @@ -0,0 +1,9 @@ +#!/usr/bin/env bash + +# Exit early if something goes wrong +set -e + +# Add commands below to run inside the container after all the other buildpacks have been applied +export $(grep -v '^#' .env.ci | xargs) + +python manage.py collectstatic --noinput diff --git a/.env.ci b/.env.ci index d51c5be9..35544d61 100644 --- a/.env.ci +++ b/.env.ci @@ -3,7 +3,7 @@ SECRET_KEY=used_for_testing ALLOWED_HOSTS="*" DEBUG=False DATABASE_URL=psql://postgres:postgres@db:5432/fido -REDIS_ENDPOINT=redis://redis:6379 +CACHE_ENDPOINT=redis://redis:6379 AUTHBROKER_CLIENT_ID= AUTHBROKER_CLIENT_SECRET= AUTHBROKER_URL= diff --git a/config/settings/base.py b/config/settings/base.py index 1d5b36a8..128b380b 100644 --- a/config/settings/base.py +++ b/config/settings/base.py @@ -13,7 +13,9 @@ import os from pathlib import Path +import dj_database_url import environ +from dbt_copilot_python.database import database_url_from_env from dbt_copilot_python.utility import is_copilot from django.urls import reverse_lazy from django_log_formatter_asim import ASIMFormatter @@ -107,12 +109,19 @@ VCAP_SERVICES = env.json("VCAP_SERVICES", default={}) -if "postgres" in VCAP_SERVICES: - DATABASE_URL = VCAP_SERVICES["postgres"][0]["credentials"]["uri"] +if is_copilot(): + DATABASES = { + "default": dj_database_url.config( + default=database_url_from_env("DATABASE_CREDENTIALS") + ) + } else: - DATABASE_URL = os.getenv("DATABASE_URL") + if "postgres" in VCAP_SERVICES: + DATABASE_URL = VCAP_SERVICES["postgres"][0]["credentials"]["uri"] + else: + DATABASE_URL = os.getenv("DATABASE_URL") -DATABASES = {"default": env.db()} + DATABASES = {"default": env.db()} DEFAULT_AUTO_FIELD = "django.db.models.AutoField" @@ -229,7 +238,7 @@ def FILTERS_VERBOSE_LOOKUPS(): credentials["port"], ) else: - REDIS_URL = env.str("REDIS_ENDPOINT") + REDIS_URL = env("CACHE_ENDPOINT", default=None) # Celery CELERY_BROKER_URL = REDIS_URL diff --git a/config/settings/paas.py b/config/settings/paas.py index b8aa86cb..d2783b53 100644 --- a/config/settings/paas.py +++ b/config/settings/paas.py @@ -12,8 +12,4 @@ if is_copilot(): ALLOWED_HOSTS = setup_allowed_hosts(ALLOWED_HOSTS) - DATABASES["default"] = dj_database_url.config( - default=database_url_from_env("DATABASE_CREDENTIALS") - ) - LOGGING["handlers"]["console"]["formatter"] = "asim"