Manny

Jun 13, 2020

6 min read

NodeJS TypeScript Docker Deployment Process With AWS EBS

How To Package A NodeJS TypeScript App, Build & Deploy The Docker Image To AWS Elastic Beanstalk

How To Deploy A TypeScript NodeJS App With Docker To Amazon Web Service Elastic Beanstalk

Why

Docker is the main reason.

What We’re Accomplishing

Requirements

NodeJS Application

Git Init

git init
touch .gitignore;

Setup Node Version

echo "12.18.0" > .nvmrc;
nvm install;
nvm use 12.18.0;

Install Package Dependencies

yarn add express cors typescript ts-node @types/express @types/node @types/cors;
yarn add -D eslint prettier ts-node-dev @typescript-eslint/parser @typescript-eslint/eslint-plugin

IDE Syntax & Formatting

mkdir .vscode;
echo "{\n\"editor.formatOnSave\": true,\n\"editor.formatOnType\": true,\n\"editor.formatOnPaste\": true\n}" > .vscode/settings.json;
touch .eslintrc.js;
touch .prettierrc.js

TypeScript Configuration File

touch tsconfig.json

Configure Package Scripts

Main App File

mkdir src;
touch src/index.ts;

Testing Our App

yarn dev;
NodeJS Local Development On Port 5000
yarn start;
NodeJS Production On Port 80

Creating Dockerfile

touch Dockerfile;
touch .dockerignore

Testing Dockerfile

docker build . -t mynodetsapp
docker run -it -d -p 5001:80 --name nodeapp mynodetsapp;
Docker NodeJS Production On Port 5001 Mapped To Port 80
docker rm -f mynodetsapp

Packing Up File For Deployment

rm -rf node_modules;
zip -r Archive.zip ./;

Commit Code To Git

*.zip

AWS Deployment

Creating Elastic Beanstalk App

AWS Management Console
Elastic Beanstalk Services
AWS Elastic Beanstalk Configuration — Part 1 of 3
AWS Elastic Beanstalk Configuration — Part 2 of 3
AWS Elastic Beanstalk Configuration — Part 3 of 3

Waiting For Build & Deployment

AWS Elastic Beanstalk Building And Deploying Code
AWS Elastic Beanstalk Successfully Deployed
Ex: DockerNodeTsApp.env…elasticbeantaslk.com [↗]
🎉Your Docker NodeJS TypeScript App Deployed To AWS Elastic Beanstalk

In Case Of Error

Yes, I know, sometimes technology can fail us.

AWS Elastic Beanstalk Build Error
AWS Elastic Beanstalk Rebuild Environment

Project Code

What’s Next

