Skip to content

Bharat2704/getting-started

 
 

Repository files navigation

Sample app to demonstrate CI/CD pipeline with GitLab

I have taken sample nodejs source code with Docker file from https://docs.docker.com/get-started/02_our_app/ and create CI/CD pipeline with GitLab CI.

I have select AWS ECS service with Fargate launch type to deploy our container app.

We are using Terraform for infrastructure provisioning on AWS and you can find terraform script inside terraform directory. I have use default VPC and subnets for our app. Terraform script will provision the below resources:

  • ECS cluster
  • ECS task definition
  • ECS services
  • Load balancer
  • LB listener
  • Target group
  • security groups
  • IAM role for task

You can find GitLab CI/CD configuration in .gitlab-ci.yml file. We assume we have the below keys configured as an environment variables before pipeline execution

  • AWS_ACCESS_KEY_ID
  • AWS_SECRET_ACCESS_KEY
  • AWS_DEFAULT_REGION

Below is the GitLab CI flow

  1. In the first stage we have include Code-Quality.gitlab-ci.yml template which checks code quality on merge request and generate a report. here is the reference. https://docs.gitlab.com/ee/user/project/merge_requests/code_quality.html
  2. In the second stage, we are building docker image, log in on AWS ecr and push docker image.
  3. In the third stage, we are provisioning AWS resources with terraforming. before apply to terraform we also validate terraform script and need manually trigger before apply.
  4. the Last stage is to notify the slack channel by triggering the webhook URL.

Future enhancement:

  • We can write scripts for customizing messages on different pipeline statuses.
  • Create a multitier architecture for securing our app deployment.
  • Configure blue/green deployment for ECS service.

About

Getting started with Docker

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 71.3%
  • HCL 18.2%
  • Dockerfile 4.0%
  • HTML 3.4%
  • CSS 2.1%
  • Shell 1.0%