mirror of
https://github.com/ilyakooo0/nixpkgs.git
synced 2024-12-28 06:14:26 +03:00
dockerTools.buildLayeredImage: Avoid appending to tarballs when building layers
Appending to an existing tar archive repeatedly seems to be a quadratic operation, since tar seems to traverse the existing archive even using the `-r, --append` flag. This commit avoids that by passing the list of files to a single tar invocation.
This commit is contained in:
parent
defdda6f93
commit
69f6294724
@ -32,15 +32,13 @@ 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.
|
||||
for storePath in "$@"; do
|
||||
n=$(basename "$storePath")
|
||||
basename -a "$@" |
|
||||
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
|
||||
--verbatim-files-from --files-from - \
|
||||
--hard-dereference --sort=name \
|
||||
--mtime="@$SOURCE_DATE_EPOCH" \
|
||||
--owner=0 --group=0 \
|
||||
--transform="flags=rS;s,^,/nix/store/,"
|
||||
|
||||
# Compute a checksum of the tarball.
|
||||
tarhash=$(tarsum < $layerPath/layer.tar)
|
||||
|
Loading…
Reference in New Issue
Block a user