Published on: January 13, 2025
3 min read
This tutorial will show you how to use NodeJS and Express to deploy an application to Google Cloud. This step-by-step guide will have you up and running in less than 10 minutes with the Cloud Run integration.
Are you looking to deploy your NodeJS app to Google Cloud with the least maintenance possible? This tutorial will show you how to utilize GitLab’s Google Cloud integration to deploy your NodeJS app in less than 10 minutes.
Traditionally, deploying an application often requires assistance from production or DevOps engineers. This integration now empowers developers to handle deployments independently. Whether you’re a solo developer or part of a large team, this setup gives everyone the ability to deploy their applications efficiently.
Create a new project in GitLab
Set up your NodeJS application
Use the Google Cloud integration to create a Service account
Use the Google Cloud integration to configure Cloud Run via Merge Request
Enjoy your newly deployed NodeJS app
Follow the cleanup guide
Owner access on a Google Cloud Platform project
Working knowledge of JavaScript/TypeScript (not playing favorites here!)
Working knowledge of GitLab CI
10 minutes
We decided to call our project nodejs–express-cloud-run
for simplicity.
Note: Make sure to include the cloud-run
CI
template
within your project.
Navigate to Operate > Google Cloud > Create Service account.
Also configure the region you would like the Cloud Run instance deployed to.
configure Cloud Run via Merge Request.
This will open a merge request – immediately merge it.
Note: GCP_PROJECT_ID
, GCP_REGION
, GCP_SERVICE_ACCOUNT
, and
GCP_SERVICE_ACCOUNT_KEY
will all be automatically populated from the
previous steps.
deployed to Google Cloud Run using GitLab CI.
Click the Service URL to view your newly deployed Node server.
In addition, you can navigate to Operate > Environments to see a list of deployments for your environments.
By clicking on the environment called main
, you’ll be able to view a
complete list of deployments specific to that environment.
To get started with developing your Node application, try adding another
endpoint. For instance, in your index.js
file, you can add a /bye
endpoint as shown below:
app.get('/bye', (req, res) => {
res.send(`Have a great day! See you!`);
});
Push the changes to the repo, and watch the deploy-to-cloud-run
job deploy
the updates. Once it’s complete, go back to the Service URL and navigate to
the /bye endpoint to see the new functionality in action.
To prevent incurring charges on your Google Cloud account for the resources used in this tutorial, you can either delete the specific resources or delete the entire Google Cloud project. For detailed instructions, refer to the cleanup guide here.
Read more of these helpful tutorials from GitLab solutions architects.