Help deploying to compute engine instance

I have a react and express app that I want to deploy to my e2-micro instance. Currently I'm going in there and installing nginx and then gcloud scp my files over. I know I can use terraform to spin up the instance and use tpl to setup and configure my nginx but how are ppl deploying their react builds and express api and set up pm2 to manage the express api?

8 comments · 100% upvoted · other discussions

comments

martin_omander

If you are doing this to learn Terraform, Compute Engine, nginx, pm2, etc, keep going down the path you are already on.

But if your goal is to get your React+Express application running in the cloud with minimum fuss and cost, go with Cloud Run. It can serve your static files and your Express API. It takes a single gcloud command to deploy your application and there will be no infrastructure to worry about.

NetFutility [OP]

I do have that cloud run configured but the load balancer cost 18$ at a minimum in addition to cloud armor costs, whereas an e2-micro with nginx whitelist will cost just 8$ a month.

Just wondering if there's a popular ci/cd pipeline I can look into for the bare minimum cost setup for a low traffic site

martin_omander

Got it. I didn't know about your whitelist requirement. Many developers run nginx in Cloud Run and skip the load balancer. Here is a video that shows a sample three-tier application using nginx with Cloud Run: https://youtu.be/4URpj0h3mv8

I have used GitHub Actions for my CI/CD pipelines. Google Cloud Build is another great alternative. Both come with generous free tiers. If you're using Cloud Run, it even has built-in deployments from GitHub that you can set up without writing any scripts at all.

A low traffic app will most likely come in under Cloud Run's free tier. The only potential blocker would be your database. If your current e2-micro server also hosts a relational database, that would not work well on Cloud Run.

Best of luck with your project!

kaeshiwaza

In the example they run a Go app, they don't need two CloudRun instances, it's very easy to serve the assets in the same Go app and don't need Nginx at all.