Skip to content

Commit

Permalink
dev merge
Browse files Browse the repository at this point in the history
  • Loading branch information
bobby-didcoding committed Nov 18, 2024
2 parents 3856995 + 4a3eed9 commit 8707807
Show file tree
Hide file tree
Showing 10 changed files with 125 additions and 7 deletions.
4 changes: 4 additions & 0 deletions .copilot/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
repository: great-core-cms
builder:
name: paketobuildpacks/builder-jammy-full
version: 0.3.339
55 changes: 55 additions & 0 deletions .copilot/image_build_run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
#!/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 BUILD_STEP='true'

# shellcheck disable=SC2046
export $(grep -v '^#' ./config/env/test | xargs)
export APP_ENVIRONMENT='local'
export REDIS_URL='redis://localhost:6379'
export BASE_URL='http://greatcms.trade.great:8020'
export WAGTAILADMIN_BASE_URL='http://greatcms.trade.great:8020'
export OPENSEARCH_PROVIDER='localhost'
export STAFF_SSO_AUTHBROKER_URL='https://www.examole.com'
export AUTHBROKER_CLIENT_ID='debug'
export AUTHBROKER_CLIENT_SECRET='debug'
export SSO_PROXY_LOGIN_URL='http://sso.proxy.trade.great:8004/sso/accounts/login/'
export SSO_PROXY_LOGOUT_URL='http://sso.proxy.trade.great:8004/sso/accounts/logout/?next=http://greatcms.trade.great:8020/thing/'
export SSO_PROXY_SIGNUP_URL='http://sso.proxy.trade.great:8004/sso/accounts/signup/?next=http://greatcms.trade.great:8020/thing/'
export SSO_PROXY_PASSWORD_RESET_URL='http://sso.proxy.trade.great:8004/sso/accounts/password/reset/'
export SSO_PROXY_REDIRECT_FIELD_NAME='next'
export SSO_SESSION_COOKIE='debug_sso_session_cookie'
export SSO_OAUTH2_LINKEDIN_URL='http://sso.proxy.trade.great:8004/sso/accounts/login/via-linkedin/'
export SSO_OAUTH2_GOOGLE_URL='debug'
export GOOGLE_TAG_MANAGER_ID='GTM-1234567'
export UTM_COOKIE_DOMAIN='.trade.great'
export RECAPTCHA_PUBLIC_KEY='test_key'
export RECAPTCHA_PRIVATE_KEY='test_key'
export DIRECTORY_FORMS_API_BASE_URL='http://forms.trade.great:8011'
export DIRECTORY_FORMS_DEFAULT_TIMEOUT='30'
export DIRECTORY_API_CLIENT_BASE_URL='http://api.trade.great:8000'
export DIRECTORY_API_CLIENT_API_KEY='debug'
export DIRECTORY_FORMS_API_API_KEY='01234567890123456789012345678912'
export DIRECTORY_FORMS_API_SENDER_ID='12345678-1234-1234-1234-123456789012'
export EU_EXIT_ZENDESK_SUBDOMAIN='debug'
export CONTACT_ENQUIRIES_AGENT_EMAIL_ADDRESS='[email protected]'
export CONTACT_ECOMMERCE_EXPORT_SUPPORT_AGENT_EMAIL_ADDRESS='[email protected]'
export CONTACT_DIT_AGENT_EMAIL_ADDRESS='[email protected]'
export CONTACT_EVENTS_AGENT_EMAIL_ADDRESS='[email protected]'
export CONTACT_DSO_AGENT_EMAIL_ADDRESS='[email protected]'
export CONTACT_INTERNATIONAL_AGENT_EMAIL_ADDRESS='[email protected]'
export UKEF_CONTACT_AGENT_EMAIL_ADDRESS='[email protected]'
export UKEF_FORM_SUBMIT_TRACKER_URL='http://go.pardot.com/l/590031/2018-08-16/5kj25l'
export MAXMIND_LICENCE_KEY='debug'
export WAGTAILTRANSFER_SECRET_KEY='local-one'
export WAGTAIL_TRANSFER_LOCAL_DEV='False'
export HEALTH_CHECK_TOKEN='debug'

echo "Running image_build_run.sh"

echo "Running collectstatic"
python manage.py collectstatic --noinput
6 changes: 6 additions & 0 deletions .copilot/phases/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/usr/bin/env bash

# Exit early if something goes wrong
set -e

