Skip to content

Commit

Permalink
fix(database): use dj_database_url for database config (#234)
Browse files Browse the repository at this point in the history
* fix: use dj_database_url for database config

* fix: remove unused envs
  • Loading branch information
ollz272 authored Apr 30, 2023
1 parent 6ed1e7b commit be133ff
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 32 deletions.
5 changes: 1 addition & 4 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,7 @@ jobs:
- name: Migrate
run: poetry run ./manage.py migrate --settings="project.settings.production"
env:
DJANGO_DATABASE_NAME: ${{ secrets.DJANGO_DATABASE_NAME }}
DJANGO_DATABASE_USER: ${{ secrets.DJANGO_DATABASE_USER }}
DJANGO_DATABASE_PASSWORD: ${{ secrets.DJANGO_DATABASE_PASSWORD }}
DJANGO_DATABASE_HOST: ${{ secrets.DJANGO_DATABASE_HOST }}
DATABASE_URL: ${{ secrets.DATABASE_URL }}
DJANGO_SETTINGS_MODULE: project.settings.production
ALLOWED_HOSTS: 127.0.0.1
CSRF_TRUSTED_ORIGINS: http://127.0.0.1
Expand Down
1 change: 1 addition & 0 deletions .idea/garden-server.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 3 additions & 10 deletions project/settings/production.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import dj_database_url

from .base import *

ALLOWED_HOSTS = os.environ.get("ALLOWED_HOSTS", "").split(" ")
Expand All @@ -8,16 +10,7 @@
if os.environ.get("DEBUG"):
DEBUG = True

DATABASES = {
"default": {
"ENGINE": "timescale.db.backends.postgis",
"NAME": os.environ.get("DJANGO_DATABASE_NAME", "gardenserver_django"),
"USER": os.environ.get("DJANGO_DATABASE_USER"),
"PASSWORD": os.environ.get("DJANGO_DATABASE_PASSWORD"),
"PORT": "5432",
"HOST": os.environ.get("DJANGO_DATABASE_HOST"),
},
}
DATABASES = {"default": dj_database_url.config()}


# Cache sessions for optimum performance
Expand Down
19 changes: 2 additions & 17 deletions services/web_service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,26 +38,16 @@ spec:
secretKeyRef:
key: latest
name: DJANGO_SETTINGS_MODULE
- name: DJANGO_DATABASE_PASSWORD
- name: DATABASE_URL
valueFrom:
secretKeyRef:
key: latest
name: DJANGO_DATABASE_PASSWORD
- name: DJANGO_DATABASE_HOST
valueFrom:
secretKeyRef:
key: latest
name: DJANGO_DATABASE_HOST
name: DATABASE_URL
- name: DJANGO_SUPERUSER_EMAIL
valueFrom:
secretKeyRef:
key: latest
name: DJANGO_SUPERUSER_EMAIL
- name: DJANGO_DATABASE_NAME
valueFrom:
secretKeyRef:
key: latest
name: DJANGO_DATABASE_NAME
- name: DJANGO_SUPERUSER_USERNAME
valueFrom:
secretKeyRef:
Expand All @@ -78,11 +68,6 @@ spec:
secretKeyRef:
key: latest
name: SECRET_KEY
- name: DJANGO_DATABASE_USER
valueFrom:
secretKeyRef:
key: latest
name: DJANGO_DATABASE_USER
- name: DJANGO_SUPERUSER_PASSWORD
valueFrom:
secretKeyRef:
Expand Down

0 comments on commit be133ff

Please sign in to comment.