This video is available to students only

Production Deployment

Production Deployment

Node and PostgreSQL Hosting#

The key requirements for deploying our app to a production environment are Node and PostgreSQL hosting. We need to use a provider that offers both.

Platform as a Service (PaaS) offerings tend to be the easiest to get started and the easiest to manage in production, but can be more expensive at higher scale, e.g., lots of users, traffic or data storage. Examples of PaaS offerings are Heroku, Google App Engine and AWS Elastic Beanstalk.

At the other end of the spectrum are Infrastructure as a Service (IaaS) offerings that provide virtual servers and leave it up to you to install the needed software (e.g., Node and Postgres) and configure network connections, apply SSL/TLS certificates and so on.

For this lesson, we are going to use Google App Engine. It offers relatively low cost to get started (5.00 USD per month) and all the features we need. You will need a credit or debit card for this lesson.

Here are the basic steps we'll follow:

  1. Create a Google Cloud Platform Project and Billing Account

  2. Add an App Engine Node.js application. This will be our Express app.

  3. Add a PostgreSQL data base to the GCP Project.

  4. Enable workstation network access to the new database.

  5. Run the migrate.js script to migrate the new remote Postgres database.

  6. Add an app.yaml file to the local project. This file will contain all the secrets for the app and the App Engine configuration.

  7. Deploy the app using the gcloud CLI tools.

Important - to get the cheapest possible pricing with Google Cloud Platform, make sure you select the Lightweight instance type when creating your Postgres instance. It is also recommended to check your GCP charges after a couple of days and make sure they meet your expectations.

Getting Started with Google Cloud Platform#

If you don't already have a Google account, you'll need one first, then head over to https://console.cloud.google.com/. This is the main web interface for managing all Google Cloud resources.

You will also need a Billing Account, so go ahead and create one using the left navigation under Billing.

PostgreSQL hosting starts at $5.00 USD per month and Node.js App Engine hosting starts with free hosting, therefore the estimated monthly charges for running this project are $5.00. Free credits are usually available to new users as well.

billing.png

Creating a GCP Project#

The next step is creating a GCP Project. From the Dashboard page, choose Create Project.

create-project

Give the Project and name and finish the creation process. GCP will automatically generate a unique project ID based on your name:

projectid

Creating an App Engine App#

After the project creation process finishes, select the project and then choose App Engine > Dashboard from the left nav. From here, choose Create Application, select a Region and choose language Node.js and Standard environment:

node-js

Then, download and install the Cloud SDK:

cloud-sdk

Adding a PostgreSQL Database#

Continuing in the GCP console, head back to the left nav and choose SQL under the Databases section. Choose Create instance and PostreSQL:

create-postgres
 

This page is a preview of Fullstack Svelte

Start a new discussion. All notification go to the author.