Ok, so I tried to figure this out, and this is what I ended up with so far (and honestly, I doubt that it’s gonna go further without other people’s help, lol)…
Dockerfile.template:
FROM balenalib/%%BALENA_MACHINE_NAME%%-debian
# Shouldn't this be ARG though? (Not sure)
ENV VERSION 'balenaOS 2.38.0+rev1'
WORKDIR /usr/src/app
RUN apt-get update && apt-get install -y curl wget build-essential \
libelf-dev awscli bc flex libssl-dev python bison git pkg-config
ADD https://raw.githubusercontent.com/balena-os/kernel-module-build/master/build.sh .
ADD https://raw.githubusercontent.com/balena-os/kernel-module-build/master/workarounds.sh .
# get wireguard kernel module source code (as described here https://www.wireguard.com/compilation/):
RUN git clone https://git.zx2c4.com/wireguard-linux-compat
RUN BALENA_MACHINE_NAME=%%BALENA_MACHINE_NAME%% ./build.sh build \
--device %%BALENA_MACHINE_NAME%% \
--os-version "$VERSION" \
--src wireguard-linux-compat/src
FROM linuxserver/wireguard
COPY --from=0 "/usr/src/app/wireguard-linux-compat/src/${AND_WHAT_DO_I_EXPECT_TO_COPY?}" /lib/modules/
Even if I knew the last piece of puzzle, which is this variable: "${AND_WHAT_DO_I_EXPECT_TO_COPY?}"
, I doubt it would work, as the wireguard instruction tells to install the module this way:
$ make -C wireguard-linux-compat/src -j$(nproc)
$ sudo make -C wireguard-linux-compat/src install
But I am trying the blackbox(to me lol) called build.sh
The problem here is that I honestly have never built any kernel modules, no clue what this kernel module is. Is it just a binary? Where the makefile will put it then? Does the makefile do anything else for it to work… I think this “simplistic wireguard VPN” setup (as it’s being advertised) should definitely not be such a hassle (hehe)…
Just leaving this here in case me, or more likely, someone smarter, becomes bored or inspired one day to finish this…