kernel-module-build not working

Hi, hopefully someone can help me here, I was not lucky doing it by myself

I am trying to run the kernel-module-build example (kernel-module-build/Dockerfile.template at master · balena-os/kernel-module-build · GitHub) but I got the following error during building

[Build]   [main] Step 12/19 : ENV MOD_DIR example_module
[Build]   [main]  ---> Using cache
[Build]   [main]  ---> 25ca1d7c7f90
[Build]   [main] Step 13/19 : ENV MOD_PATH="$MOD_PATH"
[Build]   [main]  ---> Using cache
[Build]   [main]  ---> 7e374e5a855e
[Build]   [main] Step 14/19 : COPY --from=kernel-build /usr/src/app/output/ "$MOD_PATH"
Some services failed to build:
	main: COPY failed: stat usr/src/app/output/: file does not exist


Additional information may be available with the `--debug` flag.

For further help or support, visit:
https://www.balena.io/docs/reference/balena-cli/#support-faq-and-troubleshooting


7ser23@Sergio-MP-M2 kernel-module-build-master % 

running with --debug does not give any extra help. Was someone successful running the example. I change the OS Variable to the current one and same issue.

I am running a raspberri4 if that helps. Thank you

I was able to make it work:

FROM ubuntu:jammy-20220531 as kernel-build

ARG DEBIAN_FRONTEND=noninteractive
ENV TZ=America/La_Paz

RUN apt-get update && \
    apt-get install -y \
    awscli \
    bc \
    bison \
    build-essential \
    curl \
    flex \
    git \
    libelf-dev \
    libssl-dev \
    wget

WORKDIR /usr/src/app

# Clones the kernel builder repository
#RUN git clone https://github.com/balena-os/kernel-module-build.git .

# You can switch to a specific commit of the kernel builder if you want to ensure consistent builds
# git reset --hard f889851c5d00890b51b27c63eaa59a976063265a

# Copy your kernel source from your local build context to the build directory
#COPY example_module .
COPY . .
# Set the name of the directory where you have copied your kernel source in the step above
ENV MOD_DIR "example_module"

# Set the balena OS version you intend to use
ENV OS_VERSION '2023.1.0'

# Start the build
#RUN BALENA_MACHINE_NAME=%%BALENA_MACHINE_NAME%% ./build.sh build --device %%BALENA_MACHINE_NAME%% --os-version "$OS_VERSION" --src "$MOD_DIR"
RUN BALENA_MACHINE_NAME=raspberrypi4-64 ./build.sh build --device raspberrypi4-64 --os-version "$OS_VERSION" --src "$MOD_DIR"

#RUN BALENA_MACHINE_NAME=${BALENA_MACHINE_NAME} ./build.sh build --device ${BALENA_MACHINE_NAME} --os-version "$OS_VERSION" --src "$MOD_DIR"

    
FROM alpine

# Set the directory where you would like your kernel source
ARG MOD_PATH=/etc/output
ENV MOD_DIR example_module

# Required for access when the container starts
ENV MOD_PATH="$MOD_PATH"

# Copy the built kernel module into your app
COPY --from=kernel-build /usr/src/app/output "$MOD_PATH"

# Copy the startup script for loading the modules
COPY --from=kernel-build /usr/src/app/run.sh /usr/src/app/run.sh

# Start the script that loads the modules.
ENTRYPOINT ["sh", "/usr/src/app/run.sh"]

# Run your usual service with CMD
CMD exec /bin/sh -c "trap : TERM INT; sleep 9999999999d & wait"

Hello,

Glad to hear you made it work!