dockerTools.buildLayeredImage: fix image with only 2 layers
A test is also added to ensure an image with 2 layers can be built.
This commit is contained in:
@@ -315,7 +315,7 @@ rec {
|
||||
runCommand "${name}-granular-docker-layers" {
|
||||
inherit maxLayers;
|
||||
paths = referencesByPopularity overallClosure;
|
||||
nativeBuildInputs = [ jshon rsync tarsum ];
|
||||
nativeBuildInputs = [ jshon rsync tarsum moreutils ];
|
||||
enableParallelBuilding = true;
|
||||
}
|
||||
''
|
||||
@@ -335,7 +335,8 @@ rec {
|
||||
cat $paths ${lib.concatMapStringsSep " " (path: "| grep -v ${path}") (closures ++ [ overallClosure ])}
|
||||
}
|
||||
|
||||
paths | head -n $((maxLayers - 1)) | cat -n | xargs -P$NIX_BUILD_CORES -n2 ${storePathToLayer}
|
||||
# We need to sponge to avoid grep broken pipe error when maxLayers == 1
|
||||
paths | sponge | head -n $((maxLayers - 1)) | cat -n | xargs -r -P$NIX_BUILD_CORES -n2 ${storePathToLayer}
|
||||
if [ $(paths | wc -l) -ge $maxLayers ]; then
|
||||
paths | tail -n+$maxLayers | xargs ${storePathToLayer} $maxLayers
|
||||
fi
|
||||
|
||||
Reference in New Issue
Block a user