1

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!

aroe
  • 499
  • 1
  • 6
  • 15

1 Answers1

3

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.

Mayank Raj
  • 1,574
  • 11
  • 13
  • WOW TY SO MUCH! Let me look into this! – aroe Jul 15 '20 at 04:23
  • 2
    Hey @aroe, you're welcome. If the answer did indeed address your question, do you mind accepting it. That way, others who stumble upon this can easily find the solution. Cheers. – Mayank Raj Jul 15 '20 at 04:24
  • I absolutely will! It's a bit late here so I will do so tomorrow when I'm back in the thick of it. Really appreciate the suggestions and links a lot. – aroe Jul 15 '20 at 04:29
  • I have a question regarding the appspec and taskdef files in the codepipeline. I have been manually creating tasks but, if I put the appspec in my github repo won't it override my Dockerfile? – aroe Jul 15 '20 at 17:07
  • They are two different things. Dockerfile describles the containers and their state whereass appsec gives CodeDeploy the instructions on how to build, test and deploy the application. – Mayank Raj Jul 15 '20 at 17:25
  • ok thank you very much! I have the ECS container deploy but, when I put the public IP in the browser it hangs OR when I put the public IP with the port on the back it goes to the page but I have to change https to http – aroe Jul 15 '20 at 17:30