Can I run a fullstack app inside Cloud Run container

I want to set up a cheap website with this stack react + express + firebase auth + firestore

I think running it on Cloud Run might be the best option and with maybe a few thousand requests per month and like 20 MAU it could live in the free tier.

Is this a good assumption and can it be done? I see alot of yt and articles on setting up nginx and react in Cloud run but nothing about setting up an nginx react and express server.

12 comments · 75% upvoted · other discussions

comments

BehindTheMath

You can technically run both nginx and Node on a single container, but it goes against the best practice of 1 process per container.

Check out Firebase Hosting for the frontend.

NetFutility [OP]

I need to whitelist ips allowed to access this app can I do that from Cloud Run or firebase hosting?

BehindTheMath

I'm not sure if Firebase Hosting supports whitelisting. I don't believe Cloud Run does.

A better solution might be to use a load balancer with Cloud Storage for the frontend. I believe you can filter by IP using Cloud Armor.

NetFutility [OP]

Thank you thats exactly the architecture rec I was looking for. I know it's against practice to have nginx and express processes in same server but I figure in terms of cost savings as well as if I have separate container for express the total cold start time might be doubled

martin_omander

Cloud Run works great for web apps that serve static HTML/JS files and provide an API. There are many ways of doing it, so I described the top three in this video.

I haven't felt the need for nginx when using Google's serverless platforms, as Google will do many of the things you'd use nginx for (scaling, routing, https termination, load balancing). But you may have different needs than I do. Here is another video I shot with a co-worker about how to build a three-tier web app on Cloud Run that uses nginx.

Hope this helps.

NetFutility [OP]

I think in this case I just don't have a webserver to serve my static content but yeah thanks for the rec I'll check out your video now

the_hack_is_back

Why not serve the static content with express?

martin_omander

Agreed. I really like serving static content with Express for low-traffic applications. Last month I had to roll back a bad deployment. Because both the front-end HTML/JS and the back-end REST API were in the same container, I simply pointed Cloud Run to the previous container version. It was safe and quick.

If I need more scalability, on the order of thousands of users per day, I put my static content on Firebase Hosting.

NetFutility [OP]

Lol honestly didn't know you could do that 😅 I thought it was either server side templating or api with express

martin_omander

I learned that Express can serve static content only last year. We live and learn. 🙂

martin_omander

Makes sense. Express or Google's Firebase Hosting can serve your static content. Firebase Hosting in particular is very good at it, as it includes https termination, custom domains, CDN, content compression, you deploy your content with one single command, and there is no fixed monthly cost.

Or stick with nginx if that is what you know and love. The videos above have more details.

jkonarze

Just do it in the app engine. Once service for react one for node. Fire base is a separate product nothing to run in the cloud run.