
Ask HN: Deploy multiple containers to AWS with CI/CD - thedenimdino
I have an API service and an ngnix server in separate containers and (a database for dev) in another container. These three are packaged in a docker-compose.yml file.<p>Now, how would you deploy this to AWS? Would I create one cluster and use the docker-compose.yml file to somehow deploy it on AWS ECS? Or create a cluster for each container and deploy it separately?<p>The API service is written in PHP and the nginx server connects to php-fpm to process php files.<p>What I don&#x27;t understand is also how tests work. When I commit to a specified branch, will it just run the tests? Or will every commit trigger a build of the image (and the tests are specified as a RUN command in the dockerfile)?<p>All of this is so confusing, how would you do it?
======
ac2u
>Now, how would you deploy this to AWS?

Personally, on AWS I'd provision RDS for the database instead of running the
DB in the cluster. YMMV but I'll happily pay for the simplified backups and
ops.

If you're mainly just using nginx as an application server here instead of as
a load balancer, I'd probably put it in the same docker container as the php
code.

Then you can leave the actual load balancing and health checks to AWS's ALB so
that when an ECS task stops responding, ECS will bring up a new one and get
things stable again.

You've two options when it comes to your cluster, EC2, in which you provision
some machines yourself for the cluster, and Fargate, in which you don't. If
you fancy managing everything tightly and tweaking until you find the right
balance, EC2 clusters can be cheaper.

Fargate gets you up and running quicker but can be more expensive.

>What I don't understand is also how tests work. When I commit to a specified
branch, will it just run the tests? Or will every commit trigger a build of
the image (and the tests are specified as a RUN command in the dockerfile)?

How you do that very much depends on the CI system you use. For example, I use
travis in work, and I can set it up so that: \- each commit runs a shell
script, and in that shell script I can run tests, and if those tests pass, and
if I'm on the main branch, a deploy will happen. \- or, I can split the tests
and deploy up into different 'stages' and the configuration file for travis
allows me to specify which branches (or pull requests) each stage can run on.

------
justincormack
Hi, Docker has recently released Compose for ECS support in beta
[https://docs.docker.com/engine/context/ecs-
integration/](https://docs.docker.com/engine/context/ecs-integration/)

