Structuring Applications with Multiple Services
Best practices guide on how to structure larger applications consisting of multiple services efficiently and optimize storage requirements
Last updated
Best practices guide on how to structure larger applications consisting of multiple services efficiently and optimize storage requirements
Last updated
Below are a few tips on how to efficiently structure applications consisting of multiple containers, which are described in more detail down below:
Package your services that are docker images into a single application. This ensures that the user only needs to handle a single .auterionos
file.
Write a common base Dockerfile
for a shared environment used by your services. This ensures that the resulting .auterionos
file, as well as the storage space requirements after installation are as low as possible.
While your app can be composed of multiple docker containers, we advise that they are all packaged into a single Application. The user should only need to handle a single .auterionos
file when installing or updating your application. This brings a few benefits:
You can specify the launch order of the individual docker containers, in case some services rely on others
You can provide all your services at the exact version required for a specific release of the application
There is no risk of your application being installed incompletely
There is no risk of your application being updated only partially, resulting in a mismatch of the services inside
Build and tag the required docker images / micro-services in the :
In the Makefile's target rule for building your application, you need to export all services as a single image, for example:
In the context of Skynode and AuterionOS, identifying, breaking out and reusing base images in your application brings the following advantages:
Your app uses less space on Skynode, because the base needs to be stored only once in Docker
Example folder structure using a base Dockerfile and services:
Create Dockerfile.base that defines a common environment for your micro-service's images:
Create one Dockerfile for each of your services and reuse the base image:
In the Makefile, build the base image as well as your services:
Last but not least include all services the file:
Take a look at the to see this in action.
Docker builds its images using layers. Images that share the same base image can therefore reuse its layers, thus saving storage space. More details can be found in .
Smaller download size of your app, which saves time and bandwidth for downloading files, and speeds up the installation process. This benefit is only achieved when all .
Combine the use of base images with the method for to achieve the most compact .auterionos files.