Update 'src/dkr_functions.bash'

This commit is contained in:
Garrett Mills 2024-08-26 21:41:19 +00:00
parent 6921d090dd
commit 51cf20f8f4

View File

@ -16,10 +16,22 @@ function dkr::import_fs_as_layer() {
# tar path = $1 # tar path = $1
# base image = $2 # base image = $2
# final image = $3 # final image = $3
# whiteout file = $4
docker image import "$1" docker-isolate-flat-temp:latest > /dev/null docker image import "$1" docker-isolate-flat-temp:latest > /dev/null
echo "FROM docker-isolate-flat-temp:latest as isolated" > Dockerfile echo "FROM docker-isolate-flat-temp:latest as isolated" > Dockerfile
echo "FROM $2 as from_image" >> Dockerfile echo "FROM $2 as from_image" >> Dockerfile
echo "COPY --from=isolated / /" >> Dockerfile echo "COPY --from=isolated / /" >> Dockerfile
local WHITEOUT
if [ -n "${4:-}" ]; then
# Convert "./path/to/.wh.file" to "/path/to/file"
WHITEOUT="$(awk '{gsub(/\.wh\./, "", $0); sub(/^\./, "", $0); printf "\"%s\" ", $0}' "$4")"
if [ -n "$WHITEOUT" ]; then
echo "RUN rm -f $WHITEOUT" >> Dockerfile
fi
fi
docker image build -f Dockerfile -t "$3" . > /dev/null docker image build -f Dockerfile -t "$3" . > /dev/null
docker image rm -f docker-isolate-flat-temp:latest > /dev/null docker image rm -f docker-isolate-flat-temp:latest > /dev/null
rm -f Dockerfile rm -f Dockerfile