Skip to main content

Deploy a Node.js app

This guide covers deploying a Node.js backend to Cloud Run with advncd. The same steps apply to Express, Fastify, NestJS, Hono, and Koa.


Prerequisites

  • advncd installed and authenticated (advncd login)
  • A GCP project configured (advncd init)
  • Required APIs enabled (advncd apis enable)

1. Check detection

From your project root:

advncd detect --path .

Expected output for a Node.js app:

runtime:              nodejs
build strategy: buildpacks
port: 8080
confidence: high
warnings: none
service name proposal: my-api

If confidence is not high, check the warnings. Common causes:

  • Missing package.json — add one with a start script
  • Port not inferred — set it explicitly in advncd.yaml

2. Make sure your app listens on the right port

Cloud Run injects the PORT environment variable. Your app must read it:

const port = process.env.PORT || 8080;
app.listen(port, '0.0.0.0', () => {
console.log(`Server running on port ${port}`);
});

3. Deploy

advncd deploy --path . --name my-api

advncd will:

  1. Build the app via Cloud Buildpacks (no Dockerfile needed)
  2. Push the image to Artifact Registry
  3. Deploy to Cloud Run and enable public access
  4. Print the service URL

4. Verify

advncd services describe my-api

Or open it directly:

advncd services open my-api

advncd.yaml (optional)

Pin your config so you don't need flags:

version: 1

service:
name: my-api
port: 8080

deploy:
project: my-gcp-project
region: europe-west1
allow_service_rename: false

build:
strategy: buildpacks

runtime:
family: nodejs
framework: express

With this file in the project root, just run:

advncd deploy

Environment variables

advncd auto-picks .env.production.env.prod.env in that order.

To pass extra variables at deploy time, set them in the env block in advncd.yaml:

env:
required:
- DATABASE_URL
optional:
- SENTRY_DSN

Multiple services from one repo

advncd deploy --path ./apps/web  --name web-frontend
advncd deploy --path ./apps/api --name backend-api

Each gets its own Cloud Run service, independently scalable.