#
Working towards deploying Django apps to Google Cloud Run, using a Cloud SQL Postgres database and a Cloud Build GitHub Trigger for the continuous deployment. (Also exploring Github actions push deployment as well as AlloyDB as Cloud SQL alternative)
https://hello-world-vlfae7w5dq-nn.a.run.app/ (from GitHub Actions) and https://hello-world-three-vlfae7w5dq-nn.a.run.app (from Cloud Build trigger).
gcloud auth application-default login
gcloud config set project <your project>
During first run through, when you're prompted with an error indication Cloud Build needs to be connected to the GitHub Repo:
Then rerun.
(for initial makemigrations)
Link to curl command to download & install
chmod +x cloud-sql-proxy
Run app locally with cloud sql proxy (note this is for non-windows machines)(https://cloud.google.com/sql/docs/sqlserver/connect-instance-auth-proxy) for other devices
./cloud-sql-proxy $PROJECT_ID:$REGION:$INSTANCE_NAME
Note: This seems to timeout - if you get oauth2: "invalid_grant" "reauth related error (invalid_rapt):
gcloud auth application-default revoke
gcloud auth application-default login
(note here's an article re migration jobs (https://cloud.google.com/blog/topics/developers-practitioners/running-database-migrations-cloud-run-jobs) we may change the way we start this off. )
Change directories into
python manage.py makemigrations
python manage.py makemigrations <app>
python manage.py migrate
python manage.py collectstatic
gcloud builds submit --config cloudbuild.yaml
TODO - waitress and TODO - ci.yaml github actions for pull request
Retrieve URL (also displayed in Service Details page in Cloud Run)
SERVICE_URL=$(gcloud run services describe $SERVICE_NAME --platform managed \
--region northamerica-northeast1 --format "value(status.url)")
gcloud run services update $SERVICE_NAME \
--platform managed \
--region northamerica-northeast1 \
--set-env-vars CLOUDRUN_SERVICE_URL=$SERVICE_URL
** note this step will change once we have the DNS set up
GitHub Actions https://www.hacksoft.io/blog/github-actions-in-action-setting-up-django-and-postgres
Determine when tests should run. Currently, tests run on pull request can we also run these test prior to the Cloud Build (rather than concurently) on push to main? Or should we be locking downthe main branch so pull requests naturally always happen before push to main
Automate/ determine gcloud command for turning on vunerability scanning for Artifact Registry
Connecting GitHub Repo to Cloud Build is also a manual step and requires someone's GitHub account for authorization - Keith is looking into other options/ possibilities
Yakima account (Config Connector for ifrastucture as code set up (IaS) has a misleading name in the IAM console - change this to something more user friendly if we don't know what it is)
Automate approved hosts (Dan got SSL working for DNS so may not need this?)
Docker compose to use context (add deploy folder) & tests!!
CICD options (TODO - add in testing and linting steps)
videos
Database
To look at:
AlloyDB Omni (containerized version - for testing)
Migrations:
Options:
gcloud run jobs update JOB_NAME --image IMAGE_URL
Logging: