I manage a Docker server that currently runs a single web application along with a reverse proxy. I'm planning to expand this server to host multiple independent apps in the future. My question is, should I consolidate everything into one large Docker Compose file, or would it be better to have individual compose files for each app? Also, I'm unsure if there's any widely accepted best practice regarding this. Thanks for your insights!
5 Answers
I prefer separate compose files for each project, which I then integrate into my NGINX configuration manually. Having everything in one file can cause issues if one project fails to start; it could prevent NGINX from starting up correctly. I also use an NGINX agent to manage configuration changes, but you could do it manually if that's your style.
I think separating the files is definitely the way to go. I create multiple Docker Compose projects while sharing a single network for reverse-proxying. This allows the reverse proxy to direct traffic based on domain names or paths. Just ensure that the shared network isn't tied to any specific compose project to avoid issues when you bring down a project.
I generally prefer keeping them separate. For example, I use Traefik instead of NGINX, but the principle is similar. When you make changes to a specific app's .yml file, you don't want to risk affecting your reverse proxy setup. I like to group my compose files by type of service - I have one for core services like Traefik, another for media stacks, and so on. Also, if you're working with any databases, it's a good idea to keep those in their own compose file along with their respective app.
I do recommend keeping everything separate, but you can still keep them in one repository if you’re using Git. This way, any changes you make to your app and the corresponding NGINX configurations can be bundled into one commit, which is super convenient.
For me, it's all about having distinct files for each app. YML files can get pretty unwieldy, and trying to scroll through hundreds of lines for each app makes it a nightmare. Keeping them separate makes it much easier to manage.

Related Questions
How to Build a Custom GPT Journalist That Posts Directly to WordPress
Fix Not Being Able To Add New Categories With Intuitive Category Checklist For Wordpress
Get Real User IP Without Installing Cloudflare Apache Module
How to Get Total Line Count In Visual Studio 2013 Without Addons
Install and Configure PhpMyAdmin on Centos 7
How To Setup PostfixAdmin With Dovecot and Postfix Virtual Mailbox