r/devops • • Aug 12 '26

Architecture Deploying docker-compose.yml

Hello all. The circumstance I have working with is the following:
* I have an Apache2 PHP server that gets bundled as a Docker image in a CI process to ECR

* I have an infra repository with a docker-compose.yml that bundles the PHP Docker image to an Nginx image, alongside Nginx config like attaching TLS certs

When the CICD process deploys a release, it deploys a new EC2 with a given user data script to prop up the server. If I only had a Docker image, the user data would generally look like "Pull down ECR image and start image", however in this case I am spinning up a docker-compose.yml file.

How is this typically done? I suppose I *can* add a CI process to zip up the docker-compose.yml and related nginx config, however feels backwards? Is there a consensus with this?

If I am fundamentally misunderstanding something let me know, I'd say my only constraint is I'd like to solve this problem in a relatively cloud agnostic environment (so keeping EC2 as a VM, ECR as a registry, but excluding abstractions like Fargate or ECS)

Thanks!

13 Upvotes

17 comments sorted by

View all comments

Show parent comment

1

u/aress1605 Aug 12 '26

```it won't work if you need to add more compute power than just a single EC2 VM to your application.```

If there is load balancer that sits as a proxy, there can be N EC2 instances with N docker compose files launched via user data, so the way I am interpreting it, adding more is possible with a classic LB.

I think you are mentioning that traditionally you have one load balancer (ie. Nginx / AWS native solution) that proxies to N EC2 instances. Therefore each EC2 instances only needs the PHP server, and does not need it's own Nginx image, since TLS often ends at the load balancer anyway, so you can port forward it directly to the Apache2 endpoint? Is that what you were talking about when you mentioned you cannot scale EC2s beyond one?

6

u/MDivisor Aug 12 '26

The load balancer is not the problem with the scaling. It's the fact that you need a separate compose file for each VM and they don't talk to each other in any way.

In a more complicated setup you could have X amount of servers and Y amount of different services (some possibly with multiple replica instances) you need to run. This becomes very tedious to manage with per-server compose files. With a container orchestrator (like Kubernetes or ECS), you just tell the orchestrator "these are your VMs and these are the containers I want to run, you figure out what goes where and network them together".

1

u/BrocoLeeOnReddit Aug 13 '26

This and you can automatically scale up/down depending on usage metrics.