mirror of
https://github.com/ilyakooo0/nixpkgs.git
synced 2024-12-27 13:57:10 +03:00
Merge pull request #24947 from timclassic/docker-repro
docker: improve reproducibility of layers
This commit is contained in:
commit
8cf393bf48
@ -209,7 +209,7 @@ rec {
|
|||||||
|
|
||||||
postMount = ''
|
postMount = ''
|
||||||
echo "Packing raw image..."
|
echo "Packing raw image..."
|
||||||
tar -C mnt --mtime=0 -cf $out .
|
tar -C mnt --mtime="@$SOURCE_DATE_EPOCH" -cf $out .
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -247,7 +247,7 @@ rec {
|
|||||||
echo "Adding contents..."
|
echo "Adding contents..."
|
||||||
for item in $contents; do
|
for item in $contents; do
|
||||||
echo "Adding $item"
|
echo "Adding $item"
|
||||||
rsync -ak $item/ layer/
|
rsync -ak --chown=0:0 $item/ layer/
|
||||||
done
|
done
|
||||||
else
|
else
|
||||||
echo "No contents to add to layer."
|
echo "No contents to add to layer."
|
||||||
@ -260,7 +260,7 @@ rec {
|
|||||||
# Tar up the layer and throw it into 'layer.tar'.
|
# Tar up the layer and throw it into 'layer.tar'.
|
||||||
echo "Packing layer..."
|
echo "Packing layer..."
|
||||||
mkdir $out
|
mkdir $out
|
||||||
tar -C layer --mtime=0 -cf $out/layer.tar .
|
tar -C layer --mtime="@$SOURCE_DATE_EPOCH" -cf $out/layer.tar .
|
||||||
|
|
||||||
# Compute a checksum of the tarball.
|
# Compute a checksum of the tarball.
|
||||||
echo "Computing layer checksum..."
|
echo "Computing layer checksum..."
|
||||||
@ -310,7 +310,7 @@ rec {
|
|||||||
echo "Adding contents..."
|
echo "Adding contents..."
|
||||||
for item in ${toString contents}; do
|
for item in ${toString contents}; do
|
||||||
echo "Adding $item..."
|
echo "Adding $item..."
|
||||||
rsync -ak $item/ layer/
|
rsync -ak --chown=0:0 $item/ layer/
|
||||||
done
|
done
|
||||||
'';
|
'';
|
||||||
|
|
||||||
@ -340,7 +340,7 @@ rec {
|
|||||||
|
|
||||||
echo "Packing layer..."
|
echo "Packing layer..."
|
||||||
mkdir $out
|
mkdir $out
|
||||||
tar -C layer --mtime=0 -cf $out/layer.tar .
|
tar -C layer --mtime="@$SOURCE_DATE_EPOCH" -cf $out/layer.tar .
|
||||||
|
|
||||||
# Compute the tar checksum and add it to the output json.
|
# Compute the tar checksum and add it to the output json.
|
||||||
echo "Computing checksum..."
|
echo "Computing checksum..."
|
||||||
@ -467,7 +467,8 @@ rec {
|
|||||||
comm <(sort -n baseFiles|uniq) \
|
comm <(sort -n baseFiles|uniq) \
|
||||||
<(sort -n layerFiles|uniq|grep -v ${layer}) -1 -3 > newFiles
|
<(sort -n layerFiles|uniq|grep -v ${layer}) -1 -3 > newFiles
|
||||||
# Append the new files to the layer.
|
# Append the new files to the layer.
|
||||||
tar -rpf temp/layer.tar --mtime=0 --no-recursion --files-from newFiles
|
tar -rpf temp/layer.tar --mtime="@$SOURCE_DATE_EPOCH" \
|
||||||
|
--owner=0 --group=0 --no-recursion --files-from newFiles
|
||||||
|
|
||||||
echo "Adding meta..."
|
echo "Adding meta..."
|
||||||
|
|
||||||
@ -496,7 +497,7 @@ rec {
|
|||||||
chmod -R a-w image
|
chmod -R a-w image
|
||||||
|
|
||||||
echo "Cooking the image..."
|
echo "Cooking the image..."
|
||||||
tar -C image --mtime=0 -c . | pigz -nT > $out
|
tar -C image --mtime="@$SOURCE_DATE_EPOCH" -c . | pigz -nT > $out
|
||||||
|
|
||||||
echo "Finished."
|
echo "Finished."
|
||||||
'';
|
'';
|
||||||
|
Loading…
Reference in New Issue
Block a user