Best way to deploy a JS app that is already using docker as dev environment

0

Hello, I have a next.js/mysql application running on docker on my laptop. It uses docker-compose.

I would like to deploy it to aws and take advantage of Load Balancer and Auto Scaling Groups.

Do you suggest to use ECS to deploy the whole container (can I use LB and ASG) or should I better use cloudformation and only deploy the application code? In the latter case how should I setup my dev environment? I would like to have the DEV and the TEST/PRD environments consistent.

thanks

2개 답변
0

Hello,

Since you are already using docker-compose, you can easily deploy your services to Amazon ECS using Docker-ECS integration.

Amazon ECS supports both service autoscaling and service loadbalancing.

If you are interested in a serverless option, you can leverage ECS Fargate to avoid managing the underlying infrastructure.

As you are new to ECS, I recommend you to check out the ECS workshop tutorial to learn about all the cool things that ECS offers.

profile pictureAWS
지원 엔지니어
답변함 일 년 전
  • Hello Venkat, thanks for your help.

    If I use ECS Fargate or just ECS, I guess it will create an EC2 instance for mysql. Is there a way to make it use Aurora instead and avoid to create the EC2 instance for mysql?

    Thank you

  • If you choose to use ECS Fargate for hosting your mysql container, you don't need to provision any infrastructure as the container will run on Fargate infrastructure. However, I'd recommend that you host your database on RDS for scalability and resiliency.

    If you choose to use RDS aurora for database storage, you will have to create the RDS cluster/instance separately. If you are looking to create RDS using cloudformation, please look at these sample templates for reference - https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/quickref-rds.html

0

Hi Venkat, so it sounds that it's probably better to only use cloudformation, just to avoid to build half infrastructure using fargate (the next.js container) and the other half with cloudformation (RDS).

If I only use cloudformation, how do you suggest I should do the coding? If I keep docker for my local dev is going to diverge from the cloud anyway. What is best practice in this case?

M

답변함 일 년 전
  • Hello again,

    You can use CloudFormation to build both your RDS Aurora cluster, and your ECS cluster and its related components i.e. ECS service, ECS Task Definition to define your application configuration, and an ECR repository to store your docker images.

    After creating the above components, you can build your docker image on your local machine or through a pipeline and push it to the ECR repository and deploy it as a service on ECS.

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