Skip to content

Latest commit

 

History

History
89 lines (73 loc) · 3.35 KB

deploy-cloudrun.md

File metadata and controls

89 lines (73 loc) · 3.35 KB

Deploying to Google Cloud Run

This deploys the video-upload web app (app.py) as a public HTTPS URL you can reach from your phone, using the Dockerfile in this repo. Cloud Run's free monthly quota (2M requests, ~180k vCPU-seconds) covers casual personal use at $0 — but it requires a Google Cloud account with billing enabled to create a project at all, even though nothing is charged while you stay in quota.

These setup steps are yours to do (account creation, billing, and login aren't things I can do on your behalf):

  1. Create/sign in to a Google Cloud account at https://console.cloud.google.com
  2. Create a project (or pick an existing one) and enable billing on it.
  3. Set a budget alert (Billing → Budgets & alerts) — e.g. alert at $1 — so an unexpected spike can't quietly cost real money.
  4. Install the gcloud CLI: https://cloud.google.com/sdk/docs/install
  5. Run gcloud init and gcloud auth login, and select your project.
  6. Enable the required APIs once:
    gcloud services enable run.googleapis.com cloudbuild.googleapis.com

Choose a password and deploy

Pick a password to gate the app with (anyone with the URL could otherwise upload videos and burn your quota). From the repo root:

gcloud run deploy filters-app \
  --source . \
  --region us-central1 \
  --allow-unauthenticated \
  --memory 2Gi \
  --cpu 2 \
  --timeout 300 \
  --min-instances 0 \
  --max-instances 2 \
  --set-env-vars APP_PASSWORD=choose-a-password-here,MAX_VIDEO_SECONDS=30

--source . builds the Dockerfile in this repo via Cloud Build and deploys it — no separate docker build/docker push step needed. --max-instances 2 caps how many concurrent instances can spin up, which bounds worst-case spend if the URL ever gets hammered. MAX_VIDEO_SECONDS=30 rejects longer uploads up front to keep each request's processing time (and compute cost) predictable; raise or drop it if you want longer clips.

APP_SECRET_KEY (used to sign the login session cookie) is optional — if you skip it, a random key is generated per instance restart, which just means you'd need to log in again after a cold start. To keep sessions stable across restarts, generate one and add it to --set-env-vars:

python -c "import secrets; print(secrets.token_hex(32))"

For anything beyond casual personal use, prefer Secret Manager over a plain env var for the password:

echo -n "choose-a-password-here" | gcloud secrets create app-password --data-file=-
gcloud run deploy filters-app \
  --source . \
  --region us-central1 \
  --allow-unauthenticated \
  --memory 2Gi \
  --cpu 2 \
  --timeout 300 \
  --min-instances 0 \
  --max-instances 2 \
  --set-secrets APP_PASSWORD=app-password:latest \
  --set-env-vars MAX_VIDEO_SECONDS=30

The command prints a *.run.app URL when it finishes — that's your public site. Visiting it should redirect to /login.

Updating after a code change

Re-run the same gcloud run deploy command (env vars/secrets you've already set are preserved unless you override them).

Costs

Everything above fits inside Cloud Run's perpetual free tier for occasional personal use. If usage grows, current (2026) pricing beyond the free quota is roughly $0.000024/vCPU-second and $0.0000025/GiB-second of memory while an instance is handling requests — check https://cloud.google.com/run/pricing for current rates.