̵̶̵ ̵̶̵̴̵̶̵̶̵̶̵̴̵̵I̵̶̵̴̵̶̵̶̵̶̵̴̵̶̵’̵̶̵̴̵̶̵̶̵̶̵̴̵̶̵l̵̶̵̴̵̶̵̶̵̶̵̴̵̶̵l̵̶̵̴̵̶̵̶̵̶̵̴̵̶̵ ̵̶̵̴̵̶̵̶̵̶̵̴̵̶̵b̵̶̵̴̵̶̵̶̵̶̵̴̵̶̵e̵̶̵̴̵̶̵̶̵̶̵̴̵̶̵ ̵̶̵̴̵̶̵̶̵̶̵̴̵̶̵w̵̶̵̴̵̶̵̶̵̶̵̴̵̶̵r̵̶̵̴̵̶̵̶̵̶̵̴̵̶̵i̵̶̵̴̵̶̵̶̵̶̵̴̵̶̵t̵̶̵̴̵̶̵̶̵̶̵̴̵̶̵i̵̶̵̴̵̶̵̶̵̶̵̴̵̶̵n̵̶̵̴̵̶̵̶̵̶̵̴̵̶̵g̵̶̵̴̵̶̵̶̵̶̵̴̵̶̵ ̵̶̵̴̵̶̵̶̵̶̵̴̵̶̵t̵̶̵̴̵̶̵̶̵̶̵̴̵̶̵h̵̶̵̴̵̶̵̶̵̶̵̴̵̶̵i̵̶̵̴̵̶̵̶̵̶̵̴̵̶̵s̵̶̵̴̵̶̵̶̵̶̵̴̵̶̵ ̵̶̵̴̵̶̵̶̵̶̵̴̵̶̵n̵̶̵̴̵̶̵̶̵̶̵̴̵̶̵e̵̶̵̴̵̶̵̶̵̶̵̴̵̶̵x̵̶̵̴̵̶̵̶̵̶̵̴̵̶̵t̵̶̵̴̵̶̵̶̵̶̵̴̵̶̵ ̵̶̵̴̵̶̵̶̵̶̵̴̵̶̵s̵̶̵̴̵̶̵̶̵̶̵̴̵̶̵t̵̶̵̴̵̶̵̶̵̶̵̴̵̶̵e̵̶̵̴̵̶̵̶̵̶̵̴̵̶̵p̵̶̵̴̵̶̵̶̵̶̵̴̵̶̵ ̵̶̵̴̵̶̵̶̵̶̵̴̵̶̵s̵̶̵̴̵̶̵̶̵̶̵̴̵̶̵o̵̶̵̴̵̶̵̶̵̶̵̴̵̶̵o̵̶̵̴̵̶̵̶̵̶̵̴̵̶̵n̵̶̵̴̵̶̵̶̵̶̵̴̵̶̵,̵̶̵̴̵̶̵̶̵̶̵̴̵̶̵ ̵̶̵̴̵̶̵̶̵̶̵̴̵̶̵s̵̶̵̴̵̶̵̶̵̶̵̴̵̶̵o̵̶̵̴̵̶̵̶̵̶̵̴̵̶̵ ̵̶̵̴̵̶̵̶̵̶̵̴̵̶̵m̵̶̵̴̵̶̵̶̵̶̵̴̵̶̵a̵̶̵̴̵̶̵̶̵̶̵̴̵̶̵k̵̶̵̴̵̶̵̶̵̶̵̴̵̶̵e̵̶̵̴̵̶̵̶̵̶̵̴̵̶̵ ̵̶̵̴̵̶̵̶̵̶̵̴̵̶̵s̵̶̵̴̵̶̵̶̵̶̵̴̵̶̵u̵̶̵̴̵̶̵̶̵̶̵̴̵̶̵r̵̶̵̴̵̶̵̶̵̶̵̴̵̶̵e̵̶̵̴̵̶̵̶̵̶̵̴̵̶̵ ̵̶̵̴̵̶̵̶̵̶̵̴̵̶̵t̵̶̵̴̵̶̵̶̵̶̵̴̵̶̵o̵̶̵̴̵̶̵̶̵̶̵̴̵̶̵ ̵̶̵̴̵̶̵̶̵̶̵̴̵̶̵c̵̶̵̴̵̶̵̶̵̶̵̴̵̶̵h̵̶̵̴̵̶̵̶̵̶̵̴̵̶̵e̵̶̵̴̵̶̵̶̵̶̵̴̵̶̵c̵̶̵̴̵̶̵̶̵̶̵̴̵̶̵k̵̶̵̴̵̶̵̶̵̶̵̴̵̶̵ ̵̶̵̴̵̶̵̶̵̶̵̴̵̶̵b̵̶̵̴̵̶̵̶̵̶̵̴̵̶̵a̵̶̵̴̵̶̵̶̵̶̵̴̵̶̵c̵̶̵̴̵̶̵̶̵̶̵̴̵̶̵k̵̶̵̴̵̶̵̶̵̶̵̴̵̶̵ ̵̶̵̴̵̶̵̶̵̶̵̴̵̶̵w̵̶̵̴̵̶̵̶̵̶̵̴̵̶̵h̵̶̵̴̵̶̵̶̵̶̵̴̵̶̵e̵̶̵̴̵̶̵̶̵̶̵̴̵̶̵n̵̶̵̴̵̶̵̶̵̶̵̴̵̶̵ ̵̶̵̴̵̶̵̶̵̶̵̴̵̶̵i̵̶̵̴̵̶̵̶̵̶̵̴̵̶̵t̵̶̵̴̵̶̵̶̵̶̵̴̵̶̵’̵̶̵̴̵̶̵̶̵̶̵̴̵̶̵s̵̶̵̴̵̶̵̶̵̶̵̴̵̶̵ ̵̶̵̴̵̶̵̶̵̶̵̴̵̶̵u̵̶̵̴̵̶̵̶̵̶̵̴̵̶̵p̵̶̵̴̵̶̵̶̵̶̵̴̵̶̵. Here’s the next part:

Other Articles I’ve Written