apiVersion: v1
kind: ConfigMap
metadata:
  name: build-module
data:
  dockerfile: |
    FROM amazonlinux as builder
    ARG KERNEL_VERSION=''
    RUN amazon-linux-extras install kernel-5.4 -y
    RUN yum -y install kernel-headers-${KERNEL_VERSION} \
        kernel-${KERNEL_VERSION} \
        kernel-devel-${KERNEL_VERSION} \
        python3 \
        git \
        make \
        gcc \
        bison \
        flex \
        elfutils-libelf-devel \
        linux-headers \
        openssl-devel \
        xz \
        yum-utils \
        bc && \
        yum clean all

    RUN git clone https://github.com/kubernetes-sigs/kernel-module-management.git
    WORKDIR kernel-module-management/ci/kmm-kmod 
    RUN make 

    FROM amazonlinux
    ARG KERNEL_VERSION
    RUN yum -y install kmod && yum clean all
    COPY --from=builder kernel-module-management/ci/kmm-kmod/kmm_ci_a.ko /opt/lib/modules/${KERNEL_VERSION}/
    COPY --from=builder kernel-module-management/ci/kmm-kmod/kmm_ci_b.ko /opt/lib/modules/${KERNEL_VERSION}/
    RUN depmod -b /opt

