From 9bca6e5bbc46b40e7d83820e179fb84680b7b74c Mon Sep 17 00:00:00 2001 From: Mike Aizatsky Date: Thu, 6 Oct 2016 14:57:40 -0700 Subject: [PATCH] [infra] flattening base-clang image The image has lots of layers with lots of deleted files (sources and intermediates). Flatten the image to reduce its size. --- infra/base-images/Jenkinsfile | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/infra/base-images/Jenkinsfile b/infra/base-images/Jenkinsfile index 32020f747..9711a26ce 100644 --- a/infra/base-images/Jenkinsfile +++ b/infra/base-images/Jenkinsfile @@ -18,6 +18,16 @@ def dockerOptions="--no-cache" +// Flattens all intermediate layers of the image. +// Usefull when image has lots of deleted files. +def flattenDockerImage(image) { + def containerName = image.replaceAll('/', '_') + "-tmp"; + sh "echo ${image} ${containerName}" + sh "docker rm -f ${containerName} || true" + sh "docker run --name ${containerName} ${image} /bin/true" + sh "docker export ${containerName} | docker import - ${image}" +} + node { git url: 'https://github.com/google/oss-fuzz/' @@ -27,6 +37,8 @@ node { stage name: 'Build ossfuzz/base-clang', concurrency: 1 sh "docker build $dockerOptions -t ossfuzz/base-clang infra/base-images/base-clang" + flattenDockerImage("ossfuzz/base-clang") + stage name: 'Build ossfuzz/base-libfuzzer', concurrency: 1 sh "docker build $dockerOptions -t ossfuzz/base-libfuzzer infra/base-images/base-libfuzzer"