dockerTools: take a list of images in mergeImages
This commit is contained in:
parent
ecc293ff7a
commit
dcc9aef015
@ -682,27 +682,26 @@ rec {
|
|||||||
in
|
in
|
||||||
result;
|
result;
|
||||||
|
|
||||||
# Merge the tarballs of two images built with buildImage into a single
|
# Merge the tarballs of images built with buildImage into a single
|
||||||
# tarball that contains both images. Running `docker load` on the resulting
|
# tarball that contains all images. Running `docker load` on the resulting
|
||||||
# tarball with load both images into the docker daemon.
|
# tarball will load the images into the docker daemon.
|
||||||
mergeImages = a: b: runCommand "merge-docker-images"
|
mergeImages = images: runCommand "merge-docker-images"
|
||||||
{
|
{
|
||||||
|
inherit images;
|
||||||
nativeBuildInputs = [ pigz jq ];
|
nativeBuildInputs = [ pigz jq ];
|
||||||
} ''
|
} ''
|
||||||
mkdir a b image
|
mkdir image inputs
|
||||||
# Extract images
|
# Extract images
|
||||||
tar -I pigz -xf ${a} -C a
|
for item in $images; do
|
||||||
tar -I pigz -xf ${b} -C b
|
mkdir inputs/$(basename $item)
|
||||||
# Make writable (to enable mv)
|
tar -I pigz -xf $item -C inputs/$(basename $item)
|
||||||
chmod -R +w a b
|
done
|
||||||
# Merge repositories objects (image:tag -> hash)
|
# Copy all layers from input images to output image directory
|
||||||
jq -s add a/repositories b/repositories > repositories
|
cp -R --no-clobber inputs/*/* image/
|
||||||
# Merge docker images manifests ([image])
|
# Merge repositories objects and manifests
|
||||||
jq -s add a/manifest.json b/manifest.json > manifest.json
|
jq -s add inputs/*/repositories > repositories
|
||||||
# Move layers to output directory
|
jq -s add inputs/*/manifest.json > manifest.json
|
||||||
mv --no-clobber a/* image/
|
# Replace output image repositories and manifest with merged versions
|
||||||
mv --no-clobber b/* image/
|
|
||||||
# Move merged repositories object and manifest list to output directory
|
|
||||||
mv repositories image/repositories
|
mv repositories image/repositories
|
||||||
mv manifest.json image/manifest.json
|
mv manifest.json image/manifest.json
|
||||||
# Create tarball and gzip
|
# Create tarball and gzip
|
||||||
|
Loading…
x
Reference in New Issue
Block a user