Skipping Cloud Build when deploying from source to Cloud Run

Deploying from source with gcloud run deploy --source lets you skip writing a Dockerfile, though by default it still runs a build. Every time you deploy, Cloud Run uses a virtual machine (VM) in Cloud Build to build a container image and push it to Artifact Registry. However, sometimes you don't even need a build step and wish you could skip it.

With --no-build (in public preview as of November 2026), you can skip Cloud Build and deploy from your local directory in seconds (I measured seven seconds for a minimal service). Cloud Run overlays your uploaded files over a Google-managed base image instead of building a container image.

Here's how to deploy a service with --no-build, how the container is configured and started, and what caveats to watch for.

Prerequisites

To follow along, you need curl, a Google Cloud project with billing enabled, and an authenticated gcloud with the beta component installed (gcloud components install beta).

Set your project ID and target region in your shell:

export PROJECT_ID="YOUR_PROJECT_ID"
export REGION="europe-west1"

With those variables set, enable the Cloud Run Admin API and Cloud Storage API in your project (unlike standard source builds, you don't need to enable Cloud Build or Artifact Registry):

gcloud services enable \
  run.googleapis.com \
  storage.googleapis.com \
  --project="$PROJECT_ID"
Operation "operations/acf.p2-123456789012-f982ccd6-0900-4d39-aecb-7f233bb443a1" finished successfully.

Deploy a Node.js service with --no-build

To test --no-build, you'll create a single-file Node.js HTTP server, measure the deployment time, and verify the response with curl. Start by creating a directory for the service and entering it:

mkdir no-build-app && cd no-build-app

Save the following HTTP server as index.js. It uses Node's built-in node:http module to listen on the port provided by the PORT environment variable and print the running Node.js version:

index.js
const http = require("node:http");

const port = process.env.PORT || 8080;
const server = http.createServer((req, res) => {
  res.writeHead(200, { "Content-Type": "text/plain" });
  res.end(`Deployed directly from source with --no-build (Node ${process.version})\n`);
});

server.listen(port, () => {
  console.log(`Listening on port ${port}`);
});

Because this script only imports a built-in Node.js module, there are no external packages to install (I cover third-party packages in Install dependencies locally before deploying below).

Deploy the service no-build-app from the current directory, prefixing the command with time to measure the wall-clock duration:

time gcloud beta run deploy no-build-app \
  --source=. \
  --no-build \
  --base-image=nodejs24 \
  --no-invoker-iam-check \
  --region="$REGION" \
  --project="$PROJECT_ID"
Deploying sources to Cloud Run service [no-build-app] in project [YOUR_PROJECT_ID] region [europe-west1]
✓ Deploying new service... Done.
  ✓ Uploading sources...
  ✓ Creating Revision...
  ✓ Routing traffic...
Done.
Service [no-build-app] revision [no-build-app-00001-c7l] has been deployed and is serving 100 percent of traffic.
Service URL: https://no-build-app-123456789012.europe-west1.run.app

real    0m11.503s
  • --source=. packages the contents of the current working directory into a .tar.gz archive and uploads it to Cloud Storage.
  • --no-build skips the Cloud Build step (which requires the gcloud beta track while in preview).
  • --base-image=nodejs24 selects the nodejs24 base image from the available base images (other options include, for example, python314, java25, and osonly24).
  • --no-invoker-iam-check disables Cloud Run's IAM invoker check so you can test the public URL directly with curl.

From my machine to europe-west1 (the closest region to me), I measured 11.5 seconds for that first deployment on a fresh project while Cloud Run created the regional run-sources-$PROJECT_ID-$REGION bucket and provisioned the service. Subsequent --no-build updates to the service finished in about seven seconds.

Fetch the service URL and send a request with curl to verify the response:

SERVICE_URL=$(gcloud run services describe no-build-app \
  --region="$REGION" \
  --project="$PROJECT_ID" \
  --format="value(status.url)")

curl "$SERVICE_URL"
Deployed directly from source with --no-build (Node v24.22.1)

Standard source builds compared to --no-build

Now that you've seen --no-build deploy a service, it helps to compare its pipeline against a standard source deployment. Both paths start by uploading an archive of your local files to Cloud Storage, and both end up running your code as a layer on top of the nodejs24 base image:

Side-by-side diagram comparing standard --source deployments with --no-build deployments. On the left, standard --source uploads local source files to a Cloud Storage bucket, runs Buildpacks on a Cloud Build VM, pushes the image to Artifact Registry, and pulls it into a container instance combining application layers and a base image (nodejs24). On the right, --no-build uploads local source files to a Cloud Storage bucket and pulls them directly into Cloud Run, overlaying the uploaded source files over the base image (nodejs24) in a container instance.

The difference is how your files get from Cloud Storage into the container instance. In a standard source deployment, Cloud Build runs Google Cloud's buildpacks to install dependencies and export a container image to Artifact Registry. With --no-build, Cloud Run pulls the archive straight from Cloud Storage when creating the revision and overlays your uploaded files directly over the base image.

Configure --no-build in service YAML

--no-build relies on runtime rebasing, the mechanism behind automatic base image updates where Cloud Run keeps your application files separate from the base image (covered in How runtime rebasing works on Cloud Run). Export the YAML definition for the service no-build-app to inspect how Cloud Run stores that configuration:

gcloud run services describe no-build-app \
  --region="$REGION" \
  --project="$PROJECT_ID" \
  --format=export

The trimmed output below highlights the source and base-image fields on the template:

apiVersion: serving.knative.dev/v1
kind: Service
metadata:
  name: no-build-app
  # ...
spec:
  template:
    metadata:
      annotations:
        run.googleapis.com/base-images:
        '{"":"europe-west1-docker.pkg.dev/serverless-runtimes/google-24/runtimes/nodejs24"}'
        run.googleapis.com/sources:
        '{"":"gs://run-sources-YOUR_PROJECT_ID-europe-west1/services/no-build-app/1794474704.995-a9ac210b.tar.gz#1794474705131670"}'
    spec:
      containers:
      - image: scratch
        # ...
      runtimeClassName: run.googleapis.com/linux-base-image-update

Three settings work together to run your uploaded source files without a container build:

  • The run.googleapis.com/base-images annotation selects the nodejs24 base image for the container, while the runtimeClassName field (run.googleapis.com/linux-base-image-update) enables base image updates so Cloud Run swaps in a patched Ubuntu OS and Node.js 24 runtime automatically.
  • The run.googleapis.com/sources annotation points to the versioned .tar.gz archive (pinned by generation number) in the regional run-sources-YOUR_PROJECT_ID-europe-west1 bucket.
  • The image field is set to scratch, which tells Cloud Run there's no container image to pull from Artifact Registry.

When gcloud creates the .tar.gz source archive, it packages everything in your directory at the root of the archive (preserving symlinks and Linux executable permissions) and checks only .gcloudignore rather than .gitignore (see Filter uploaded files with .gcloudignore below). When creating the revision, Cloud Run extracts those files into /workspace (the container's working directory, rather than /).

Base images detect your startup command

When you deployed the service no-build-app earlier, you didn't specify what command to run to start the app. Instead, language base images such as nodejs24 and python314 include an entrypoint launcher (/usr/bin/app-runner) that inspects the /workspace directory at startup to figure out how to start your app. The launcher looks first for a Procfile (a plain-text file that declares your startup command) and otherwise falls back to standard entrypoints (package.json with a start script, index.js, server.js, main.py, or app.py).

Install dependencies locally before deploying

Because no remote build runs after the upload, every runtime dependency needs to be inside your local directory before you deploy. For Node.js, run npm ci --omit=dev locally so the node_modules directory is populated. For Python, a local .venv directory won't work inside the Linux container because it links against your workstation's Python interpreter; instead, vendor dependencies into a ./vendor directory (pip install --target=./vendor), which the python314 base image adds to Python's module search path (sys.path) by setting PYTHONPATH=./vendor.

Target linux/amd64 for compiled binaries and native extensions

If you're deploying compiled binaries (or dependencies that include compiled binaries), they need to target linux/amd64 because Cloud Run runs all containers on that architecture (see the container runtime contract). That matters when you develop on an Apple Silicon (arm64) Mac, as any binary compiled for macOS and ARM CPUs fails to execute inside an amd64 Linux container.

Cross-compile self-contained binaries locally (for example, GOOS=linux GOARCH=amd64 go build -o server for Go) and deploy them on the osonly24 base image (--base-image=osonly24), which includes Ubuntu 24.04 without a language runtime. Because that base image has no automatic entrypoint detection, specify the binary to run by passing --command=./server or adding a Procfile (web: ./server). When your Python or Node.js dependencies include native extensions, fetch linux/amd64 package builds or install your dependencies inside a local linux/amd64 container.

Filter uploaded files with .gcloudignore

Standard --source deployments respect .gitignore by default, skipping ignored paths such as node_modules, vendor, compiled binaries, and local .env files. With --no-build, gcloud ignores .gitignore and only reads .gcloudignore so your local dependencies and compiled binaries make it into the .tar.gz archive.

That means you need to configure a .gcloudignore file to control what gets uploaded. Add any local files that shouldn't end up in /workspace (such as .git/, .env secret files, a local .venv directory, or test caches) to .gcloudignore, and make sure it doesn't exclude your runtime dependencies (node_modules or vendor).

Deploy from your own Cloud Storage bucket

In the exported service YAML earlier, the run.googleapis.com/sources annotation pointed to a .tar.gz archive in the default run-sources-$PROJECT_ID-$REGION bucket that gcloud created for your upload. You don't have to use that default bucket: you can pass a gs:// URI to --source to deploy a .tar.gz archive from any Cloud Storage bucket you manage. That's useful, for example, when a CI pipeline builds a release archive once and promotes the same artifact from staging to production.

To test this with the service no-build-app, create a bucket in the same region as your service ($REGION):

gcloud storage buckets create "gs://$PROJECT_ID-releases" \
  --location="$REGION" \
  --project="$PROJECT_ID"

From inside the no-build-app directory, package its contents into a .tar.gz archive and upload it to your bucket:

tar -czf /tmp/no-build-app.tar.gz .
gcloud storage cp /tmp/no-build-app.tar.gz \
  "gs://$PROJECT_ID-releases/no-build-app.tar.gz"

Look up the uploaded object's generation number and append #GENERATION to the --source URI when deploying:

GENERATION=$(gcloud storage objects describe \
  "gs://$PROJECT_ID-releases/no-build-app.tar.gz" \
  --format="value(generation)")

gcloud beta run deploy no-build-app \
  --source="gs://$PROJECT_ID-releases/no-build-app.tar.gz#$GENERATION" \
  --no-build \
  --base-image=nodejs24 \
  --region="$REGION" \
  --project="$PROJECT_ID"

When the bucket is in the same project as your Cloud Run service, no extra bucket permissions are needed as long as the user or service account running gcloud can read the archive (your service's runtime service account doesn't need access to the bucket).

You only need to configure bucket permissions when deploying from a bucket in another project, such as a shared release bucket used across staging and production projects. In that setup, grant roles/storage.objectViewer on the shared bucket to both the user or service account running gcloud and the target project's Cloud Run service agent (the Google-managed service account that Cloud Run uses to fetch your source archive when creating a revision):

PROJECT_NUMBER=$(gcloud projects describe "$PROJECT_ID" \
  --format="value(projectNumber)")

gcloud storage buckets add-iam-policy-binding "gs://SHARED_BUCKET_NAME" \
  --member="serviceAccount:service-$PROJECT_NUMBER@serverless-robot-prod.iam.gserviceaccount.com" \
  --role="roles/storage.objectViewer"

When you still need a container build

--no-build fits services that run on a standard language runtime or as a self-contained Linux binary, while heavier customization still requires a container build. You can't install OS packages with apt-get during deployment, though selecting a fuller base image such as google-24-full/nodejs24 covers common system libraries. As of November 2026, --no-build has a few other limitations: it supports only Cloud Run services (not jobs or worker pools) and caps the compressed .tar.gz source archive at 250 MiB.

Clean up

Delete the service no-build-app when you're finished testing:

gcloud run services delete no-build-app \
  --region="$REGION" \
  --project="$PROJECT_ID" \
  --quiet
Deleting [no-build-app]...done.
Deleted service [no-build-app].

Deleting a Cloud Run service leaves its uploaded .tar.gz archives in Cloud Storage, so remove those staged objects as well:

gcloud storage rm --recursive \
  "gs://run-sources-$PROJECT_ID-$REGION/services/no-build-app/"

If you created the custom release bucket earlier, delete that bucket and local tarball too:

gcloud storage rm --recursive "gs://$PROJECT_ID-releases"
rm -f /tmp/no-build-app.tar.gz