diff --git a/src/dkr_functions.bash b/src/dkr_functions.bash index e32e952..61a86e2 100644 --- a/src/dkr_functions.bash +++ b/src/dkr_functions.bash @@ -16,10 +16,22 @@ function dkr::import_fs_as_layer() { # tar path = $1 # base image = $2 # final image = $3 + # whiteout file = $4 + docker image import "$1" docker-isolate-flat-temp:latest > /dev/null echo "FROM docker-isolate-flat-temp:latest as isolated" > Dockerfile echo "FROM $2 as from_image" >> 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 rm -f docker-isolate-flat-temp:latest > /dev/null rm -f Dockerfile