summaryrefslogtreecommitdiff
path: root/docker/utils
diff options
context:
space:
mode:
authorMarcus Cobden <marcus@marcuscobden.co.uk>2014-11-04 10:02:24 +0000
committerMarcus Cobden <marcus@marcuscobden.co.uk>2014-11-04 10:02:24 +0000
commitdacaa583fba562fd071cf200088df3a5384680c2 (patch)
tree2977209bfaa703bc6d80e58bd1c9972b053e391e /docker/utils
parent00e3ff9574b12e2321c0f3db55498a3ffa43a713 (diff)
downloaddocker-py-dacaa583fba562fd071cf200088df3a5384680c2.tar.gz
Walk file tree in order for deterministic builds
Python's `os.walk` does not order the lists of files and directories it returns, so in order to produce a consistent build context tarfile, they should be ordered.
Diffstat (limited to 'docker/utils')
-rw-r--r--docker/utils/utils.py3
1 files changed, 2 insertions, 1 deletions
diff --git a/docker/utils/utils.py b/docker/utils/utils.py
index 0853ac4..7cd3b1a 100644
--- a/docker/utils/utils.py
+++ b/docker/utils/utils.py
@@ -72,7 +72,8 @@ def tar(path, exclude=None):
fnames = [name for name in filenames
if not fnmatch_any(os.path.join(relpath, name),
exclude)]
- for name in fnames:
+ dirnames.sort()
+ for name in sorted(fnames):
arcname = os.path.join(relpath, name)
t.add(os.path.join(path, arcname), arcname=arcname)
for name in dirnames: