Get hands-on experience with 20+ free Google Cloud products and $300 in free credit for new customers.

What is the best way to deploy a React.js app on GCP?

We want to deploy a React.js app on Google Cloud. It will be using push-notifications. What is the best way to do this? I can think of at least 3 options:

- cloud run

- app engine

- firebase

with so many choices, it is difficult for a newcomer to know which one is the right choice. cost is one of the things we want to consider for determining the best choice. other than that is just speed which i am assuming all 3 will provide. the app is not going to serve millions of users. it will be a low traffic internal application - lets say max 10 rps.

Solved Solved
0 4 7,445
1 ACCEPTED SOLUTION

Cloud Run + firebase hosting & CDN is a great option! Cloud Run let's you deploy from source just like you would from App Engine and has more modern capabilities. Here is a great tutorial - https://firebase.google.com/docs/hosting/cloud-run 

View solution in original post

4 REPLIES 4

Cloud Run + firebase hosting & CDN is a great option! Cloud Run let's you deploy from source just like you would from App Engine and has more modern capabilities. Here is a great tutorial - https://firebase.google.com/docs/hosting/cloud-run 

I deployed my React app on Google Cloud Run, but it turned out to be a bad choice. How can we securely access our environment variables from a .env file in Google Cloud Run? My .env file contains secrets that I do not want to expose.

You can use Cloud Run environment variables (note that there are some reserved variables like `PORT`), but it's best to store non-sensitive stuff there from .env and to use Secrets Manager for API tokens, DB connection strings, keys, certificates, etc. Note that anyone with Viewer IAM permissions on Cloud Run resource can view its environment variables, so it's needed to decide really carefully what can be stored in Cloud Run env vars, and what shall go only to Secrets Manager.

Cloud Run environment variables docs: https://cloud.google.com/run/docs/configuring/services/environment-variables

The solution we typically recommend is storing secrets in Secret Manager, and then exposing those secrets as environment variables. https://cloud.google.com/run/docs/configuring/services/secrets

Top Solution Authors