Skip to content

Latest commit

 

History

History
 
 

pubsub

Cloud Run Pub/Sub Tutorial Sample

This sample shows how to create a service that processes Pub/Sub messages.

Use it with the Cloud Pub/Sub with Cloud Run tutorial.

Run in Google Cloud

Build

docker build --tag pubsub-tutorial:python .

Run Locally

docker run --rm -p 9090:8080 -e PORT=8080 pubsub-tutorial:python

Test

pytest

Note: you may need to install pytest using pip install pytest.

Deploy

# Set an environment variable with your GCP Project ID
export GOOGLE_CLOUD_PROJECT=<PROJECT_ID>

# Submit a build using Google Cloud Build
gcloud builds submit --tag gcr.io/${GOOGLE_CLOUD_PROJECT}/pubsub-tutorial

# Deploy to Cloud Run
gcloud run deploy pubsub-tutorial --image gcr.io/${GOOGLE_CLOUD_PROJECT}/pubsub-tutorial