Guide to Deploy to Google Cloud Run - Short Guide
For more detail refer my blog article at zettabitt.com/silverbullet-cloud-run-deployment-recipe-by-gemini-update-with-concise-guide
PREQUISITES
- Google Cloud Account - Free & has free tier but billing must be enabled. I went into this in detail with Gemini - and check the original documentation and did calculation by hand - and for a single user note app I expect to remain with the free tier limites.
- Start a new project in your account from the Cloud Console console.cloud.google.com
I. Provision Storage
-
Console GUI:
- Go to Cloud Storage > Buckets.
- Click “CREATE BUCKET”.
- Name:
bucket-for-mynotes-app
(or your unique name). - Region:
us-central1
(orus-east1
,us-west1
). - Storage Class: Standard. Access Control: Uniform.
- Click “CREATE”.
- Go to the created buckehttps://zettabitt.com/silverbullet-cloud-run-deployment-recipe-by-gemini-update-with-concise-guidet’s PERMISSIONS tab.
- Click “GRANT ACCESS”.
- New principals: Enter your Cloud Run service account email (e.g.,
[email protected]
). - Role:
Storage Object Admin
. - Click “SAVE”.
-
Cloud Shell CLI:
Bash
# Create GCS bucket gcloud storage buckets create gs://bucket-for-mynotes-app \ --project=silverbullet-notes-app \ --location=us-central1 \ --uniform-bucket-level-access # Grant permissions to Cloud Run servichttps://zettabitt.com/silverbullet-cloud-run-deployment-recipe-by-gemini-update-with-concise-guidee account (replace YOUR_PROJECT_NUMBER) gcloud storage buckets add-iam-policy-binding gs://bucket-for-mynotes-app \ --member="serviceAccount:[email protected]" \ --role="roles/storage.objectAdmin" \ --project=silverbullet-notes-app
II. Deploy Image & Service
-
Cloud Shell CLI (Recommended for initial setup with volume mounts and env vars):
Bash
# Enable Cloud Run API (if not already enabled) gcloud services enable run.googleapis.com # Deploy SilverBullet service gcloud run deploy silverbullet-notes \ --image docker.io/zefhemel/silverbullet:latest \ --project=silverbullet-notes-app \ --region us-central1 \ --platform managed \ --allow-unauthenticated \ --min-instances 0 \ --max-instances 1 \ --cpu 1 \ --memory 512Mi \ --add-volume name=silverbullet-data,type=cloud-storage,bucket=bucket-for-mynotes-app \ --add-volume-mount volume=silverbullet-data,mount-path=/space \ --set-env-vars SB_FOLDER=/space,SB_USER=your_username:your_password \ --port 3000
Replace
your_username:your_password
with your actual SilverBullet credentials. -
Console GUI:
- Go to Cloud Run > Services.
- Click “CREATE SERVICE”.
- Container image URL:
docker.io/zefhemel/silverbullet:latest
. - Service name:
silverbullet-notes
. - Region:
us-central1
. - Authentication: “Allow unauthenticated invocations”.
- Expand “Container(s), volumes, networking, security”.
- Container tab: CPU:
1
vCPU, Memory:512
MiB. Min instances:0
, Max instances:1
. Container port:3000
. - Volumes tab: Add Cloud Storage bucket volume (
silverbullet-data
→bucket-for-mynotes-app
). Add Volume Mount (silverbullet-data
→/space
). - Variables & Secrets tab: Add
SB_FOLDER
=/space
andSB_USER
=your_username:your_password
. - Click “CREATE”.
III. Monitor Usage & Costs
- Console GUI:
- Go to Billing > Reports. Filter by Cloud Run and Cloud Storage.
- Go to Billing > Budgets & alerts.
- Click “CREATE BUDGET”. Set a low budget (e.g., $5) and alert thresholds for “All products”.
IV. Maintain Service & Image
-
Change or Upgrade Image Version (Redeploy):
-
**Cloud Shell CLI:**Bash
gcloud run deploy silverbullet-notes \ --image docker.io/zefhemel/silverbullet:[NEW_VERSION_TAG_OR_LATEST] \ --project=silverbullet-notes-app \ --region us-central1 \ --platform managed \ --allow-unauthenticated \ --min-instances 0 \ --max-instances 1 \ --cpu 1 \ --memory 512Mi \ --add-volume name=silverbullet-data,type=cloud-storage,bucket=bucket-for-mynotes-app \ --add-volume-mount volume=silverbullet-data,mount-path=/space \ --set-env-vars SB_FOLDER=/space,SB_USER=mike:t1nkerB3ll3! \ --port 3000
Replace
[NEW_VERSION_TAG_OR_LATEST]
with the specific version orlatest
. -
Console GUI:
- Go to Cloud Run > Services. Click
silverbullet-notes
. - Click “Edit & Deploy new revision”.
- Update “Container image URL” with the new tag.
- Click “Deploy”.
- Go to Cloud Run > Services. Click
-
-
Manually Stop Service (Delete Service Endpoint):
-
**Cloud Shell CLI:**Bash
gcloud run services delete silverbullet-notes \ --region us-central1 \ --project silverbullet-notes-app \ --quiet for Exploration
-
Console GUI:
- Go to Cloud Run > Services.
- Check the box next to
silverbullet-notes
. - Click “DELETE” at the top.
- Confirm deletion. (Note: Deleting the service endpoint does NOT delete your GCS bucket or its data.)
-
Useful gcloud
Cloud Shell CLI Commands
Bash
# General help for gcloud commands
gcloud COMMAND --help
# List your GCP projects
gcloud projects list
# Set the current project for subsequent commands (replace NAME)
gcloud config set project silverbullet-notes-app
# List your Cloud Storage buckets
gcloud storage buckets list
# List your Cloud Run services
gcloud run services list --region=us-central1 # Specify region
# List service accounts in your project
gcloud iam service-accounts list --project=silverbullet-notes-app
# Get details about a specific Cloud Run service
gcloud run services describe silverbullet-notes --region=us-central1