DevOps, Project Blog - 5

DevOps, Project Blog - 5

Project

Get a NodeJs application from GitHub

  1. Clone the Node.js Project from GitHub:

     git clone <GitHub_Repository_URL>
     cd <repository_directory>
    

  2. Build the Docker Image: Assuming there's a Dockerfile in your project directory, you can build the Docker image like this:

     docker build -t <your_image_name> .
    

  3. See the created images.

  4. Set Up AWS CLI and AWS Login: If you haven't already, configure the AWS CLI with your credentials:

     aws configure
    
     aws configure list
    

  5. Create an ECR Repository: If you haven't already created an ECR repository, do it with the following command:

     aws ecr create-repository --repository-name <your_repository_name>
    

  6. Log in to ECR: Get the Docker login command to authenticate your Docker client to the ECR registry:

     aws ecr get-login-password --region <your_aws_region> | docker login --username AWS --password-stdin <your_account_id>.dkr.ecr.<your_aws_region>.amazonaws.com
    

  7. Tag and Push the Docker Image to ECR: Tag your Docker image and push it to your ECR repository:

     docker tag <your_image_name> <your_account_id>.dkr.ecr.<your_aws_region>.amazonaws.com/<your_repository_name>:latest
     docker push <your_account_id>.dkr.ecr.<your_aws_region>.amazonaws.com/<your_repository_name>:latest
    

  8. Navigate to ECR in the AWS console, and check for your repository

  9. Set Up an ECS Cluster

    • Open the AWS Management Console.

    • Navigate to the Amazon ECS service.

    • Click the "Create Cluster" button.

    • Fill and Click "Create" to create the ECS cluster.

    • Our Cluster is created.

  10. Create a Task Definition

    • In the ECS service of the AWS Management Console, click on "Task Definitions" in the left navigation pane.

    • Click the "Create new Task Definition" button.

    • Select the launch type compatibility for your task definition. Choose "EC2" if you are using EC2 instances for your cluster OR Choose the Fargate launch type if you prefer a serverless deployment. Provide the required task definition name and optional task role.

    • Configure your task resources, such as CPU and memory requirements.

    • In the "Container Definitions" section, click on the "Add container" button.

    • Fill in the container details:

    • Configure any additional settings for your container, such as port mappings, environment variables, and volumes as required by your Node.js application.

    • Review your task definition settings, and then click the "Create" button to create the task definition.

    • Our task definition is created.

  11. Run the Project on ECS

    • In the AWS Management Console, go back to the ECS service and click on "Clusters" in the left navigation pane.

    • Select the ECS cluster that you created.

    • Click on the "Services" tab, then click the "Create" button to create a new service.

    • Choose your task definition created from the dropdown menu.

    • Configure the service settings, such as the number of tasks, launch type, and load balancing if necessary.

    • Review and configure additional settings like deployment and auto-scaling based on your project's needs.

    • Click "Create Service" to launch your Node.js application on the ECS cluster.

  12. Once done, browse.


Thank you so much for reading

Follow me on LinkedIn to see interesting posts like this : )

Linkedin

Β