This repository provides a streamlined solution for automating the process of building Docker images and pushing them to AWS Elastic Container Registry (ECR) using GitHub Actions. With these configurations and provided files, you can set up a seamless workflow to manage your containerised applications.
Prerequisites Before getting started, ensure you have the following:
- An AWS account: Sign up for Free Tier
- Docker installed on your local machine: Docker Installation Guide
- GitHub account: Sign up for GitHub
-
Fork this repository
-
Once forked, go to your profile on GitHub, and clone the repository down to your local machine:
git clone https://github.com/headinthecloud5/youtube-docker-ci-aws-ecr.git
- Navigate to the cloned repository:
cd youtube-docker-ci-aws-ecr
- Build the Docker image:
docker build -t docker-manual-aws-ecr:1.0.0 .
- Run the Docker container:
docker run -d --name docker-test-app -p 3000:3000 docker-manual-aws-ecr:1.0.0
- Access the application in your web browser at http://localhost:3000.
-
Configure AWS Credentials - To enable GitHub Actions to access AWS services such as ECR, we need to set up AWS credentials in GitHub as secrets.
-
Commit and Push Your Changes:
git add .
git commit -m "Set up Docker build and push workflow"
git push origin main
-
Navigate to the "Actions" tab on GitHub to monitor the workflow's execution.
-
Once the workflow is triggered (e.g., on each push to the main branch), it will build the Docker image and push it to AWS ECR automatically.
-
Check your AWS account under ECR service, look for the newly created Docker image.
For a comprehensive step-by-step guide on setting up and using this automated workflow, watch our tutorial video on YouTube. In the video, we walk you through the entire process, from configuring the Dockerfile, nodejs + dependencies, and GitHub Actions workflow to pushing Docker images to AWS ECR.
This project is licensed under the MIT License.
You are encouraged to tailor the workflow and Dockerfile to suit your specific needs.
If you come across any challenges or have ideas for enhancements, don't hesitate to open an issue or send a pull request. Your contributions are greatly appreciated!
Thank you for your interest and support!