Skip to content

Commit c0ff957

Browse files
authored
Merge pull request #39 from linuxserver/compile
compile wireguard tools/module, make it optional
2 parents 8fd0825 + 304d341 commit c0ff957

File tree

8 files changed

+212
-95
lines changed

8 files changed

+212
-95
lines changed

Dockerfile

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,22 +14,37 @@ RUN \
1414
apt-get update && \
1515
apt-get install -y \
1616
bc \
17+
build-essential \
1718
curl \
18-
dkms \
19+
git \
1920
gnupg \
2021
ifupdown \
2122
iproute2 \
2223
iptables \
2324
iputils-ping \
25+
jq \
2426
libc6 \
27+
libelf-dev \
2528
perl \
29+
pkg-config \
2630
qrencode && \
27-
apt-key adv --keyserver keyserver.ubuntu.com --recv-keys E1B39B6EF6DDB96564797591AE33835F504A1A25 && \
28-
echo "deb http://ppa.launchpad.net/wireguard/wireguard/ubuntu bionic main" >> /etc/apt/sources.list.d/wireguard.list && \
29-
echo "deb-src http://ppa.launchpad.net/wireguard/wireguard/ubuntu bionic main" >> /etc/apt/sources.list.d/wireguard.list && \
3031
echo resolvconf resolvconf/linkify-resolvconf boolean false | debconf-set-selections && \
3132
echo "REPORT_ABSENT_SYMLINK=no" >> /etc/default/resolvconf && \
32-
apt-get install resolvconf && \
33+
apt-get install -y --no-install-recommends \
34+
dkms \
35+
resolvconf && \
36+
echo "**** install wireguard-tools ****" && \
37+
if [ -z ${WIREGUARD_RELEASE+x} ]; then \
38+
WIREGUARD_RELEASE=$(curl -sX GET "https://api.github.com/repos/WireGuard/wireguard-tools/tags" \
39+
| jq -r .[0].name); \
40+
fi && \
41+
cd /app && \
42+
git clone https://git.zx2c4.com/wireguard-linux-compat && \
43+
git clone https://git.zx2c4.com/wireguard-tools && \
44+
cd wireguard-tools && \
45+
git checkout "${WIREGUARD_RELEASE}" && \
46+
make -C src -j$(nproc) && \
47+
make -C src install && \
3348
echo "**** install CoreDNS ****" && \
3449
COREDNS_VERSION=$(curl -sX GET "https://api.github.com/repos/coredns/coredns/releases/latest" \
3550
| awk '/tag_name/{print $4;exit}' FS='[""]' | awk '{print substr($1,2); }') && \

Dockerfile.aarch64

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,22 +14,37 @@ RUN \
1414
apt-get update && \
1515
apt-get install -y \
1616
bc \
17+
build-essential \
1718
curl \
18-
dkms \
19+
git \
1920
gnupg \
2021
ifupdown \
2122
iproute2 \
2223
iptables \
2324
iputils-ping \
25+
jq \
2426
libc6 \
27+
libelf-dev \
2528
perl \
29+
pkg-config \
2630
qrencode && \
27-
apt-key adv --keyserver keyserver.ubuntu.com --recv-keys E1B39B6EF6DDB96564797591AE33835F504A1A25 && \
28-
echo "deb http://ppa.launchpad.net/wireguard/wireguard/ubuntu bionic main" >> /etc/apt/sources.list.d/wireguard.list && \
29-
echo "deb-src http://ppa.launchpad.net/wireguard/wireguard/ubuntu bionic main" >> /etc/apt/sources.list.d/wireguard.list && \
3031
echo resolvconf resolvconf/linkify-resolvconf boolean false | debconf-set-selections && \
3132
echo "REPORT_ABSENT_SYMLINK=no" >> /etc/default/resolvconf && \
32-
apt-get install resolvconf && \
33+
apt-get install -y --no-install-recommends \
34+
dkms \
35+
resolvconf && \
36+
echo "**** install wireguard-tools ****" && \
37+
if [ -z ${WIREGUARD_RELEASE+x} ]; then \
38+
WIREGUARD_RELEASE=$(curl -sX GET "https://api.github.com/repos/WireGuard/wireguard-tools/tags" \
39+
| jq -r .[0].name); \
40+
fi && \
41+
cd /app && \
42+
git clone https://git.zx2c4.com/wireguard-linux-compat && \
43+
git clone https://git.zx2c4.com/wireguard-tools && \
44+
cd wireguard-tools && \
45+
git checkout "${WIREGUARD_RELEASE}" && \
46+
make -C src -j$(nproc) && \
47+
make -C src install && \
3348
echo "**** install CoreDNS ****" && \
3449
COREDNS_VERSION=$(curl -sX GET "https://api.github.com/repos/coredns/coredns/releases/latest" \
3550
| awk '/tag_name/{print $4;exit}' FS='[""]' | awk '{print substr($1,2); }') && \

