@@ -201,6 +201,65 @@ process the ``Dockerfile`` and handle the special syntax. Whereas the
201201only generated once and then re-used by all subsequent pushes until the image
202202is modified.
203203
204+ Layering images on top of each other
205+ ....................................
206+
207+ The `parent ` value on a docker-image task can refer to another image's `name `.
208+ The parent image can then be referenced from the dependent image's Dockerfile
209+ as `$DOCKER_IMAGE_PARENT `. Whenever the base image's definition (or
210+ something it includes) changes, that automatically also triggers a
211+ rebuild of the dependent image.
212+
213+ For example, `kind.yml ` could include:
214+
215+ .. code-block :: yaml
216+
217+ tasks :
218+ base :
219+ symbol : I(base)
220+ extras :
221+ symbol : I(extras)
222+ parent : base
223+
224+ And the `extras ` image's Dockerfile:
225+
226+ .. code-block ::
227+
228+ FROM $DOCKER_IMAGE_PARENT
229+
230+ RUN apt-get update && apt-get install -y extra software && apt-get clean
231+
232+
233+ .. note ::
234+ The `taskgraph build-image ` command doesn't handle this syntax, so it won't work for those images.
235+ In taskcluster this is handled by the image_builder tool, see
236+ `the image_builder docker image <https://hub.docker.com/r/mozillareleases/image_builder >`_ and
237+ `its source code <https://searchfox.org/mozilla-central/source/taskcluster/docker/image_builder >`_.
238+
239+
240+ Reusing image definitions
241+ .........................
242+
243+ The same `Dockerfile ` can be used for multiple images, by setting `definition `, for example:
244+
245+ .. code-block :: yaml
246+
247+ tasks :
248+ debian12 :
249+ symbol : I(deb12)
250+ definition : debian
251+ args :
252+ BASE_IMAGE : debian:12
253+ debian11 :
254+ symbol : I(deb11)
255+ definition : debian
256+ args :
257+ BASE_IMAGE : debian:11
258+
259+ Both the `debian11 ` and `debian12 ` images will be built from the definition in
260+ `taskcluster/docker/debian `, but they'll be passed different `BASE_IMAGE `
261+ variables (as in `docker build --build-arg `).
262+
204263Context Directory Hashing
205264~~~~~~~~~~~~~~~~~~~~~~~~~
206265
0 commit comments