Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DPM-421 Update to Enable PaaS Migration #508

Merged
merged 8 commits into from
Jul 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .copilot/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
repository: fft
builder:
name: paketobuildpacks/builder-jammy-full
version: 0.3.339
9 changes: 9 additions & 0 deletions .copilot/image_build_run.sh
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion .env.ci
Original file line number Diff line number Diff line change
Expand Up @@ -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=
19 changes: 14 additions & 5 deletions config/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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")
)
}
PaulWheatcroft marked this conversation as resolved.
Show resolved Hide resolved
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"

Expand Down Expand Up @@ -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
Expand Down
4 changes: 0 additions & 4 deletions config/settings/paas.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"