# Test coverage provided by this container:
# - musl (instead of glibc)
# - openrc (instead of systemd)
# - eudev (instead of systemd-udev)
# - elogind (instead of logind)
# - busybox default shell (no dash installed)
# - gzip compression
# - dbus-daemon
# - network: networkmanager

# Not installed
# - dash (to increase coverage)
# - ntfs-3g (not enabled with linux-virt)
# - erofs-utils (not enabled with linux-virt)
# - multipath-tools (does not work well)
# - kernel-install is not available

FROM docker.io/alpine:edge

# export
ARG TARGETARCH
ARG OPTION

# Use dracut-tests package to install dependencies for test suite
RUN apk add --no-cache \
    alpine-base \
    build-base \
    cargo \
    curl \
    dnsmasq \
    dracut-tests \
    efistub \
    ukify

RUN \
if [ "${TARGETARCH}" == "amd64" ]; then \
    apk add --no-cache \
        ovmf \
; fi

# workaround for https://gitlab.alpinelinux.org/alpine/aports/-/issues/17907
RUN \
  ln -sf /boot/vmlinuz-virt /boot/vmlinuz-$(cd /lib/modules; ls -1 | tail -1)

# busybox container
# replace GNU coreutils, util-linux, kmod binaries with busybox binaries
RUN \
if [ "$OPTION" == "busybox" ] ; then \
  mkdir /busybox && cd /busybox && /bin/busybox --install -s /busybox ;\
  cp -a /busybox/* /bin/ ;\
  cp -a /busybox/* /sbin/ ;\
  cp -a /busybox/* /usr/bin/ ;\
  cp -a /busybox/* /usr/sbin/ ;\
  rm -f /bin/kmod ;\
fi
