Last active
September 22, 2018 20:28
-
-
Save the-vampiire/fffd1b5a39dc849b132b50ad416ced48 to your computer and use it in GitHub Desktop.
Django + PostgreSQL Google Cloud Flexible App Engine deployment template
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| runtime: python | |
| # the PROJECT-DIRECTORY is the one with settings.py and wsgi.py | |
| entrypoint: gunicorn -b :$PORT PROJECT-DIRECTORY.wsgi # specific to a GUnicorn HTTP server deployment | |
| env: flex # for Google Cloud Flexible App Engine | |
| # any environment variables you want to pass to your application. | |
| # accessible through os.environ['VARIABLE_NAME'] | |
| env_variables: | |
| # the secret key used for the Django app (from PROJECT-DIRECTORY/settings.py) | |
| SECRET_KEY: 'DJANGO-SECRET-KEY' | |
| DEBUG: 'False' # always False for deployment | |
| # everything after /cloudsql/ can be found by entering >> gcloud sql instances describe DATABASE-NAME << in your Terminal | |
| # the DATABASE-NAME is the name you gave your project's PostgreSQL database | |
| # the second line from the describe output called connectionName can be copied and pasted after /cloudsql/ | |
| DB_HOST: '/cloudsql/PROJECT-ID:COMPUTE-ENGINE-ZONE:DATABASE-NAME' | |
| DB_PORT: '5432' # PostgreSQL port | |
| DB_NAME: 'DATABASE-NAME' | |
| DB_USER: 'DATABASE-USERNAME' # either 'postgres' (default) or one you created on the PostgreSQL instance page | |
| DB_PASSWORD: 'DATABASE-PASSWORD' | |
| STATIC_URL: 'https://storage.googleapis.com/BUCKET-NAME/static/' # this is the url that you sync static files to | |
| handlers: | |
| - url: /static | |
| static_dir: static | |
| beta_settings: | |
| # from command >> gcloud sql instances describe DATABASE-NAME << | |
| cloud_sql_instances: PROJECT-ID:COMPUTE-ENGINE-ZONE:DATABASE-NAME | |
| runtime_config: | |
| python_version: 3 # enter your Python version BASE ONLY here. Enter 2 for 2.7.9 or 3 for 3.6.4 |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
from my article on deploying a django project to google cloud