Compose for Infrastructure, Containers for Apps?

I’m curious about what would be considered “good practices.” I’m currently working on writing the same project in multiple languages/frameworks, where I want them all to have access to the same database instance so I don’t have to think about synchronizing multiple databases as a learning exercise. I watched this video by Dreams of Code on YouTube about deploying a production ready VPS, where he uses Docker Compose to handle running both some infrastructure and his app from a single Compose file.

That video made me wonder: with my situation of having multiple apps, if I wanted to use a similar setup, which would be better:

  1. using a single Compose file to setup the infrastructure (traefik, Watchtower, DB), then deploy each of the apps as standalone containers configured to connect up with the infrastructure
  2. Adding new images to the Compose file as I complete another language or framework and re-run compose up -d

I’m still relatively new to the world of containerization, so I wanted to see what others would consider to be the better approach.

I would say that infrastructure is usually the term for underlying hardware (servers, network) in IT.

We use various Docker networks which we attach to our services from various compose files. Reverse proxy and DB have their own compose file.

Yeah I may not be using the appropriate terms here, as I said I’m still pretty new to this whole side of things.

So you’re saying you keep your reverse-proxy and DB in one compose file, attached to whichever networks are appropriate, then use multiple compose files for other services/apps and connect them to the same networks? Just trying to make sure I understand.

Yes. For a simple setup, you might have a proxy and database Docker network and attach according services.