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 Answers
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
SUPPORT ENGINEER
answered a year ago
  • 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

answered a year ago
  • 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.

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions