How to Deploy Next.js to Google Cloud Run (2026 Guide)
Google Cloud Run is one of the best platforms for deploying Next.js apps in 2026. It's serverless, auto-scaling, and you only pay for actual usage — making it extremely cost-efficient for SaaS products with variable traffic.
This guide covers the full production deployment pipeline: Docker → Container Registry → Cloud Run → GitHub Actions CI/CD.
Why Cloud Run for Next.js?
- Auto-scaling to zero — no cost when traffic is low
- Scale to thousands — handles traffic spikes automatically
- Simple pricing — pay per request, not per server
- Managed infrastructure — no Kubernetes, no server management
- Custom domains + HTTPS — built-in SSL
Prerequisites
- Google Cloud account with billing enabled
gcloudCLI installed and authenticated- Docker installed
- Next.js 16 app
Step 1: Configure Next.js for Standalone Output
Add output: "standalone" to your next.config.js:
const nextConfig = {
output: "standalone",
};
module.exports = nextConfig;
This tells Next.js to bundle everything needed to run the app into .next/standalone — essential for Docker.
Step 2: Create a Multi-Stage Dockerfile
# Stage 1: Install dependencies
FROM node:20-alpine AS deps
WORKDIR /app
COPY package.json package-lock.json ./
RUN npm ci
# Stage 2: Build
FROM node:20-alpine AS builder
WORKDIR /app
COPY --from=deps /app/node_modules ./node_modules
COPY . .
ENV NEXT_TELEMETRY_DISABLED=1
RUN npm run build
# Stage 3: Production runner (minimal image)
FROM node:20-alpine AS runner
WORKDIR /app
ENV NODE_ENV=production
RUN addgroup --system --gid 1001 nodejs
RUN adduser --system --uid 1001 nextjs
COPY --from=builder /app/public ./public
COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./
COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static
USER nextjs
EXPOSE 3000
ENV PORT=3000
ENV HOSTNAME="0.0.0.0"
CMD ["node", "server.js"]
The multi-stage build keeps the final image small — typically under 200MB.
Step 3: Build and Test Locally
docker build -t svbtechlabs-website .
docker run -p 3000:3000 svbtechlabs-website
Open http://localhost:3000 — if it works locally, it'll work on Cloud Run.
Step 4: Push to Google Container Registry
# Authenticate Docker with GCR
gcloud auth configure-docker
# Tag and push
docker tag svbtechlabs-website gcr.io/YOUR_PROJECT_ID/svbtechlabs-website
docker push gcr.io/YOUR_PROJECT_ID/svbtechlabs-website
Step 5: Deploy to Cloud Run
gcloud run deploy svbtechlabs-website \
--image gcr.io/YOUR_PROJECT_ID/svbtechlabs-website \
--platform managed \
--region asia-south1 \
--allow-unauthenticated \
--port 3000 \
--memory 512Mi
Cloud Run will give you a URL like https://svbtechlabs-website-xyz.run.app.
Step 6: Automate with GitHub Actions
Create .github/workflows/deploy.yml:
name: Deploy to Cloud Run
on:
push:
branches: [main]
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: google-github-actions/auth@v2
with:
workload_identity_provider: ${{ secrets.GCP_WORKLOAD_IDENTITY_PROVIDER }}
service_account: ${{ secrets.GCP_SERVICE_ACCOUNT }}
- run: gcloud auth configure-docker --quiet
- run: |
docker build -t gcr.io/${{ secrets.GCP_PROJECT_ID }}/svbtechlabs-website:${{ github.sha }} .
docker push gcr.io/${{ secrets.GCP_PROJECT_ID }}/svbtechlabs-website:${{ github.sha }}
- run: |
gcloud run deploy svbtechlabs-website \
--image gcr.io/${{ secrets.GCP_PROJECT_ID }}/svbtechlabs-website:${{ github.sha }} \
--platform managed \
--region asia-south1 \
--allow-unauthenticated
Every push to main now automatically builds and deploys.
Custom Domain
gcloud run domain-mappings create \
--service svbtechlabs-website \
--domain svbtechlabs.com \
--region asia-south1
Cost Estimate
For a typical early-stage SaaS website (10k–50k page views/month), Cloud Run costs roughly ₹200–₹800/month — significantly cheaper than a dedicated server or VM.
Conclusion
Next.js + Docker + Cloud Run is our production stack at SVB Tech Labs. It's the right balance of simplicity, scalability, and cost-efficiency — and the GitHub Actions pipeline means every merge to main ships automatically.
Want us to set up this stack for your project? SVB Tech Labs offers cloud deployment services.