Dockerfile.armhf

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,22 +14,37 @@ RUN \
1414
apt-get update && \
1515
apt-get install -y \
1616
bc \
17+
build-essential \
1718
curl \
18-
dkms \
19+
git \
1920
gnupg \
2021
ifupdown \
2122
iproute2 \
2223
iptables \
2324
iputils-ping \
25+
jq \
2426
libc6 \
27+
libelf-dev \
2528
perl \
29+
pkg-config \
2630
qrencode && \
27-
apt-key adv --keyserver keyserver.ubuntu.com --recv-keys E1B39B6EF6DDB96564797591AE33835F504A1A25 && \
28-
echo "deb http://ppa.launchpad.net/wireguard/wireguard/ubuntu bionic main" >> /etc/apt/sources.list.d/wireguard.list && \
29-
echo "deb-src http://ppa.launchpad.net/wireguard/wireguard/ubuntu bionic main" >> /etc/apt/sources.list.d/wireguard.list && \
3031
echo resolvconf resolvconf/linkify-resolvconf boolean false | debconf-set-selections && \
3132
echo "REPORT_ABSENT_SYMLINK=no" >> /etc/default/resolvconf && \
32-
apt-get install resolvconf && \
33+
apt-get install -y --no-install-recommends \
34+
dkms \
35+
resolvconf && \
36+
echo "**** install wireguard-tools ****" && \
37+
if [ -z ${WIREGUARD_RELEASE+x} ]; then \
38+
WIREGUARD_RELEASE=$(curl -sX GET "https://api.github.com/repos/WireGuard/wireguard-tools/tags" \
39+
| jq -r .[0].name); \
40+
fi && \
41+
cd /app && \
42+
git clone https://git.zx2c4.com/wireguard-linux-compat && \
43+
git clone https://git.zx2c4.com/wireguard-tools && \
44+
cd wireguard-tools && \
45+
git checkout "${WIREGUARD_RELEASE}" && \
46+
make -C src -j$(nproc) && \
47+
make -C src install && \
3348
echo "**** install CoreDNS ****" && \
3449
COREDNS_VERSION=$(curl -sX GET "https://api.github.com/repos/coredns/coredns/releases/latest" \
3550
| awk '/tag_name/{print $4;exit}' FS='[""]' | awk '{print substr($1,2); }') && \

Jenkinsfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ pipeline {
103103
steps{
104104
script{
105105
env.EXT_RELEASE = sh(
106-
script: ''' curl -sX GET http://ppa.launchpad.net/wireguard/wireguard/ubuntu/dists/bionic/main/binary-amd64/Packages.gz | gunzip -c |grep -A 7 -m 1 'Package: wireguard' | awk -F ': ' '/Version/{print $2;exit}' ''',
106+
script: ''' curl -sX GET https://api.github.com/repos/WireGuard/wireguard-tools/tags | jq -r .[0].name ''',
107107
returnStdout: true).trim()
108108
env.RELEASE_LINK = 'custom_command'
109109
}

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -168,11 +168,11 @@ In this instance `PUID=1000` and `PGID=1000`, to find yours use `id user` as bel
168168
 
169169
## Application Setup
170170

171-
This image is designed for Ubuntu and Debian based systems only. During container start, it will download the necessary kernel headers and build the kernel module (until kernel 5.6, which has the module built-in, goes mainstream).
171+
This image is designed for Ubuntu and Debian based systems mainly (it works on some others, but ymmv). During container start, it will first check if the wireguard module is already installed and loaded. If not, it will then check if the kernel headers are already installed (in `/usr/src`) and if not, attempt to download the necessary kernel headers from the ubuntu/debian/raspbian repos; then will compile and install the kernel module.
172172

173173
If you're on a debian/ubuntu based host with a custom or downstream distro provided kernel (ie. Pop!_OS), the container won't be able to install the kernel headers from the regular ubuntu and debian repos. In those cases, you can try installing the headers on the host via `sudo apt install linux-headers-$(uname -r)` (if distro version) and then add a volume mapping for `/usr/src:/usr/src`, or if custom built, map the location of the existing headers to allow the container to use host installed headers to build the kernel module (tested successful on Pop!_OS, ymmv).
174174

175-
With regards to arm32/64 devices, Raspberry Pi 2-4 running the [official ubuntu images](https://ubuntu.com/download/raspberry-pi) or Raspbian Buster are supported out of the box. For all other devices and OSes, you can try installing the kernel headers on the host, and mapping `/usr/src:/usr/src` and it may just work (no guarantees).
175+
With regards to arm32/64 devices, Raspberry Pi 2-4 running the [official ubuntu images prior to focal](https://ubuntu.com/download/raspberry-pi) or Raspbian Buster are supported out of the box. For all other devices and OSes, you can try installing the kernel headers on the host, and mapping `/usr/src:/usr/src` and it may just work (no guarantees).
176176

177177
This can be run as a server or a client, based on the parameters used.
178178

@@ -268,6 +268,7 @@ Once registered you can define the dockerfile to use with `-f Dockerfile.aarch64
268268

269269
## Versions
270270

271+
* **19.06.20:** - Add support for Ubuntu Focal (20.04) kernels. Compile wireguard tools and kernel module instead of using the ubuntu packages. Make module install optional. Improve verbosity in logs.
271272
* **29.05.20:** - Add support for 64bit raspbian.
272273
* **28.04.20:** - Add Buster/Stretch backports repos for Debian. Tested with OMV 5 and OMV 4 (on kernel 4.19.0-0.bpo.8-amd64).
273274
* **20.04.20:** - Fix typo in client mode conf existence check.

jenkins-vars.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# jenkins variables
44
project_name: docker-wireguard
55
external_type: na
6-
custom_version_command: "curl -sX GET http://ppa.launchpad.net/wireguard/wireguard/ubuntu/dists/bionic/main/binary-amd64/Packages.gz | gunzip -c |grep -A 7 -m 1 'Package: wireguard' | awk -F ': ' '/Version/{print $2;exit}'"
6+
custom_version_command: "curl -sX GET https://api.github.com/repos/WireGuard/wireguard-tools/tags | jq -r .[0].name"
77
release_type: stable
88
release_tag: latest
99
ls_branch: master

readme-vars.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,11 @@ optional_block_1_items: ""
5454
# application setup block
5555
app_setup_block_enabled: true
5656
app_setup_block: |
57-
This image is designed for Ubuntu and Debian based systems only. During container start, it will download the necessary kernel headers and build the kernel module (until kernel 5.6, which has the module built-in, goes mainstream).
57+
This image is designed for Ubuntu and Debian based systems mainly (it works on some others, but ymmv). During container start, it will first check if the wireguard module is already installed and loaded. If not, it will then check if the kernel headers are already installed (in `/usr/src`) and if not, attempt to download the necessary kernel headers from the ubuntu/debian/raspbian repos; then will compile and install the kernel module.
5858
5959
If you're on a debian/ubuntu based host with a custom or downstream distro provided kernel (ie. Pop!_OS), the container won't be able to install the kernel headers from the regular ubuntu and debian repos. In those cases, you can try installing the headers on the host via `sudo apt install linux-headers-$(uname -r)` (if distro version) and then add a volume mapping for `/usr/src:/usr/src`, or if custom built, map the location of the existing headers to allow the container to use host installed headers to build the kernel module (tested successful on Pop!_OS, ymmv).
6060
61-
With regards to arm32/64 devices, Raspberry Pi 2-4 running the [official ubuntu images](https://ubuntu.com/download/raspberry-pi) or Raspbian Buster are supported out of the box. For all other devices and OSes, you can try installing the kernel headers on the host, and mapping `/usr/src:/usr/src` and it may just work (no guarantees).
61+
With regards to arm32/64 devices, Raspberry Pi 2-4 running the [official ubuntu images prior to focal](https://ubuntu.com/download/raspberry-pi) or Raspbian Buster are supported out of the box. For all other devices and OSes, you can try installing the kernel headers on the host, and mapping `/usr/src:/usr/src` and it may just work (no guarantees).
6262
6363
This can be run as a server or a client, based on the parameters used.
6464
@@ -85,6 +85,7 @@ app_setup_block: |
8585
8686
# changelog
8787
changelogs:
88+
- { date: "19.06.20:", desc: "Add support for Ubuntu Focal (20.04) kernels. Compile wireguard tools and kernel module instead of using the ubuntu packages. Make module install optional. Improve verbosity in logs." }
8889
- { date: "29.05.20:", desc: "Add support for 64bit raspbian." }
8990
- { date: "28.04.20:", desc: "Add Buster/Stretch backports repos for Debian. Tested with OMV 5 and OMV 4 (on kernel 4.19.0-0.bpo.8-amd64)." }
9091
- { date: "20.04.20:", desc: "Fix typo in client mode conf existence check." }

0 commit comments

Comments
 (0)