From aec80dddc0416722a421330316003f27cf0c566b Mon Sep 17 00:00:00 2001 From: Graham Christensen Date: Mon, 16 Dec 2019 12:47:47 -0500 Subject: dockerTools.buildLayeredImage: pass a list of closures to mkManyPureLayers so it can exclude the top-most level Before, every docker image had three extra layers: 1. A `closure` layer which is an internal implementation detail of calculating the closure of the container 2. a `name-config.json` layer which is the images' run-time configuration, and has no business being *in* the image as a layer. 3. a "bulk-layers" layer which is again and implementation detail around collecting the image's closure. None of these layers need to be in the final product. --- pkgs/build-support/docker/default.nix | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'pkgs/build-support/docker') diff --git a/pkgs/build-support/docker/default.nix b/pkgs/build-support/docker/default.nix index 0781c7dd4f1..77edbb76601 100644 --- a/pkgs/build-support/docker/default.nix +++ b/pkgs/build-support/docker/default.nix @@ -290,7 +290,7 @@ rec { mkManyPureLayers = { name, # Files to add to the layer. - closure, + closures, configJson, # Docker has a 125-layer maximum, we pick 100 to ensure there is # plenty of room for extension. @@ -303,10 +303,12 @@ rec { isExecutable = true; src = ./store-path-to-layer.sh; }; + + overallClosure = writeText "closure" (lib.concatStringsSep " " closures); in runCommand "${name}-granular-docker-layers" { inherit maxLayers; - paths = referencesByPopularity closure; + paths = referencesByPopularity overallClosure; nativeBuildInputs = [ jshon rsync tarsum ]; enableParallelBuilding = true; } @@ -558,7 +560,7 @@ rec { bulkLayers = mkManyPureLayers { name = baseName; - closure = writeText "closure" "${contentsEnv} ${configJson}"; + closures = [ contentsEnv configJson ]; # One layer will be taken up by the customisationLayer, so # take up one less. maxLayers = maxLayers - 1; -- cgit 1.4.1