Deploying an Express Application

Introduction

Overview

We will cover:

  • What is deployment

  • Where is deployment in the SDLC

  • Deployment options

  • How to deploy an app

  • Post-Deployment

  • Some Deployment Difficulties

What Is Deployment?

The Definition

Software deployment includes all of the steps, processes, and activities that are required to make a software system or update available to its intended users.

~ Sumo Logic

Essentially

Deployment is taking the code that we have built, and making it available outside of our local machine. It includes hosting the code on another machine and making it accessible to others.

A Visual Look at Deployment

_images/deployment.jpeg

Where is Deployment in the Software Development Lifecycle

Reviewing the SDLC

  1. Planning

  2. Analysis of Requirements

  3. Design

  4. Implementation

  5. Testing & Integration

  6. Maintain

Deployment falls into the Integration portion of Testing & Integration

Who is Responsible for Deployment?

Typically, deployment falls under the responsibility of the DevOps team. However, it is important to remember that smaller companies may not have a DevOps team, and therefore deployment could land under the responsibility of a Lead Engineer or Project Manager.

When to Deploy

Typically, once all the necessary code has been implemented it is handed off to QA. Once the back-and-forth between Devs and QA is complete and QA has given the green light to deploy, the DevOps team will take over.

We will cover more on the DevOps team and responsibilities next week.

Deployment Options

Different Types of Hosts

It is important to know that there are different types of hosts/hosting services.

Some (like Heroku & Glitch) are fully automated, simply link your project, add a few pieces of information, and deploy!

While others (like Digital Ocean & AWS) host remote servers for you to access via the command line, clone your code base, set up your processes, etc…

The first option is much simpler. The second option is much more capable. You’ll find uses for both throughout your development journey.

How to Deploy an App

Similar but Different Process

Depending on which platform you use to host your application, the process might be slightly different. However, most platforms follow the same general outline.

Deploying with AWS EC2

In today’s demonstration, we will look at how to deploy an application with AWS EC2.

  • EC2 stands for Elastic Compute Cloud

  • An EC2 instance is a virtual server that’s hosted in a cloud

  • Imagine a big data center filled with lots of computers, that’s the cloud

  • Each of these computers can run multiple services/environments

  • And the virtual server is an environment running on one of those computers

So basically you’ll be interacting with a remote virtualized computer through the command line.

High-level Overview

We’ll be creating an Express server that serves front-end files.

Then we’ll put that code onto an EC2 instance.

Last, we’ll set up the server to run indefinitely so that when other computers (clients) request information from our computer (server), Express will know what to send them.

Steps to Deploy

Set up an express server

This is what will actually receive requests and send responses

Create an EC2 instance and configure it

An EC2 instance is just an Ubuntu (Linux) computer running in the cloud. We’ll need to set it up like you did with your computer at the beginning of Foundations.

Get code onto the EC2 instance

We’ll use GitHub to transfer code between your local machine and your remote server.

Run express with pm2

Up until now, you’ve used node or nodemon to run JavaScript files. This new tool, pm2 is a utility that can run apps even when you close your connection to the computer.

Post-Deployment

Adding Domain Names

Once an application has been deployed, depending on your hosting service, you might need to go to some ip address to access you app, like 67.205.192:5555, or you might need to go to a site like wwww.my-awesome-app.heroku.com. Neither of these are what we really want. We simply want to go to something like www.my-awesome-app.com.

In order to do that, you will need to register for a domain name. Some common domain name services include:

  • GoDaddy

  • Name.com

  • NameCheap

Once you have your domain name, you will need to link it with your hosting service. This can sometimes be complicated. Instructions will be presented by both the DNS provider and the hosting service, and often times these instructions can be conflicting…

Other Adjustments

Depending on what hosting service you are using, you may also be able to adjust the following settings:

  • SSL (Allows you to use different protocols such as HTTPS)

  • File Transfer Size (Allows you to change limitations on file upload size)

Deployment Difficulties

Use It or Lose It

Deployment can be a complicated process. On top of that, if you can easily find yourself only deploying content once a year, or even less. With that lack of consistency you will likely lose all your knowledge on deployments. Challenge yourself to deploy applications more often, even if they are just practice applications. Play with host/server settings such as SSL settings.