Cloud Run Hello + DB Test Image
129
This repository builds a minimal Python container image designed for Google Cloud Run services. It is based on the Cloud Run “Hello World” sample and adds a /db-test endpoint to validate Postgres connectivity.
/ returns a simple “Hello NAME!” response./db-test performs a short Postgres connection test using environment variables, logs success/failure, and returns:
200 OK with DB connection test: success on success500 with DB connection test: failed on failureNo secrets are logged or returned in responses.
The container expects the following variables at runtime:
DB_HOST (required)DB_NAME (required)DB_USER (required)DB_PASSWORD (required)Optional:
NAME (defaults to World)PORT (defaults to 8080)docker-compose.yml
services:
db:
image: postgres:16
restart: always
shm_size: 128mb
environment:
POSTGRES_PASSWORD: test
POSTGRES_USER: user
POSTGRES_DB: test-db
ports:
- "5432:5432"
app:
image: tuyojr/hello-image-app:v1.0.1
restart: always
depends_on:
- db
ports:
- "8080:8080"
environment:
NAME: "Local"
DB_HOST: db
DB_NAME: test-db
DB_USER: user
DB_PASSWORD: test
docker compose up
Then open:
http://localhost:8080/http://localhost:8080/db-testDeploy to Cloud Run and set environment variables (via Terraform or gcloud). The service must be attached to a VPC connector if you are connecting to a private Cloud SQL instance.
This image is adapted from the Cloud Run Hello World sample:
Content type
Image
Digest
sha256:97711c0b1…
Size
48.9 MB
Last updated
9 months ago
docker pull tuyojr/hello-image-app:v1.0.1