Merge pull request #80102 from nlewo/fix-78744

dockerTools.buildLayeredImage: store all paths passed in final layer (fix 78744)
This commit is contained in:
lewo
2020-02-14 09:48:52 +01:00
committed by GitHub
3 changed files with 28 additions and 11 deletions
+12
View File
@@ -246,4 +246,16 @@ rec {
contents = [ pkgs.bash pkgs.hello ];
maxLayers = 2;
};
# 16. Create a layered image with more packages than max layers.
# coreutils and hello are part of the same layer
bulk-layer = pkgs.dockerTools.buildLayeredImage {
name = "bulk-layer";
tag = "latest";
contents = with pkgs; [
coreutils hello
];
maxLayers = 2;
};
}
@@ -5,11 +5,8 @@ set -eu
layerNumber=$1
shift
storePath="$1"
shift
layerPath="./layers/$layerNumber"
echo "Creating layer #$layerNumber for $storePath"
echo "Creating layer #$layerNumber for $@"
mkdir -p "$layerPath"
@@ -35,13 +32,15 @@ tar -cf "$layerPath/layer.tar" \
# to /nix/store. In order to create the correct structure
# in the tar file, we transform the relative nix store
# path to the absolute store path.
n=$(basename "$storePath")
tar -C /nix/store -rpf "$layerPath/layer.tar" \
--hard-dereference --sort=name \
--mtime="@$SOURCE_DATE_EPOCH" \
--owner=0 --group=0 \
--transform="s,$n,/nix/store/$n," \
$n
for storePath in "$@"; do
n=$(basename "$storePath")
tar -C /nix/store -rpf "$layerPath/layer.tar" \
--hard-dereference --sort=name \
--mtime="@$SOURCE_DATE_EPOCH" \
--owner=0 --group=0 \
--transform="s,$n,/nix/store/$n," \
$n
done
# Compute a checksum of the tarball.
tarhash=$(tarsum < $layerPath/layer.tar)