I'm building docker images for our servers, and I'm looking for the best practices related to multi environments support, when creating the DOCKERFILE(s).
The main purpose of the servers is to run LAMP on top of Centos 6, and I want to make the DOCKERFILE(s) as generic as possible to support both development and production environments. The images will have lot of common configurations / utils, and some differences.
Differences for example:
- Production only: monitoring tools, AntiVirus and different LAMP configurations
- Development only: xdebug, profiling utils and different LAMP configurations
I thought about using something like the following structure:
- Customized Base OS (C1)
- Prod. Base OS (C1E1)
- Dev. Base OS (C1E2)
- Web image (httpd, apache..) (C2)
- Prod. adjustments (C2E1)
- Dev. adjustments (C2E2)
- DB image (C3)
- Prod. adjustments (C3E1)
- Dev. adjustments (C3E2)
- Data image (C4)
- Prod. adjustments (C4E1)
- Dev. adjustments (C4E2)
- Samba image (dev. only) (C5)
but as you can see, it is impossible to do it with the current inheritance mechanism, and even if it was, it is not maintainable.
I can't find a way to use ENV conditions within a DOCKERFILE (only with Linux based conditions in the RUN command for example).
At the moment I'm using the following structure:
- Base Image (Common things, such as LAMP, utils..)
- Dev. Image (Dev. specific utils / configuration)
- Prod. Image (Prod. specific ...)
Are there any best practices for the above? Duplication of images (double maintenance) is the only possibility?