-
Notifications
You must be signed in to change notification settings - Fork 115
Open
Labels
Description
The Dockerfiles in this repo have A LOT of content that is common between them, or at least a subset of them. Just a couple of examples:
- The Debian packages that get installed in the Helix Dockerfiles are all the same between the different Debian versions.
- Creation of the helixbot user between the Dockerfiles is (roughly) the same.
Having Dockerfiles that all contain their own implementation leads to the danger of inconsistency amongst the whole set. It's also just extra work on behalf of the contributor to have to apply the changes across Dockerfiles (this change had to be applied the same across 21 Dockerfiles: #1390).
We should consider options to solve this problem. There are several things to be considered:
- Use of
ARGto parameterize the Dockerfiles: Consider utilizing parameterized Dockerfiles as a means to reduce duplication #231. This solves things only partially and is really only good for simple value replacement like a version number, not for something like a set of commands to be executed. One problem is that image caching doesn't support the use ofARG: Image caching doesn't account for build args docker-tools#1505. - Encapsulating common logic in scripts that can be executed by multiple Dockerfiles that need that logic. This is nice, but there other elements of Dockerfiles that are common besides just script logic such as setting of
ENVvars or just common multi-stage patterns. These script files would also not be supported by image caching: Image caching support for copied local files docker-tools#1270. In order to use a script by multiple Dockerfiles, you'd also need a way to set the build context to copy in the script which requires Add abuildContextoption to Platform in Manifest docker-tools#1592. - Implement Dockerfile templates. Image Builder supports this already and is used by dotnet-docker. But there is a desire to migrate to a different templating language: Migrate off of Cottle templating engine docker-tools#1610. Templates solve the shortcomings of
ARGand scripts.
am11, lbussell and MichaelSimons