🌩ī¸ Angular Universal on Google Cloud Run

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

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 firebase.json
{
  "hosting": {
    "public": "dist/browser",
    "ignore": [
      "firebase.json",
      "**/.*",
      "**/node_modules/**"
    ],
    "rewrites": [ 
      {
        "source": "**",
        "run": {
          "serviceId": "nest-angular-ssr",
          "region": "us-central1" 
        }
      }
    ]
  }
}

Questions? Let's chat

Open Discord