Update 'src/isolate.bash'

This commit is contained in:
Garrett Mills 2024-08-26 21:43:07 +00:00
parent 51cf20f8f4
commit 25a5446089

View File

@ -56,10 +56,20 @@ function app::dlt::isolate() {
tar xf "../to_image/${raw_layer}" tar xf "../to_image/${raw_layer}"
done done
# Create a tarball w/ the isolated files (special find magic to avoid the leading ./ on paths) # DOCKER BACKGROUND: When you export an image layer to a tarball, Docker creates
# special "whiteout" placeholder files to represent files that were deleted in that
# layer. These files are prefixed with `.wh.`.
# Due to our shenanigans, we need to handle these manually since we're importing the
# tarball directly in as a single image, so the whiteout files are ever removed.
# Instead, let's extract them to a list so we can rm them manually during the build step.
g::info 'Building white-out list'
find . -name '.wh.*' > ../whiteout.list
xargs -a ../whiteout.list rm -f
# Create a tarball w/ the isolated files
g::info 'Creating archive' g::info 'Creating archive'
tar cf ../isolated.tar .
cd .. cd ..
find isolated/ \( -type f -o -type d \) -printf "%P\n" | tar cf isolated.tar -C isolated/ -T -
# Do a bit of cleanup # Do a bit of cleanup
rm -rf to_image from_image isolated rm -rf to_image from_image isolated
@ -72,7 +82,7 @@ function app::dlt::isolate() {
docker image import isolated.tar "$as_image" > /dev/null docker image import isolated.tar "$as_image" > /dev/null
else else
g::info "Creating image $as_image on top of $from_image" g::info "Creating image $as_image on top of $from_image"
dkr::import_fs_as_layer isolated.tar "$from_image" "$as_image" dkr::import_fs_as_layer isolated.tar "$from_image" "$as_image" whiteout.list
fi fi
fi fi