Skip to content

julien-muke/nodejs-docker-aws-ecs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

aws Deploy Node JS Docker Container to AWS ECS Cluster (Fargate).

Amazon ECS uses Docker images in task definitions to launch containers. Docker is a technology that provides the tools for you to build, run, test, and deploy distributed applications in containers.

In this hands-on we're diving deep into the world of AWS as we guide you through the process of pushing your Node.js Docker container to AWS Elastic Container Registry and deploying it to AWS Elastic Container Service.

Docker Image-2

Use Case: Deploying Web Application on Amazon ECS.

Imagine you are developing a basic web application, and you want to deploy it using Amazon ECS. Example: Imagine a simple Node.j application that displays "Hello, World!" on a webpage. The Dockerfile could specify the Node.js base image and install any required dependencies. You'd then build and push the image to ECR. Finally, by creating an ECS service with your task definition, you'd deploy the application on Fargate, making it accessible on the internet.

The procedure for deploying this architecture on AWS consists of the following steps:

Step 1. Create WebApp Docker Image

Step 2. Create aws-cli user

Step 3. Create & push image to AWS ECR repository

Step 4. Create Security Groups

Step 5. Create AWS ECS Fargate Cluster

Step 6. Create Task Definition

Step 7. Create ECS Service with Application Load Balancer

Step 8 Update Application Load Balancer Security Group

πŸ“ Prerequisites

Before you begin, ensure the following prerequisites are met:

➑️ Step 1 - Create WebApp Docker Image

Amazon ECS uses Docker images in task definitions to launch containers. Docker is a technology that provides the tools for you to build, run, test, and deploy distributed applications in containers.

To create a Docker image of a simple web application:

  1. Create a file called Dockerfile. A Dockerfile is a manifest that describes the base image to use for your Docker image and what you want installed and running on it. For more information about Dockerfiles.
touch Dockerfile
  1. Edit the Dockerfile you just created and add the following content.
FROM node:alpine

WORKDIR /nodejs-docker-aws-ecs

COPY package.json .

RUN npm install

COPY . .

EXPOSE 3000

CMD [ "node", "app.js" ]

πŸ’° Cost

All services used are eligible for the AWS Free Tier. However, charges will incur at some point so it's recommended that you shut down resources after completing this tutorial.

Conclusion

In this blog post, we have provided a step-by-step guide on how to develop and deploy a basic web application on Amazon ECS using Fargate. By following these steps, you can learn the basics of ECS and Fargate and get started with deploying containerized applications on AWS. This approach offers scalability, reliability, and cost-effectiveness for managing containerized workloads in the cloud.

About

A step-by-step guide on how to develop and deploy a basic web application on Amazon ECS using Fargate.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages