Urgent.News

What's breaking now, across hundreds of outlets.

Tech

Building a Fully Automated CI/CD Pipeline on AWS with Docker, ECR, CodeBuild, CodePipeline and ECS Fargate

Introduction Shipping software by hand is one of the quickest ways to introduce mistakes. Someone builds an image on their laptop, pushes it to a registry, logs into a console and clicks through a deployment. It works until the day a step is skipped, a wrong tag is deployed or the one person who knows the process is on leave. Continuous Integration and Continuous Delivery (CI/CD) solves this by…

Continuous Integration and Continuous Delivery (CI/CD) eliminates manual errors in software development by automating the release process. In this project, the author constructed a comprehensive CI/CD pipeline on AWS that transforms a code push into a running container on Amazon ECS Fargate, without any manual intervention. To maintain focus on the pipeline, the author utilized the 2048 game as the workload.

This static web application is straightforward to containerize and provides immediate visibility when a deployment succeeds. The AWS setup, IAM configuration, and pipeline were designed and validated by the author.

The CI/CD pipeline operates as follows: once code is pushed to GitHub, the process automatically commences with CodePipeline identifying the push and extracting the latest code from GitHub. Subsequently, CodeBuild executes the instructions outlined in buildspec.yml. This phase builds a Docker image, assigns a tag to it, pushes the image to Amazon ECR, and generates a small file known as imagedefinitions.json.

Finally, CodePipeline forwards this file to Amazon ECS, which replaces the existing container with the updated image.

The project employs a Dockerfile intentionally kept minimal. It leverages the official Nginx image, incorporates the game files into Nginx's web root, and initiates Nginx in the foreground to ensure the container remains operational. The Docker image was successfully built and tested locally before deploying it to AWS. The image was subsequently stored in Amazon ECR, a private repository for CodeBuild to push every new version of the image.

Before automating the deployment, the author manually deployed the container through four steps: creating an ECS cluster with the Fargate option for serverless execution, defining the task blueprint with the container name, ECR image reference, and port mapping, initiating a service to maintain the desired number of tasks (one) and replace any stopped tasks, and configuring a security group to allow inbound HTTP on port 80.

After verifying the manual deployment, the author created a GitHub repository containing the Dockerfile, buildspec.yml, and game source code.

The buildspec.yml file, the core of CI, specifies three phases for CodeBuild: pre_build, build, and post_build. During pre_build, CodeBuild logs into ECR to enable image pushing. The build phase constructs the Docker image and tags it with the ECR repository URI. Lastly, post_build pushes the image and generates imagedefinitions.json. The entire CI/CD pipeline is designed to automate the entire process, from code push to automatic deployment in Amazon ECS Fargate, ensuring consistent and error-free deployments.

Rewritten by urgent.news; may contain errors — check the original.

Read the original at dev.to →

Report a problem with this story

More in Tech

Estimating Popularity Without Collecting a Single Answer

The board is a model, not a poll A trivia game that scores you on how popular your answer is has an obvious implementation problem: popularity is data, and data implies collecting it from players.

  • Scoring remains consistent throughout the day for honest comparisons.
  • Unexpectedly popular answers omitted from the board.
  • Trade-off between comparability and recognizing unexpected success.

Building a Telegram Stars ledger in TypeScript: payments, refunds and nanostars

Telegram's Bot API reports a bot's Stars activity as a list of StarTransaction objects, and the useful numbers (net balance, how much was refunded) are not in the response: you have to compute them.

  • TypeScript ledger created for Telegram Stars payments and refunds
  • Star value calculated at $0.013 as per Bot Developer Terms
  • Ledger written in TypeScript, runs in Node 24 without build

More from Saturday 21 November →