aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2015-08-20 18:26:14 +0000
committerGerrit Code Review <review@openstack.org>2015-08-20 18:26:14 +0000
commitdf6708560c53267d874bc7f43b871b3314d44bf8 (patch)
treeb55a2eb042d9f0eed38b2a7bce082d4738969e4d
parent2b01412ab9ae0257f2f76970b189b1668f324a28 (diff)
parent49a9fba23ee5440fb3bc2bfadc0714a311f981e1 (diff)
downloadkolla-df6708560c53267d874bc7f43b871b3314d44bf8.tar.gz
kolla-df6708560c53267d874bc7f43b871b3314d44bf8.zip
Merge "Allow Docker to make better use of cache"
-rwxr-xr-xtools/build.py15
1 files changed, 15 insertions, 0 deletions
diff --git a/tools/build.py b/tools/build.py
index 89cffc061..63477a148 100755
--- a/tools/build.py
+++ b/tools/build.py
@@ -80,6 +80,9 @@ class WorkerThread(Thread):
'Failed to download tarball: status_code {}'.format(
r.status_code))
+ # Set time on destination tarball to epoch 0
+ os.utime(os.path.join(dest_dir, source['dest']), (0, 0))
+
def builder(self, image):
LOG.info('Processing: {}'.format(image['name']))
image['status'] = "building"
@@ -204,6 +207,14 @@ class KollaWorker(object):
shutil.copytree(self.images_dir, self.working_dir)
LOG.debug('Created working dir: {}'.format(self.working_dir))
+ def set_time(self):
+ for root, dirs, files in os.walk(self.working_dir):
+ for file_ in files:
+ os.utime(os.path.join(root, file_), (0, 0))
+ for dir_ in dirs:
+ os.utime(os.path.join(root, dir_), (0, 0))
+ LOG.debug('Set atime and mtime to 0 for all content in working dir')
+
def createDockerfiles(self):
for path in self.docker_build_paths:
template_name = "Dockerfile.j2"
@@ -390,6 +401,10 @@ def main():
if args['template']:
kolla.createDockerfiles()
+ # We set the atime and mtime to 0 epoch to preserve allow the Docker cache
+ # to work like we want. A different size or hash will still force a rebuild
+ kolla.set_time()
+
pools = kolla.buildQueues()
# Returns a list of Queues for us to loop through