This demo covers how to host a frontend application using Firebase and the Google Cloud Platform (GCP). In it, you will see files for deploying to Firebase and also the Dockerfile that is needed to deploy to GCP's Cloud Run service.
You will need to download and install the following:
NodeJS is 100% required for this demo. Docker and the GCloud CLI are only required if you would like to learn how to professionally deploy your app as a docker container. This will be the second half of the demo.
Steps:
- Go to the firebase console and create a new project
- Install the firebase CLI
$ npm i -g firebase-tools
- Log in to the firebase CLI
$ firebase login
- Navigate to the 'sample' directory in the terminal and run the following
$ firebase init
-
Place all of your code in the 'public' folder
-
After configuring the project, run the following
$ firebase deploy
Steps:
- Create a nginx Docker file
- Build the image (assuming in the 'sample' directory)
$ docker build -t gcr.io/$PROJECT_ID/client .
Note that the $PROJECT_ID is the ID of the google cloud platform project. This project is automatically created when you create a firebase application.
- Push the new image to GCP's container registry
$ docker push gcr.io/$PROJECT_ID/client
- Deploy the container to Cloud Run
$ gcloud run deploy client --image gcr.io/$PROJECT_ID/client --region us-central1 --platform managed