summary refs log tree commit diff
path: root/pkgs/build-support/docker
diff options
context:
space:
mode:
authorGraham Christensen <graham@grahamc.com>2019-12-16 12:47:47 -0500
committerGraham Christensen <graham@grahamc.com>2019-12-16 12:48:05 -0500
commitaec80dddc0416722a421330316003f27cf0c566b (patch)
treea0de86468c5bd57a6758186d7d930a21a2a58b42 /pkgs/build-support/docker
parentf6d75f550ebcea9145b5b63473ce2652e580a44e (diff)
downloadnixpkgs-aec80dddc0416722a421330316003f27cf0c566b.tar
nixpkgs-aec80dddc0416722a421330316003f27cf0c566b.tar.gz
nixpkgs-aec80dddc0416722a421330316003f27cf0c566b.tar.bz2
nixpkgs-aec80dddc0416722a421330316003f27cf0c566b.tar.lz
nixpkgs-aec80dddc0416722a421330316003f27cf0c566b.tar.xz
nixpkgs-aec80dddc0416722a421330316003f27cf0c566b.tar.zst
nixpkgs-aec80dddc0416722a421330316003f27cf0c566b.zip
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.
Diffstat (limited to 'pkgs/build-support/docker')
-rw-r--r--pkgs/build-support/docker/default.nix8
1 files changed, 5 insertions, 3 deletions
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;