Angular Universal on Google Cloud Run Deploy to Angular Universal to Google Cloud Run and connect it to Firebase Hosting

This lesson is available for PRO members or as a single course purchase. Sign-in and choose a plan below.


*Enrollment provides full access to this course (and updates) for life.

Or Signup for Unlimited PRO Access

Deploy Angular Universal to Google Cloud Run and connect it to Firebase hosting. Make sure Google Cloud SDK is installed on your local machine. Cloud Run is a solid choice, because it gives you a fully-managed “serverless” runtime using a Docker container - not to mention a generous free tier.

Dockerize the App

file_type_docker Dockerfile
FROM node:10
WORKDIR usr/src/app
COPY package*.json ./
RUN npm install
# Copy local angular/nest code to the container
COPY . .
# Build production app
RUN npm run build:ssr
CMD ["npm", "run", "serve:ssr"]

Register the Container on GCP

command line
gcloud config set project <PROJECT_ID>
gcloud builds submit --tag gcr.io/PROJECT_ID/nest-angular-ssr

Connect to Firebase

Connect your Cloud Run service to Firebase hosting.

command line
 firebase init hosting
 firebase deploy --only hosting

file_type_js_official firebase.json
{
  "hosting": {
    "public": "dist/browser",
    "ignore": [
      "firebase.json",
      "**/.*",
      "**/node_modules/**"
    ],
    "rewrites": [ 
      {
        "source": "**",
        "run": {
          "serviceId": "nest-angular-ssr",
          "region": "us-central1" 
        }
      }
    ]
  }
}

Q&A Chat