How steren/cloud-run-instant-deploy works
Main Components
• Client/Developer Environment:
• Represents the developer’s local system where the code is developed and the gcloud CLI is used.
• Actions: Running commands to perform Cloud Storage uploads and service updates.
• Source Code Repository / Local Application:
• “app” folder containing the application’s files (in this example, “index.js”).
• Google Cloud Storage:
• Acts as the repository where the app’s files are stored after being uploaded.
• This bucket is mounted into the Cloud Run container, replacing the need for local containerized code.
• Cloud Run Service:
• The managed service that runs the application.
• It uses a Cloud Run runtime base image (e.g. nodejs22) and reads the application code from the mounted Cloud Storage bucket.
• Service Configuration (service.yaml):
• Contains deployment configuration, including settings to mount the Cloud Storage bucket and define the runtime image and command.
• Deployment Pipeline (Command Flow):
• Sequence of commands: uploading the app (“gcloud storage cp”), deploying/replacing the service with service.yaml, and updating environment variables to trigger a roll-out of code changes.
Relationships and Interactions
• Developer uses the gcloud CLI (from their local machine) to:
• Upload updated source code to the Cloud Storage bucket.
• Deploy or update the Cloud Run service with the provided service.yaml, which references the Cloud Storage bucket.
• Cloud Run Service mounts the Cloud Storage bucket to locate the application files.
• The runtime base image executes the application code (via “node index.js” for Node.js deployments).
• The update mechanism involves changing an environment variable to force Cloud Run to pickup new revisions when the bucket content is updated.
Architectural Patterns and Design Principles
• Separation of Code and Runtime:
• The code is stored separately in Cloud Storage instead of being embedded in the container image.
• Dynamic Code Loading:
• The Cloud Run container is designed to mount the Cloud Storage bucket at startup, dynamically loading the application code.
• Declarative Deployment:
• The YAML configuration (service.yaml) declares the deployment details including the runtime image and commands.
• Continuous Deployment:
• The provided process allows for quick updates by re-uploading the code and updating the Cloud Run service, which uses environment vars as a revision trigger.
Key Technologies, Frameworks, and Libraries
• Google Cloud Run – for serving the application.
• Google Cloud Storage – for storing and mounting the application code.
• gcloud CLI – to interact with Google Cloud (creating buckets, uploading code, deploying services).
• Node.js – as seen from the “app/index.js” and indicated in the README for the Node.js quickstart.