# Add commands below to run as part of the build phase
6 changes: 6 additions & 0 deletions .copilot/phases/install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/usr/bin/env bash

# Exit early if something goes wrong
set -e

# Add commands below to run as part of the install phase
6 changes: 6 additions & 0 deletions .copilot/phases/post_build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/usr/bin/env bash

# Exit early if something goes wrong
set -e

# Add commands below to run as part of the post_build phase
25 changes: 25 additions & 0 deletions .copilot/phases/pre_build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/usr/bin/env bash

# Exit early if something goes wrong
set -e

if [ -f "./.gitmodules" ]; then
echo ".gitmodules file exists. Modifying URLs..."
account_id=$(echo $CODESTAR_CONNECTION_ARN | cut -d':' -f5)
connection_id=$(echo $CODESTAR_CONNECTION_ARN | cut -d'/' -f2)
git_clone_base_url="https://codestar-connections.eu-west-2.amazonaws.com/git-http/$account_id/eu-west-2/$connection_id/uktrade"

git config --global credential.helper '!aws codecommit credential-helper $@'
git config --global credential.UseHttpPath true

sed -i "s|url = [email protected]:uktrade/\(.*\).git|url = $git_clone_base_url/\1.git|g" ./.gitmodules

git submodule update --init --remote --recursive

else
echo ".gitmodules file does not exist. No URLs to update."
fi

# Add commands below to run as part of the pre_build phase

rm ./.python-version
3 changes: 2 additions & 1 deletion Procfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
web: python manage.py collectstatic --noinput && python manage.py migrate --noinput && gunicorn config.wsgi --bind 0.0.0.0:$PORT
web: python manage.py migrate --noinput && gunicorn config.wsgi --bind 0.0.0.0:$PORT
app: python manage.py migrate --noinput && gunicorn config.wsgi --bind 0.0.0.0:$PORT
celery_worker: celery -A config worker -l DEBUG
celery_beat: celery -A config beat -l info -S django
8 changes: 6 additions & 2 deletions config/env.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import os
from typing import Any, Optional
import dj_database_url
from typing import Any, Optional, Union

from dbt_copilot_python.database import database_url_from_env
from dbt_copilot_python.utility import is_copilot
Expand Down Expand Up @@ -397,7 +398,10 @@ class DBTPlatformEnvironment(BaseSettings):
@computed_field(return_type=str)
@property
def database_url(self):
return database_url_from_env('DATABASE_CREDENTIALS')
if self.build_step:
return 'postgres://'

return dj_database_url.parse(database_url_from_env('DATABASE_CREDENTIALS'))

@computed_field(return_type=str)
@property
Expand Down
18 changes: 14 additions & 4 deletions config/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import directory_healthcheck.backends
import dj_database_url
import sentry_sdk
from dbt_copilot_python.database import database_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 @@ -195,9 +196,15 @@
DEFAULT_AUTO_FIELD = 'django.db.models.AutoField'

# Database
# Database
# https://docs.djangoproject.com/en/1.9/ref/settings/#databases
DATABASES = {'default': dj_database_url.config(default=env.database_url)}
# https://docs.djangoproject.com/en/2.2/ref/settings/#databases

if is_copilot():
DATABASES = database_from_env('DATABASE_CREDENTIALS')
DATABASES['default']['ENGINE'] = 'django.db.backends.postgresql'

else:
DATABASES = {'default': env.db()}

DATABASES['default']['ATOMIC_REQUESTS'] = True

REDIS_URL = env.redis_url
Expand Down Expand Up @@ -719,7 +726,10 @@
DNB_API_RENEW_ACCESS_TOKEN_SECONDS_REMAINING = env.dnb_api_renew_access_token_seconds_remaining

# geo location
GEOIP_PATH = os.path.join(ROOT_DIR, 'core/geolocation_data')
if is_copilot():
GEOIP_PATH = '/tmp'
else:
GEOIP_PATH = os.path.join(ROOT_DIR, 'core/geolocation_data')
GEOIP_COUNTRY = 'GeoLite2-Country.mmdb'
GEOIP_CITY = 'GeoLite2-City.mmdb'
MAXMIND_LICENCE_KEY = env.maxmind_licence_key
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"version": "1.0.0",
"description": "",
"scripts": {
"start": "echo start",
"lighthouse": "lhci autorun",
"test": "jest --testPathIgnorePatterns=venv --config jest.config.js",
"test:dev": "jest --watch",
Expand Down

0 comments on commit 8707807

Please sign in to comment.