Skip to main content
Peermetrics can be deployed to Google App Engine by deploying each service independently. Both the api and web repositories contain an app_engine.yaml file that configures the App Engine service.
The app_engine.yaml files live in the individual service repositories, not in the main peermetrics/peermetrics repository. Find them at:

Prerequisites

  • A Google Cloud project with App Engine enabled
  • The Google Cloud CLI (gcloud) installed and authenticated
  • A PostgreSQL database accessible from App Engine (e.g. Cloud SQL)
  • A Redis instance accessible from App Engine (e.g. Memorystore)

Overview

Because Peermetrics splits ingestion (API) and visualization (web) into two services, both must be deployed separately to App Engine. Each deployment reads its configuration from environment variables defined in the respective app_engine.yaml.

Deployment steps

1

Clone the service repositories

git clone https://github.com/peermetrics/api
git clone https://github.com/peermetrics/web
2

Configure the API service

Edit api/app_engine.yaml to set your environment variables. At minimum, configure the database connection, Redis, and the secret values:
  • SECRET_KEY — Django secret key
  • INIT_TOKEN_SECRET — used to generate JWT tokens
  • SESSION_TOKEN_SECRET — used to encrypt session cookies
  • DEFAULT_ADMIN_PASSWORD — password for the auto-created admin account
  • DATABASE_HOST, DATABASE_USER, DATABASE_PASSWORD, DATABASE_NAME
  • REDIS_HOST
  • WEB_DOMAIN — the domain where the web service will be accessible
Do not commit production secrets to version control. Use App Engine environment variables or Secret Manager references instead.
3

Deploy the API service

cd api
gcloud app deploy app_engine.yaml
4

Configure the web service

Edit web/app_engine.yaml and set:
  • SECRET_KEY
  • DEFAULT_ADMIN_PASSWORD — must match the value set in the API service
  • API_ROOT — the public URL of your deployed API service, ending with /v1
  • DATABASE_HOST, DATABASE_USER, DATABASE_PASSWORD, DATABASE_NAME
5

Deploy the web service

cd web
gcloud app deploy app_engine.yaml
6

Run database migrations

After the API service is deployed, run the Django migrations. You can trigger this via the App Engine console, a Cloud Run job, or by using App Engine’s built-in task queue.If the api service exposes a management endpoint, you can also open a shell via Cloud Shell and run:
gcloud app instances ssh <instance-id> --service=api --version=<version>
# inside the instance:
python manage.py migrate

Optional Google Cloud integrations

The API service supports optional integrations that are useful when running on Google Cloud. Enable them by setting the following environment variables in app_engine.yaml:
VariableValueDescription
USE_GOOGLE_CLOUD_LOGGINGTrueRoute Django logs to Google Cloud Logging
USE_GOOGLE_TASK_QUEUETrueUse Cloud Tasks instead of local task processing
GOOGLE_TASK_QUEUE_NAMEe.g. queue-1Name of the Cloud Tasks queue
APP_ENGINE_LOCATIONe.g. us-east1App Engine region for Cloud Tasks
TASK_QUEUE_DOMAINe.g. https://api.example.com/Domain used when enqueuing tasks

Next steps

Build docs developers (and LLMs) love