mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-24 10:45:42 +00:00
fc3f70b542
A limitation of traditional docker build context generation is it only includes files from the same directory as the Dockerfile. When repositories have multiple, related Dockerfiles, this limitation results file duplication or putting all Dockerfiles in the same directory (which isn't feasible for mozilla-central since they would need to be in the root directory). This commit enhances Dockerfiles to allow *any* file from the repository checkout to be ADDed to the docker build context. Using the syntax "# %include <path>" you are able to include paths or directories (relative from the top source directory root) in the generated context archive. Files add this way are available under the "topsrcdir/" path and can be ADDed to Docker images. Since context archive generation is deterministic and the hash of the resulting archive is used to determine when images need to be rebuilt, any extra included file that changes will change the hash of the context archive and force image regeneration. Basic tests for the new feature have been added. MozReview-Commit-ID: 4hPZesJuGQV --HG-- extra : rebase_source : 99fae9fe82102126fbee879c134981047bb4a601
43 lines
1.3 KiB
ReStructuredText
43 lines
1.3 KiB
ReStructuredText
.. taskcluster_dockerimages:
|
|
|
|
=============
|
|
Docker Images
|
|
=============
|
|
|
|
TaskCluster Docker images are defined in the source directory under
|
|
``testing/docker``. Each directory therein contains the name of an
|
|
image used as part of the task graph.
|
|
|
|
Adding Extra Files to Images
|
|
============================
|
|
|
|
Dockerfile syntax has been extended to allow *any* file from the
|
|
source checkout to be added to the image build *context*. (Traditionally
|
|
you can only ``ADD`` files from the same directory as the Dockerfile.)
|
|
|
|
Simply add the following syntax as a comment in a Dockerfile::
|
|
|
|
# %include <path>
|
|
|
|
e.g.
|
|
|
|
# %include mach
|
|
# %include testing/mozharness
|
|
|
|
The argument to ``# %include`` is a relative path from the root level of
|
|
the source directory. It can be a file or a directory. If a file, only that
|
|
file will be added. If a directory, every file under that directory will be
|
|
added (even files that are untracked or ignored by version control).
|
|
|
|
Files added using ``# %include`` syntax are available inside the build
|
|
context under the ``topsrcdir/`` path.
|
|
|
|
Files are added as they exist on disk. e.g. executable flags should be
|
|
preserved. However, the file owner/group is changed to ``root`` and the
|
|
``mtime`` of the file is normalized.
|
|
|
|
Here is an example Dockerfile snippet::
|
|
|
|
# %include mach
|
|
ADD topsrcdir/mach /home/worker/mach
|