FROM quay.io/pypa/manylinux_2_28_x86_64:2024-02-08-a1b4ddc as build

RUN dnf install -y kernel-devel kernel-headers && dnf clean all
RUN curl https://developer.download.nvidia.com/compute/cuda/12.3.2/local_installers/cuda-repo-rhel8-12-3-local-12.3.2_545.23.08-1.x86_64.rpm -o cuda.rpm
RUN rpm -i cuda.rpm \
    && dnf install -y epel-release \
    && dnf clean all
# hadolint ignore=DL3041
RUN dnf update -y \
    && dnf -y module install nvidia-driver:latest-dkms \
    && dnf -y install cuda \
    && dnf clean all
# Add a non-root user and group
RUN groupadd -g 10001 grp02 && \
    useradd -u 10000 -g grp02 usr01 && \
    chown -R usr01:grp02 /usr/local/cuda-12.3
# Switch to the non-root user
USER usr01:grp02

FROM scratch
COPY --from=build /usr/local/cuda-12.3/ /usr/local/cuda-12.3/
COPY --from=build /usr/lib64/libcuda.so* /usr/lib64/
