Trying to setup CI/CD on AWS using Github,Docker,ECR, and EC2

760 views Asked by At

So the title kind of says it all. I am trying to come up with a solution to create a CI/CD workflow. The workflow I am trying to create is roughly as follows; Github stores our code and Dockerfile, ECR pulls in our built image every time a push to master is made. ECR then pushes that newly built image to EC2 based on tagging it by (latest), I then route that instance to DNS and create our web server.

I already have Docker images built for all repos and then build perfectly fine. Github actions is also already set and pushes a new image to ECR with the tag (latest) when a push is made. This all works fine. My blind spot is this.. what do I do with the ECR images? How do I host them and point them publicly towards DNS? I know of ECS but, I would prefer EC2 I just can't find any answers anywhere. Thank you all for your help!

1

There are 1 answers

6
Mayank Raj On

You have correctly identified ECS as a appropriate service for this use case. With ECS you can still choose to host the container on EC2. You may choose to do so because of multiple reasons like if you want access to the host machines, already have Reserved Instances, need GPU instances etc. Read more about it here.

By using ECS, you offload the overhead of managing the containers to AWS among other things like routing logs to CloudWatch, hosting multiple containers on a single bigger host and automatically balancing the load etc.

To point the domain name to your service, you can make use of ECS behind Application Load Balancer (ALB). Read more about it here.

Finally as far as the CICD pipeline is concerned, explore AWS Codepipeline. When paired with ECS, you can easily configure deployment strategies like Blue/Green Deployment, automatic roolback etc. Read more about it here.