Skip to content

Commit cb8e6a1

Browse files
committed
multi-arch, add coredns
1 parent cd1968d commit cb8e6a1

File tree

11 files changed

+165
-14
lines changed

11 files changed

+165
-14
lines changed

Dockerfile

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,15 @@ RUN \
2929
echo resolvconf resolvconf/linkify-resolvconf boolean false | debconf-set-selections && \
3030
echo "REPORT_ABSENT_SYMLINK=no" >> /etc/default/resolvconf && \
3131
apt-get install resolvconf && \
32+
echo "**** install CoreDNS ****" && \
33+
COREDNS_VERSION=$(curl -sX GET "https://api.github.com/repos/coredns/coredns/releases/latest" \
34+
| awk '/tag_name/{print $4;exit}' FS='[""]' | awk '{print substr($1,2); }') && \
35+
curl -o \
36+
/tmp/coredns.tar.gz -L \
37+
"https://github.com/coredns/coredns/releases/download/v${COREDNS_VERSION}/coredns_${COREDNS_VERSION}_linux_amd64.tgz" && \
38+
tar xf \
39+
/tmp/coredns.tar.gz -C \
40+
/app && \
3241
echo "**** clean up ****" && \
3342
rm -rf \
3443
/tmp/* \

Dockerfile.aarch64

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
FROM lsiobase/ubuntu:arm64v8-bionic
2+
3+
# set version label
4+
ARG BUILD_DATE
5+
ARG VERSION
6+
ARG WIREGUARD_RELEASE
7+
LABEL build_version="Linuxserver.io version:- ${VERSION} Build-date:- ${BUILD_DATE}"
8+
LABEL maintainer="aptalca"
9+
10+
ENV DEBIAN_FRONTEND="noninteractive"
11+
12+
RUN \
13+
echo "**** install dependencies ****" && \
14+
apt-get update && \
15+
apt-get install -y \
16+
curl \
17+
dkms \
18+
gnupg \
19+
ifupdown \
20+
iproute2 \
21+
iptables \
22+
iputils-ping \
23+
libc6 \
24+
perl \
25+
qrencode && \
26+
apt-key adv --keyserver keyserver.ubuntu.com --recv-keys E1B39B6EF6DDB96564797591AE33835F504A1A25 && \
27+
echo "deb http://ppa.launchpad.net/wireguard/wireguard/ubuntu bionic main" >> /etc/apt/sources.list.d/wireguard.list && \
28+
echo "deb-src http://ppa.launchpad.net/wireguard/wireguard/ubuntu bionic main" >> /etc/apt/sources.list.d/wireguard.list && \
29+
echo resolvconf resolvconf/linkify-resolvconf boolean false | debconf-set-selections && \
30+
echo "REPORT_ABSENT_SYMLINK=no" >> /etc/default/resolvconf && \
31+
apt-get install resolvconf && \
32+
echo "**** install CoreDNS ****" && \
33+
COREDNS_VERSION=$(curl -sX GET "https://api.github.com/repos/coredns/coredns/releases/latest" \
34+
| awk '/tag_name/{print $4;exit}' FS='[""]' | awk '{print substr($1,2); }') && \
35+
curl -o \
36+
/tmp/coredns.tar.gz -L \
37+
"https://github.com/coredns/coredns/releases/download/v${COREDNS_VERSION}/coredns_${COREDNS_VERSION}_linux_arm64.tgz" && \
38+
tar xf \
39+
/tmp/coredns.tar.gz -C \
40+
/app && \
41+
echo "**** clean up ****" && \
42+
rm -rf \
43+
/tmp/* \
44+
/var/lib/apt/lists/* \
45+
/var/tmp/*
46+
47+
# add local files
48+
COPY /root /
49+
50+
# ports and volumes
51+
EXPOSE 51820/udp

Dockerfile.armhf

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
FROM lsiobase/ubuntu:arm32v7-bionic
2+
3+
# set version label
4+
ARG BUILD_DATE
5+
ARG VERSION
6+
ARG WIREGUARD_RELEASE
7+
LABEL build_version="Linuxserver.io version:- ${VERSION} Build-date:- ${BUILD_DATE}"
8+
LABEL maintainer="aptalca"
9+
10+
ENV DEBIAN_FRONTEND="noninteractive"
11+
12+
RUN \
13+
echo "**** install dependencies ****" && \
14+
apt-get update && \
15+
apt-get install -y \
16+
curl \
17+
dkms \
18+
gnupg \
19+
ifupdown \
20+
iproute2 \
21+
iptables \
22+
iputils-ping \
23+
libc6 \
24+
perl \
25+
qrencode && \
26+
apt-key adv --keyserver keyserver.ubuntu.com --recv-keys E1B39B6EF6DDB96564797591AE33835F504A1A25 && \
27+
echo "deb http://ppa.launchpad.net/wireguard/wireguard/ubuntu bionic main" >> /etc/apt/sources.list.d/wireguard.list && \
28+
echo "deb-src http://ppa.launchpad.net/wireguard/wireguard/ubuntu bionic main" >> /etc/apt/sources.list.d/wireguard.list && \
29+
echo resolvconf resolvconf/linkify-resolvconf boolean false | debconf-set-selections && \
30+
echo "REPORT_ABSENT_SYMLINK=no" >> /etc/default/resolvconf && \
31+
apt-get install resolvconf && \
32+
echo "**** install CoreDNS ****" && \
33+
COREDNS_VERSION=$(curl -sX GET "https://api.github.com/repos/coredns/coredns/releases/latest" \
34+
| awk '/tag_name/{print $4;exit}' FS='[""]' | awk '{print substr($1,2); }') && \
35+
curl -o \
36+
/tmp/coredns.tar.gz -L \
37+
"https://github.com/coredns/coredns/releases/download/v${COREDNS_VERSION}/coredns_${COREDNS_VERSION}_linux_arm.tgz" && \
38+
tar xf \
39+
/tmp/coredns.tar.gz -C \
40+
/app && \
41+
echo "**** clean up ****" && \
42+
rm -rf \
43+
/tmp/* \
44+
/var/lib/apt/lists/* \
45+
/var/tmp/*
46+
47+
# add local files
48+
COPY /root /
49+
50+
# ports and volumes
51+
EXPOSE 51820/udp

Jenkinsfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ pipeline {
2424
DEV_DOCKERHUB_IMAGE = 'lsiodev/wireguard'
2525
PR_DOCKERHUB_IMAGE = 'lspipepr/wireguard'
2626
DIST_IMAGE = 'ubuntu'
27-
MULTIARCH='false'
27+
MULTIARCH='true'
2828
CI='false'
2929
CI_WEB='false'
3030
CI_PORT='8080'

README.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@ The architectures supported by this image are:
5151
| Architecture | Tag |
5252
| :----: | --- |
5353
| x86-64 | amd64-latest |
54+
| arm64 | arm64v8-latest |
55+
| armhf | arm32v7-latest |
5456

5557

5658
## Usage
@@ -162,10 +164,12 @@ In this instance `PUID=1000` and `PGID=1000`, to find yours use `id user` as bel
162164
 
163165
## Application Setup
164166

165-
This image is designed for Ubuntu and Debian x86_64 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).
167+
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).
166168

167169
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).
168170

171+
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).
172+
169173
This can be run as a server or a client, based on the parameters used.
170174

171175
## Server Mode
@@ -253,7 +257,7 @@ Once registered you can define the dockerfile to use with `-f Dockerfile.aarch64
253257

254258
## Versions
255259

256-
* **08.04.20:** - Update the `add-peer`/`show-peer` scripts to utilize the templates and the `INTERNAL_SUBNET` var (previously missed, oops).
260+
* **08.04.20:** - Add arm32/64 builds and enable multi-arch (rpi4 with ubuntu and raspbian buster tested). Add CoreDNS. Update the `add-peer`/`show-peer` scripts to utilize the templates and the `INTERNAL_SUBNET` var (previously missed, oops).
257261
* **05.04.20:** - Add `INTERNAL_SUBNET` variable to prevent subnet clashes. Add templates for server and peer confs.
258262
* **01.04.20:** - Add `show-peer` script and include info on host installed headers.
259263
* **31.03.20:** - Initial Release.

jenkins-vars.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ repo_vars:
1616
- DEV_DOCKERHUB_IMAGE = 'lsiodev/wireguard'
1717
- PR_DOCKERHUB_IMAGE = 'lspipepr/wireguard'
1818
- DIST_IMAGE = 'ubuntu'
19-
- MULTIARCH='false'
19+
- MULTIARCH='true'
2020
- CI='false'
2121
- CI_WEB='false'
2222
- CI_PORT='8080'

readme-vars.yml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ project_lsio_github_repo_url: "https://github.com/linuxserver/docker-{{ project_
1010
# supported architectures
1111
available_architectures:
1212
- { arch: "{{ arch_x86_64 }}", tag: "amd64-latest"}
13+
- { arch: "{{ arch_arm64 }}", tag: "arm64v8-latest"}
14+
- { arch: "{{ arch_armhf }}", tag: "arm32v7-latest"}
1315

1416
# development version
1517
development_versions: false
@@ -43,7 +45,7 @@ opt_param_env_vars:
4345
- { env_var: "SERVERURL", env_value: "wireguard.domain.com", desc: "External IP or domain name for docker host. Used in server mode. If set to `auto`, the container will try to determine and set the external IP automatically"}
4446
- { env_var: "SERVERPORT", env_value: "51820", desc: "External port for docker host. Used in server mode."}
4547
- { env_var: "PEERS", env_value: "1", desc: "Number of peers to create confs for. Required for server mode."}
46-
- { env_var: "PEERDNS", env_value: "8.8.8.8", desc: "DNS server set in peer/client configs. Used in server mode."}
48+
- { env_var: "PEERDNS", env_value: "auto", desc: "DNS server set in peer/client configs (can be set as `8.8.8.8`). Used in server mode. Defaults to `auto`, which uses wireguard docker host's DNS via included CoreDNS forward."}
4749
- { env_var: "INTERNAL_SUBNET", env_value: "10.13.13.0", desc: "Internal subnet for the wireguard and server and peers (only change if it clashes). Used in server mode."}
4850

4951
optional_block_1: false
@@ -52,10 +54,12 @@ optional_block_1_items: ""
5254
# application setup block
5355
app_setup_block_enabled: true
5456
app_setup_block: |
55-
This image is designed for Ubuntu and Debian x86_64 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 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).
5658
5759
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).
5860
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).
62+
5963
This can be run as a server or a client, based on the parameters used.
6064
6165
## Server Mode
@@ -74,7 +78,7 @@ app_setup_block: |
7478
7579
# changelog
7680
changelogs:
77-
- { date: "08.04.20:", desc: "Update the `add-peer`/`show-peer` scripts to utilize the templates and the `INTERNAL_SUBNET` var (previously missed, oops)." }
81+
- { date: "08.04.20:", desc: "Add arm32/64 builds and enable multi-arch (rpi4 with ubuntu and raspbian buster tested). Add CoreDNS for `PEERDNS=auto` setting. Update the `add-peer`/`show-peer` scripts to utilize the templates and the `INTERNAL_SUBNET` var (previously missed, oops)." }
7882
- { date: "05.04.20:", desc: "Add `INTERNAL_SUBNET` variable to prevent subnet clashes. Add templates for server and peer confs." }
7983
- { date: "01.04.20:", desc: "Add `show-peer` script and include info on host installed headers." }
8084
- { date: "31.03.20:", desc: "Initial Release." }

root/app/add-peer

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@ if [ -z "$SERVERURL" ] || [ "$SERVERURL" = "auto" ]; then
1111
SERVERURL=$(curl icanhazip.com)
1212
fi
1313
SERVERPORT=${SERVERPORT:-51820}
14-
PEERDNS=${PEERDNS:-8.8.8.8}
14+
if [ -z "$PEERDNS" ] || [ "$PEERDNS" = "auto" ]; then
15+
PEERDNS="${INTERFACE}.1"
16+
fi
1517

1618
for i in {1..254}; do
1719
if grep -q "AllowedIPs = ${INTERFACE}.$(( $i + 1 ))/32" /config/wg0.conf; then

root/defaults/Corefile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
. {
2+
forward . 127.0.0.11
3+
}

root/etc/cont-init.d/30-config

Lines changed: 27 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,25 @@
11
#!/usr/bin/with-contenv bash
22

3-
mkdir -p /config/templates
3+
mkdir -p /config/{templates,coredns}
44

55
# install headers and wireguard
66
apt-get update
77
if apt-cache show linux-headers-$(uname -r) 2&>1 >/dev/null; then
88
apt-get install -y \
99
linux-headers-$(uname -r) \
1010
wireguard
11+
elif uname -r | grep -q 'v7l+'; then
12+
echo "Raspbian kernel naming convention detected, attempting to install raspbian kernel headers"
13+
curl -s http://archive.raspberrypi.org/debian/raspberrypi.gpg.key | apt-key add -
14+
echo -e \
15+
"deb http://archive.raspberrypi.org/debian/ buster main\ndeb-src http://archive.raspberrypi.org/debian/ buster main" \
16+
> /etc/apt/sources.list.d/raspbian.list
17+
apt-get update
18+
apt-get install -y \
19+
raspberrypi-kernel-headers \
20+
wireguard
1121
elif uname -v | grep -q 'Ubuntu'; then
22+
echo "Attempting to install kernel headers from Ubuntu Xenial repo"
1223
curl -s http://archive.ubuntu.com/ubuntu/dists/xenial/Release.gpg | apt-key add -
1324
echo -e \
1425
"deb http://archive.ubuntu.com/ubuntu/ xenial main restricted\ndeb-src http://archive.ubuntu.com/ubuntu/ xenial main restricted\n\ndeb http://archive.ubuntu.com/ubuntu/ xenial-updates main restricted\ndeb-src http://archive.ubuntu.com/ubuntu/ xenial-updates main restricted" \
@@ -19,11 +30,12 @@ elif uname -v | grep -q 'Ubuntu'; then
1930
linux-headers-$(uname -r) \
2031
wireguard
2132
else
22-
echo "No kernel headers found!! Will try the headers from the wireguard ppa, may or may not work"
33+
echo "No kernel headers found in the Ubuntu repos!! Will try the headers from host (if mapped), may or may not work"
2334
apt-get install -y \
2435
wireguard
2536
fi
2637
elif uname -v | grep -q 'Debian'; then
38+
echo "Debian host detected, attempting to install kernel headers from Debian Buster repo"
2739
curl -s https://ftp-master.debian.org/keys/archive-key-10.asc | apt-key add -
2840
echo -e \
2941
"deb http://deb.debian.org/debian buster main contrib non-free\ndeb-src http://deb.debian.org/debian buster main contrib non-free" \
@@ -34,6 +46,7 @@ elif uname -v | grep -q 'Debian'; then
3446
linux-headers-$(uname -r) \
3547
wireguard
3648
else
49+
echo "Attempting to install kernel headers from the Debian Stretch repo"
3750
curl -s https://ftp-master.debian.org/keys/archive-key-9.asc | apt-key add -
3851
sed -i 's/buster/stretch/g' /etc/apt/sources.list.d/debian.list
3952
apt-get update
@@ -42,13 +55,13 @@ elif uname -v | grep -q 'Debian'; then
4255
linux-headers-$(uname -r) \
4356
wireguard
4457
else
45-
echo "No kernel headers found!! Will try the headers from the wireguard ppa, may or may not work"
58+
echo "No kernel headers found in Debian repos!! Will try the headers from host (if mapped), may or may not work"
4659
apt-get install -y \
4760
wireguard
4861
fi
4962
fi
5063
else
51-
echo "No kernel headers found!! Will try the headers from the wireguard ppa, may or may not work"
64+
echo "No kernel headers found in the Ubuntu or Debian repos!! Will try the headers from host (if mapped), may or may not work"
5265
apt-get install -y \
5366
wireguard
5467
fi
@@ -120,11 +133,15 @@ if [ -n "$PEERS" ]; then
120133
fi
121134
SERVERPORT=${SERVERPORT:-51820}
122135
echo "External server port is set to ${SERVERPORT}. Make sure that port is properly forwarded to port 51820 inside this container"
123-
PEERDNS=${PEERDNS:-8.8.8.8}
124-
echo "DNS server is set to $PEERDNS"
125136
INTERNAL_SUBNET=${INTERNAL_SUBNET:-10.13.13.0}
126137
echo "Internal subnet is set to $INTERNAL_SUBNET"
127138
INTERFACE=$(echo "$INTERNAL_SUBNET" | awk 'BEGIN{FS=OFS="."} NF--')
139+
if [ -z "$PEERDNS" ] || [ "$PEERDNS" = "auto" ]; then
140+
PEERDNS="${INTERFACE}.1"
141+
echo "PEERDNS var is either not set or is set to \"auto\", setting peer DNS to ${INTERFACE}.1 to use wireguard docker host's DNS."
142+
else
143+
echo "Peer DNS servers will be set to $PEERDNS"
144+
fi
128145
if [ ! -f /config/wg0.conf ]; then
129146
echo "No found wg0.conf found (maybe an initial install), generating 1 server and $PEERS peer/client confs"
130147
generate_confs
@@ -149,6 +166,10 @@ else
149166
fi
150167
fi
151168

169+
# set up CoreDNS
170+
[[ ! -f /config/coredns/Corefile ]] && \
171+
cp /defaults/Corefile /config/coredns/Corefile
172+
152173
# permissions
153174
chown -R abc:abc \
154175
/config

0 commit comments

Comments
 (0)