# Build a container image that has extra testing stuff in it, such
# as nushell, some preset logically bound images, etc. This expects
# to create an image derived FROM localhost/bootc which was created
# by the Dockerfile at top.

FROM scratch as context
# We only need this stuff in the initial context
COPY . /

# An intermediate layer which caches the extended RPMS
FROM localhost/bootc as extended
# And this layer has additional stuff for testing, such as nushell etc.
RUN --mount=type=bind,from=context,target=/run/context <<EORUN
set -xeuo pipefail
cd /run/context/
./provision-derived.sh
EORUN

# And the configs
FROM extended
RUN --mount=type=bind,from=context,target=/run/context <<EORUN
set -xeuo pipefail
cd /run/context
# For test-22-logically-bound-install
cp -a lbi/usr/. /usr
for x in curl.container curl-base.image podman.image; do
    ln -s /usr/share/containers/systemd/$x /usr/lib/bootc/bound-images.d/$x
done

# Add some testing kargs into our dev builds
install -D -t /usr/lib/bootc/kargs.d test-kargs/*
# Also copy in some default install configs we use for testing
install -D -t /usr/lib/bootc/install/ install-test-configs/*
# Finally, test our own linting
bootc container lint --fatal-warnings
EORUN
