I've noticed that many applications distribute their Dockerized versions as multi-service images. For instance, XWiki's Docker image combines XWiki, Tomcat Web Server, and PostgreSQL into a single image. This got me thinking: would it be advisable to do the same with a web app that's composed of a React frontend and a Golang backend? Or are there better practices that I should consider instead?
6 Answers
It's generally viewed as a bad practice. Many multi-service images support users on systems that don’t utilize Compose stacks, but separating services leads to clearer management.
Separating services is considered best practice. I'd suggest providing a working Docker Compose file to launch everything seamlessly.
For development, it's better to use two separate containers. In production, you can serve the compiled React frontend as static files from your Golang backend. This keeps things simple and manageable.
In most cases, if services can be divided, it’s better to do so—like separating the database from the app server. However, combining an HTTP server with an app server can sometimes make sense. The simpler your image, the easier it is to manage.
Packaging multiple services in one image is convenient for tutorials and quick start guides, but having one service per image is better for system monitoring, independent scaling, and simplifying development. Providing Docker Compose files can easily counteract the downsides of keeping services separate.
Yes, bundling multiple services into one Docker image can complicate monitoring and managing processes. It's generally best to stick to a single process per image. If you need several services, consider using Docker Compose to manage them together. While it might work, managing everything in one container can lead to headaches down the line.
Great point! If I'm working within a larger microservice architecture, should I integrate my services into a single Docker Compose setup or handle it in my CI/CD configuration?
You can use Supervisord to manage multiple processes within a single container, but I still recommend separating services when possible.
What are the potential downsides of this approach? Having everything in one image seems easier for deployment.