Skip to content

Commit 9c37136

Browse files
authored
Merge pull request #5 from linuxserver/scripts
Multi-arch, add coredns, update scripts for templates
2 parents 49701c9 + e724cf3 commit 9c37136

File tree

12 files changed

+185
-31
lines changed

12 files changed

+185
-31
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: 9 additions & 4 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
@@ -70,7 +72,7 @@ docker create \
7072
-e SERVERURL=wireguard.domain.com `#optional` \
7173
-e SERVERPORT=51820 `#optional` \
7274
-e PEERS=1 `#optional` \
73-
-e PEERDNS=8.8.8.8 `#optional` \
75+
-e PEERDNS=auto `#optional` \
7476
-e INTERNAL_SUBNET=10.13.13.0 `#optional` \
7577
-p 51820:51820/udp \
7678
-v /path/to/appdata/config:/config \
@@ -102,7 +104,7 @@ services:
102104
- SERVERURL=wireguard.domain.com #optional
103105
- SERVERPORT=51820 #optional
104106
- PEERS=1 #optional
105-
- PEERDNS=8.8.8.8 #optional
107+
- PEERDNS=auto #optional
106108
- INTERNAL_SUBNET=10.13.13.0 #optional
107109
volumes:
108110
- /path/to/appdata/config:/config
@@ -127,7 +129,7 @@ Container images are configured using parameters passed at runtime (such as thos
127129
| `-e SERVERURL=wireguard.domain.com` | 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 |
128130
| `-e SERVERPORT=51820` | External port for docker host. Used in server mode. |
129131
| `-e PEERS=1` | Number of peers to create confs for. Required for server mode. |
130-
| `-e PEERDNS=8.8.8.8` | DNS server set in peer/client configs. Used in server mode. |
132+
| `-e PEERDNS=auto` | 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. |
131133
| `-e INTERNAL_SUBNET=10.13.13.0` | Internal subnet for the wireguard and server and peers (only change if it clashes). Used in server mode. |
132134
| `-v /config` | Contains all relevant configuration files. |
133135
| `-v /lib/modules` | Maps host's modules folder. |
@@ -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,6 +257,7 @@ Once registered you can define the dockerfile to use with `-f Dockerfile.aarch64
253257

254258
## Versions
255259

260+
* **08.04.20:** - 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).
256261
* **05.04.20:** - Add `INTERNAL_SUBNET` variable to prevent subnet clashes. Add templates for server and peer confs.
257262
* **01.04.20:** - Add `show-peer` script and include info on host installed headers.
258263
* **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 & 2 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,6 +78,7 @@ app_setup_block: |
7478
7579
# changelog
7680
changelogs:
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)." }
7782
- { date: "05.04.20:", desc: "Add `INTERNAL_SUBNET` variable to prevent subnet clashes. Add templates for server and peer confs." }
7883
- { date: "01.04.20:", desc: "Add `show-peer` script and include info on host installed headers." }
7984
- { date: "31.03.20:", desc: "Initial Release." }

root/app/add-peer

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

3-
if [ ! -f /config/wg0.conf ] || [ -z "$PEERS" ] || [ -z "$SERVERURL" ]; then
3+
if [ ! -f /config/wg0.conf ] || [ -z "$PEERS" ]; then
44
echo "Wireguard is not set up in server mode"
55
exit 0
66
fi
77

8+
INTERNAL_SUBNET=${INTERNAL_SUBNET:-10.13.13.0}
9+
INTERFACE=$(echo "$INTERNAL_SUBNET" | awk 'BEGIN{FS=OFS="."} NF--')
10+
if [ -z "$SERVERURL" ] || [ "$SERVERURL" = "auto" ]; then
11+
SERVERURL=$(curl icanhazip.com)
12+
fi
13+
SERVERPORT=${SERVERPORT:-51820}
14+
if [ -z "$PEERDNS" ] || [ "$PEERDNS" = "auto" ]; then
15+
PEERDNS="${INTERFACE}.1"
16+
fi
17+
818
for i in {1..254}; do
9-
if grep -q "AllowedIPs = 10.13.13.$(( $i + 1 ))/32" /config/wg0.conf; then
19+
if grep -q "AllowedIPs = ${INTERFACE}.$(( $i + 1 ))/32" /config/wg0.conf; then
1020
echo "Peer $i exists"
1121
else
1222
echo "Adding new Peer $i"
@@ -15,24 +25,14 @@ for i in {1..254}; do
1525
umask 077
1626
wg genkey | tee /config/peer${i}/privatekey-peer${i} | wg pubkey > /config/peer${i}/publickey-peer${i}
1727
fi
18-
SERVERPORT=${SERVERPORT:-51820}
19-
PEERDNS=${PEERDNS:-8.8.8.8}
28+
eval "`printf %s`
2029
cat <<DUDE > /config/peer${i}/peer${i}.conf
21-
[Interface]
22-
Address = 10.13.13.$(( $i + 1 ))
23-
PrivateKey = $(cat /config/peer${i}/privatekey-peer${i})
24-
ListenPort = 51820
25-
DNS = ${PEERDNS}
26-
27-
[Peer]
28-
PublicKey = $(cat /config/server/publickey-server)
29-
Endpoint = ${SERVERURL}:${SERVERPORT}
30-
AllowedIPs = 0.0.0.0/0, ::/0
31-
DUDE
30+
`cat /config/templates/peer.conf`
31+
DUDE"
3232
cat <<DUDE >> /config/wg0.conf
3333
[Peer]
3434
PublicKey = $(cat /config/peer${i}/publickey-peer${i})
35-
AllowedIPs = 10.13.13.$(( $i + 1 ))/32
35+
AllowedIPs = ${INTERFACE}.$(( $i + 1 ))/32
3636

3737
DUDE
3838
echo "PEER ${i} QR code:"

root/app/show-peer

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,11 @@ if [ ! $# -gt 0 ]; then
55
exit 0
66
fi
77

8+
INTERNAL_SUBNET=${INTERNAL_SUBNET:-10.13.13.0}
9+
INTERFACE=$(echo "$INTERNAL_SUBNET" | awk 'BEGIN{FS=OFS="."} NF--')
10+
811
for i in "$@"; do
9-
if grep -q "AllowedIPs = 10.13.13.$(( $i + 1 ))/32" /config/wg0.conf; then
12+
if grep -q "AllowedIPs = ${INTERFACE}.$(( $i + 1 ))/32" /config/wg0.conf; then
1013
echo "PEER $i QR code:"
1114
qrencode -t ansiutf8 < /config/peer${i}/peer${i}.conf
1215
else

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+
}

0 commit comments

Comments
 (0)