# Test the build against the latest mainline kernel
FROM registry.fedoraproject.org/fedora:rawhide

RUN dnf -y copr enable @kernel-vanilla/mainline \
    && dnf -y update --allowerasing \
    && dnf -y install --setopt=install_weak_deps=False \
        wget \
        gcc make patch \
        kernel-devel \
    && dnf clean all \
    && rm -rf /var/cache/dnf

WORKDIR /app

COPY . .

# Create entrypoint script to set up kernel build paths
RUN printf '%s\n' \
    '#!/bin/sh' \
    'KERNEL_BASE_DIR=$(echo /usr/src/kernels/*)' \
    'SYSSRC=$KERNEL_BASE_DIR exec "$@"' \
  > /entrypoint.sh && chmod +x /entrypoint.sh
ENTRYPOINT ["/entrypoint.sh"]

CMD ["./buildtest"]
