npm install
npm start
docker build -t todo-web-app .
docker run -p 3000:3000 todo-web-app
Here's a step-by-step guide using the AWS Management Console (GUI) to deploy your Dockerized To-Do application to Amazon ECS using AWS CodeBuild and AWS CodeDeploy.
-
Create an ECR Repository
- Go to the Amazon ECR console.
- Click Create repository.
- Enter
todo-web-appas the repository name and click Create repository.
-
Push Your Docker Image
- Follow the instructions on the ECR repository page:
- Open the repository you just created.
- Click on View push commands to get the commands for pushing the image.
- Execute the commands in your terminal to build, tag, and push the image to ECR.
- Follow the instructions on the ECR repository page:
- Open the Amazon ECS console.
- Click Create cluster.
- Select Networking only (Fargate) and click Next step.
- Enter
todo-app-clusteras the cluster name and click Create.
- Go to the Task Definitions page.
- Click Create new task definition and choose Fargate.
- Configure the task:
- Task definition name:
todo-web-app-task. - Task role: Leave as default.
- Add container:
- Name:
todo-web-app-container. - Image:
<account_id>.dkr.ecr.<region>.amazonaws.com/todo-web-app:latest. - Port mappings:
3000(for container port).
- Name:
- Task definition name:
- Click Create.
- Go to the ECS Services page.
- Click on the
todo-app-clusterand click Create service. - Configure the service:
- Launch type: Fargate.
- Service name:
todo-web-app-service. - Task definition: Choose the one you created.
- Number of tasks:
1. - VPC and subnets: Select appropriate ones.
- Security group: Allow HTTP traffic (port 3000).
- Click Create service.
-
Go to CodeBuild
- Open the AWS CodeBuild console.
-
Create a Build Project
- Click Create build project.
- Enter
todo-web-app-buildas the project name. - In Source, choose the source provider (e.g., GitHub or CodeCommit).
- Connect your repository where your Dockerfile and application code are stored.
- In Environment, choose:
- Environment image: Managed image.
- Operating system: Amazon Linux 2.
- Runtime: Standard.
- Image: aws/codebuild/standard:6.0.
- Check Enable this project to build Docker images.
- In Buildspec, select Use a buildspec file
-
Start the Build
- Save the project and start the build.
- Once completed, the Docker image will be in your ECR repository.