new·The score now tells you which way it movedA brain's exam only ever grows: its own material writes questions, and so does every question a real caller asked and did not get answered. The score is a percentage over that growing set, so a brain that learned more could post a smaller number — and this week three did. One of them answered two MORE questions than the week before and showed eighteen points less. Printed as a single percentage, that reads as decline to a reader and as punishment to anyone who contributes material.all news →
mozg.beta
Sign in

Bun · all subjects

deployment/google-cloud-run

7 notes, read out of this brain and free to use. Each one was extracted from a source and is re-checked against its exam.

Google Cloud Run deployment prerequisites

To deploy a Bun application on Google Cloud Run, you need: a Bun application ready for deployment, a Google Cloud account with billing enabled, and Google Cloud CLI installed and configured.

Initialize Google Cloud CLI for deployment

Run `gcloud init` to initialize the Google Cloud CLI, which logs you in and prompts you to select an existing project or create a new one.

Enable APIs for Cloud Run deployment

Enable the required APIs with `gcloud services enable run.googleapis.com cloudbuild.googleapis.com`. Cloud Run runs the containerized app, while Cloud Build builds and packages it.

Grant IAM permissions for Cloud Run deployment

Grant the Compute Engine service account permission to build and deploy images by running: `gcloud projects add-iam-policy-binding $PROJECT_ID --member=serviceAccount:$PROJECT_NUMBER-compute@developer.gserviceaccount.com --role=roles/run.builder`

Dockerfile for Bun application on Cloud Run

A Dockerfile for deploying a Bun application to Google Cloud Run should: start with `FROM oven/bun:latest`, copy `package.json` and `bun.lock` into the container, run `bun install --production --frozen-lockfile`, copy the application files, and use `CMD ["bun", "index.ts"]` (or `CMD ["bun", "run", "start"]` if using a start script). If the app has no dependencies, the install step can be omitted.

.dockerignore file for Bun Cloud Run deployment

Create a `.dockerignore` file to exclude files and directories from the container image. Recommended exclusions: node_modules, Dockerfile*, .dockerignore, .git, .gitignore, README.md, LICENSE, .vscode, .env, and any other unnecessary files. This keeps builds faster and smaller.

Deploy Bun application to Cloud Run from source

Deploy a Bun application from the directory containing the Dockerfile using: `gcloud run deploy <service-name> --source . --region=<region> --allow-unauthenticated`. Replace `<service-name>` with your desired service name and `<region>` with your preferred region (e.g., us-west1), or omit the `--region` flag to select interactively. This command creates an Artifact Registry Docker repository named `cloud-run-source-deploy` in the specified region if it doesn't exist.

Give your agent this brain