Merge pull request #80102 from nlewo/fix-78744
dockerTools.buildLayeredImage: store all paths passed in final layer (fix 78744)
This commit is contained in:
commit
d49804cf45
@ -83,5 +83,11 @@ import ./make-test.nix ({ pkgs, ... }: {
|
|||||||
|
|
||||||
# Ensure image with only 2 layers can be loaded
|
# Ensure image with only 2 layers can be loaded
|
||||||
$docker->succeed("docker load --input='${pkgs.dockerTools.examples.two-layered-image}'");
|
$docker->succeed("docker load --input='${pkgs.dockerTools.examples.two-layered-image}'");
|
||||||
|
|
||||||
|
# Ensure the bulk layer didn't miss store paths
|
||||||
|
# Regression test for https://github.com/NixOS/nixpkgs/issues/78744
|
||||||
|
$docker->succeed("docker load --input='${pkgs.dockerTools.examples.bulk-layer}'");
|
||||||
|
# This ensure the two output paths (ls and hello) are in the layer
|
||||||
|
$docker->succeed("docker run bulk-layer ls /bin/hello");
|
||||||
'';
|
'';
|
||||||
})
|
})
|
||||||
|
@ -246,4 +246,16 @@ rec {
|
|||||||
contents = [ pkgs.bash pkgs.hello ];
|
contents = [ pkgs.bash pkgs.hello ];
|
||||||
maxLayers = 2;
|
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
|
layerNumber=$1
|
||||||
shift
|
shift
|
||||||
|
|
||||||
storePath="$1"
|
|
||||||
shift
|
|
||||||
|
|
||||||
layerPath="./layers/$layerNumber"
|
layerPath="./layers/$layerNumber"
|
||||||
echo "Creating layer #$layerNumber for $storePath"
|
echo "Creating layer #$layerNumber for $@"
|
||||||
|
|
||||||
mkdir -p "$layerPath"
|
mkdir -p "$layerPath"
|
||||||
|
|
||||||
@ -35,13 +32,15 @@ tar -cf "$layerPath/layer.tar" \
|
|||||||
# to /nix/store. In order to create the correct structure
|
# to /nix/store. In order to create the correct structure
|
||||||
# in the tar file, we transform the relative nix store
|
# in the tar file, we transform the relative nix store
|
||||||
# path to the absolute store path.
|
# path to the absolute store path.
|
||||||
n=$(basename "$storePath")
|
for storePath in "$@"; do
|
||||||
tar -C /nix/store -rpf "$layerPath/layer.tar" \
|
n=$(basename "$storePath")
|
||||||
--hard-dereference --sort=name \
|
tar -C /nix/store -rpf "$layerPath/layer.tar" \
|
||||||
--mtime="@$SOURCE_DATE_EPOCH" \
|
--hard-dereference --sort=name \
|
||||||
--owner=0 --group=0 \
|
--mtime="@$SOURCE_DATE_EPOCH" \
|
||||||
--transform="s,$n,/nix/store/$n," \
|
--owner=0 --group=0 \
|
||||||
$n
|
--transform="s,$n,/nix/store/$n," \
|
||||||
|
$n
|
||||||
|
done
|
||||||
|
|
||||||
# Compute a checksum of the tarball.
|
# Compute a checksum of the tarball.
|
||||||
tarhash=$(tarsum < $layerPath/layer.tar)
|
tarhash=$(tarsum < $layerPath/layer.tar)
|
||||||
|
Loading…
Reference in New Issue
Block a user