GeezerVison is showing github.com — Use env variables for database. · msedebay-git/cloud-code-samples@bb13631
File treeExpand file treeCollapse file tree Open diff view settings python/django/python-guestbook
Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: .templates/template_location.json -6Lines changed: 0 additions & 6 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 11 | 11 | "templatePath": "python-guestbook", | 12 | 12 | "templateName": "Python: Guestbook" | 13 | 13 | }, | 14 | | - { | 15 | | - "repoPath": "https://github.com/GoogleCloudPlatform/cloud-code-samples.git", | 16 | | - "directoryPath": "python/django/python-guestbook", | 17 | | - "templatePath": "python-guestbook", | 18 | | - "templateName": "Python: Django: Guestbook" | 19 | | - }, | 20 | 14 | { | 21 | 15 | "repoPath": "https://github.com/GoogleCloudPlatform/cloud-code-samples.git", | 22 | 16 | "directoryPath": "golang/go-hello-world", | |
Collapse file Copy file name to clipboardExpand all lines: python/django/python-guestbook/kubernetes-manifests/guestbook-app.deployment.yaml +9Lines changed: 9 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 30 | 30 | image: python-guestbook | 31 | 31 | ports: | 32 | 32 | - containerPort: 8080 | | 33 | + env: | | 34 | + - name: DATABASE_NAME | | 35 | + value: "postgres" | | 36 | + - name: DATABASE_USER | | 37 | + value: "postgres" | | 38 | + - name: DATABASE_HOST | | 39 | + value: "python-guestbook-db" | | 40 | + - name: DATABASE_PORT | | 41 | + value: "5432" |
Collapse file Copy file name to clipboardExpand all lines: python/django/python-guestbook/kubernetes-manifests/guestbook-app.migration.yaml +9Lines changed: 9 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 22 | 22 | - name: python-guestbook-migration | 23 | 23 | image: python-guestbook | 24 | 24 | command: [ "/bin/sh", "-c", "python manage.py migrate" ] | | 25 | + env: | | 26 | + - name: DATABASE_NAME | | 27 | + value: "postgres" | | 28 | + - name: DATABASE_USER | | 29 | + value: "postgres" | | 30 | + - name: DATABASE_HOST | | 31 | + value: "python-guestbook-db" | | 32 | + - name: DATABASE_PORT | | 33 | + value: "5432" | 25 | 34 | restartPolicy: OnFailure |
Collapse file Copy file name to clipboardExpand all lines: python/django/python-guestbook/src/guestbook/settings.py +10-5Lines changed: 10 additions & 5 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 20 | 20 | # See https://docs.djangoproject.com/en/2.2/howto/deployment/checklist/ | 21 | 21 |
| 22 | 22 | # SECURITY WARNING: keep the secret key used in production secret! | 23 | | -SECRET_KEY = ')#53(g@x1pk#h9$&nb(-*2$y8xbi-(x(=i5n8n5(mr&v^eer!8' | | 23 | +# See https://docs.djangoproject.com/en/2.2/ref/settings/#secret-key | | 24 | +# You can generate a secret key using the following code: | | 25 | +# | | 26 | +# from django.core.management.utils import get_random_secret_key | | 27 | +# get_random_secret_key() | | 28 | +SECRET_KEY = 'CHANGE_ME_PLEASE' | 24 | 29 |
| 25 | 30 | # SECURITY WARNING: don't run with debug turned on in production! | 26 | 31 | DEBUG = True | | 77 | 82 | DATABASES = { | 78 | 83 | 'default': { | 79 | 84 | 'ENGINE': 'django.db.backends.postgresql', | 80 | | - 'NAME': 'postgres', | 81 | | - 'USER': 'postgres', | 82 | | - 'HOST': 'python-guestbook-db', | 83 | | - 'PORT': '5432', | | 85 | + 'NAME': os.getenv('DATABASE_NAME'), | | 86 | + 'USER': os.getenv('DATABASE_USER'), | | 87 | + 'HOST': os.getenv('DATABASE_HOST'), | | 88 | + 'PORT': os.getenv('DATABASE_PORT'), | 84 | 89 | } | 85 | 90 | } | 86 | 91 |
| |
|