mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-11-25 16:33:15 +00:00
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
|
||||
$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 ];
|
||||
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)
|
||||
|
Loading…
Reference in New Issue
Block a user