Sign inSign up

tuyojr/hello-image-app

By tuyojr

•Updated 9 months ago

Cloud Run Hello + DB Test Image

Image
Web servers
Databases & storage
0

129

tuyojr/hello-image-app repository overview

⁠Cloud Run Hello + DB Test Image

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.

⁠What the image does

  • / 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 success
    • 500 with DB connection test: failed on failure

No secrets are logged or returned in responses.

⁠Environment variables

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)

⁠Local usage (Docker Compose)

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-test

⁠Cloud Run usage

Deploy 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.

⁠Credits

This image is adapted from the Cloud Run Hello World sample:

Tag summary

Content type

Image

Digest

sha256:97711c0b1…

Size

48.9 MB

Last updated

9 months ago

docker pull tuyojr/hello-image-app:v1.0.1