Having the ability to quickly design and build a web application speeds up the capacity to grow a business. Express.js has everything you need right out of the box and is super easy to setup in a few minutes. This Blog article will focus on the deployment aspect of the Express app to a cloud hosting service to – Google Cloud Platform (GCP).

The application I am going to deploy is a discord app. The discord app takes an amount of money and splits it between a number of people, then creates a repeatable notification that informs specified discord users with a reminder when their bill payments are due and how much is owed.

The discord app does this in two steps. First, it has a listener attached to a specific channel within a particular discord server. The listener receives all communications sent on that channel and parses the text looking for commands (that was registered during the discord app’s authorization). If it catches any of the commands, the express app will parse that information and hand It over to another process. Additionally,, the backend has an API to (1) get upcoming notices, (2) determine what notices need to be processed and when, and (3) handle the integration into a basic webpage to also manage the notifications.

The discord app was built locally, allowing me to choose the best hosting option per my specific requirements. I then needed to determine, how would I deploy the discord app, what were my base level requirements and finally what was the cost. Below were my requirements:

Hosting Provider must adhere to these requirements:

  1. It must be easily deployable from GitHub, via GitHub actions
  2. It should be cheap yet fast and always available.
  3. It needs the current stable version of Node, as my application takes advantage of a new API feature that relies on version >= 16 of Node.

Initially, I was wondering what options made the most sense? After some initial thought and research, the clear answer was either AWS, Microsoft Azure or Google Cloud Platform. All three platforms are full of features, utilize the best hardware and are completely customizable to your specific needs, mostly.

All of the Big 3 (AWS, Microsoft Azure and GCP) had comparable pricing and the ability to deploy from GitHub.

Ultimately, I settled on Google Cloud Platform for one reason. The Node version requirement. AWS Lambdas, at the time of this writing, still do not support a node version > 14. There are some long winded work arounds to get it work, but that sounded like a headache. Microsoft Azure supports Node 16 on beta versions of the serverless modules, which I considered, because Google already knows enough about me. However, I ultimately went with GCP because they supported Node 16 out of the box, and it would not be a hassle to get my application running as expected.

Let’s walk through the steps, to ensure a smooth deployment!

1. Create Project in Google Cloud Platform

Login to GCP (https://console.cloud.google.com/), and click that little triangle (Figure 1).

GCP Dashboard

Figure 1: GCP Dashboard

Select “New Project” (See arrow below (Figure 2))

Figure 2: GCP New Project Dialog

Upon creation of the new project, you should see a new dashboard. On the dashboard are important pieces of information like the Project ID (Figure 3).

Figure 3: GCP Dashboard with the new project

Note: In order to deploy from source, you must have an active billing account. Even if you have a free trial, you must fill out the billing section and ensure your account is activated.

2. Install & initialize the Google Cloud CLI

If you previously have used GCP and have other applications you can skip this step and jump right in, after creating your project and you have your project ID.

gcloud config set project 

Install the Google Cloud CLI

MacOS: brew install –cask google-cloud-sdk

Linux: https://cloud.google.com/sdk/docs/install#linux

Windows: https://cloud.google.com/sdk/docs/install#windows

Initialize the Google Cloud CLI

  Run gcloud init from the command line

If you have only one project in GCP, it will auto assign the project. Otherwise, the cli will give you options to pick an existing or create new.

3. Deploy!

The last step is easy! We just run the follow command and follow the prompts

  gcloud run deploy

If prompted to enable the API, Reply Y to enable.

  1. When you are prompted for the source code location, press Enter to deploy the current folder.
  2. When you are prompted for the service name, press Enter to accept the default name
  3. If you are prompted to enable the Artifact Registry API, respond by pressing Y.
  4. When you are prompted for region: select the region of your choice, for example us-central1.
  5. You will be prompted to allow unauthenticated invocations: respond Y

Then wait a few moments until the deployment is complete. On success, the command line displays the service URL that we can access with our web interface.

Conclusion:

As you can see, we can get our application up and running in no time flat. We can now update our discord config to reflect the GCP URLs where it needs to call out, to send webhook responses.

I have used similar tools for deploying web applications to AWS. Comparatively, the steps are similar for AWS, Microsoft Azure, and Google Cloud Platform. They all require a little bit of fine tuning to dial it in exactly to how you want your services to scale, timeout, etc. At the end of the day, GitHub actions ultimately manage the deployment of the discord app. I just needed to set up the permissions it needed during authorization and then the rest was a breeze.

At Scalesology, we offer a wide range of services, such DevOps, Custom Development, Technology Needs Assessments and Information Security Services, to help you take your vision and make it reality. Contact us and let us ensure your business scales with the right technology