Install the gcloud CLI, https://cloud.google.com/sdk/docs/install
Deploy:
PROJECT=my-gcp-project-name
gcloud app deploy --project $PROJECT .
| runtime: python312 | |
| automatic_scaling: | |
| max_instances: 2 |
| runtime: python313 | |
| handlers: | |
| - url: /.* | |
| script: auto | |
| secure: always | |
| automatic_scaling: | |
| max_instances: 1 |
| """ | |
| Install: gcloud SDK, and configure application default credentials. | |
| https://cloud.google.com/sdk/gcloud/reference/auth/application-default/login | |
| Install: python -m pip install click google-api-python-client google-cloud-storage | |
| Usage: | |
| main.py versions --project=my-proj | |
| main.py download --project=my-proj --version=my-version --service=default |
| # Nginx will listen on localhost:8080, serving static assets and doing gzip compression. | |
| services: | |
| app: | |
| image: python:3.13-alpine | |
| ports: ["8000:8000"] | |
| command: ["python", "-m", "http.server"] | |
| nginx: | |
| build: |
Install the gcloud CLI, https://cloud.google.com/sdk/docs/install
Deploy:
PROJECT=my-gcp-project-name
gcloud app deploy --project $PROJECT .
| steps: | |
| - id: build-temp-image | |
| name: gcr.io/cloud-builders/docker | |
| script: | | |
| #!/usr/bin/env bash | |
| set -o errexit -o nounset -o pipefail | |
| # A custom image with Python + cloud-sql-proxy. We can then use this for | |
| # connecting to the database when running django commands. |
| # You need to enable `app_engine_apis: true` to use the built-in memcache | |
| # service on App Engine standard. | |
| # https://github.com/GoogleCloudPlatform/appengine-python-standard | |
| # | |
| # Then configure a custom cache backend. | |
| # https://docs.djangoproject.com/en/5.1/ref/settings/#backend | |
| import logging | |
| from django.core.cache.backends.memcached import BaseMemcachedCache |
| # For App Engine. | |
| runtime: python311 |
| # Setup for Ubuntu 20.04 | |
| # ====================== | |
| # Install Nomad, Consul, Docker | |
| # ----------------------------- | |
| # GPG keys for Nomad and Docker. | |
| curl -fsSL https://apt.releases.hashicorp.com/gpg | sudo apt-key add - | |
| curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add - |
| runtime: python38 |