aboutsummaryrefslogtreecommitdiff
path: root/al2-wireguard
diff options
context:
space:
mode:
authorMike Crute <mike@crute.us>2019-12-10 22:00:09 +0000
committerMike Crute <mike@crute.us>2019-12-10 22:07:05 +0000
commit6dbd14383a3a3c784cabf4efa2dd423dfc042926 (patch)
tree532ff71e6443dc6da55dd1b8dd83873e97c8419f /al2-wireguard
parentcf6901023842219b9ee987becc8ced7c3d1f44cb (diff)
downloaddockerfiles-6dbd14383a3a3c784cabf4efa2dd423dfc042926.tar.bz2
dockerfiles-6dbd14383a3a3c784cabf4efa2dd423dfc042926.tar.xz
dockerfiles-6dbd14383a3a3c784cabf4efa2dd423dfc042926.zip
al2-wireguard: Add new container build
Diffstat (limited to 'al2-wireguard')
-rw-r--r--al2-wireguard/Dockerfile56
-rw-r--r--al2-wireguard/Makefile25
-rwxr-xr-xal2-wireguard/entrypoint.sh18
3 files changed, 99 insertions, 0 deletions
diff --git a/al2-wireguard/Dockerfile b/al2-wireguard/Dockerfile
new file mode 100644
index 0000000..ca76f37
--- /dev/null
+++ b/al2-wireguard/Dockerfile
@@ -0,0 +1,56 @@
1FROM amazonlinux:2 AS builder
2LABEL maintainer="Mike Crute <mike@crute.us>"
3
4ARG VERSION
5ARG REGION
6
7RUN set -euxo pipefail; \
8 echo "${REGION}" > /etc/yum/vars/awsregion; \
9 amazon-linux-extras install -y kernel-ng; \
10 yum install -y \
11 libmnl-devel \
12 libmnl-static \
13 glibc-static \
14 elfutils-libelf-devel \
15 kernel-devel \
16 pkgconfig \
17 "@Development Tools" \
18 ; \
19 curl -Ls https://git.zx2c4.com/WireGuard/snapshot/WireGuard-${VERSION}.tar.xz | tar -xJC /usr/src; \
20 cd /usr/src/WireGuard-${VERSION}/src; \
21 \
22 make module; \
23 make LDFLAGS="-static" tools
24
25
26FROM amazonlinux:2
27LABEL maintainer="Mike Crute <mike@crute.us>"
28
29ARG VERSION
30
31COPY --from=builder /usr/src/WireGuard-${VERSION}/ /tmp/WireGuard-${VERSION}/
32
33RUN set -euxo pipefail; \
34 yum install -y kmod; \
35 \
36 mkdir -p /opt/wireguard; \
37 cp /tmp/WireGuard-${VERSION}/src/wireguard.ko /opt/wireguard; \
38 \
39 cd /tmp/WireGuard-${VERSION}/src; \
40 \
41 install -v -d "/usr/bin"; \
42 install -v -d "/usr/share/man/man8"; \
43 install -v -m 0755 tools/wg "/usr/bin/wg"; \
44 install -v -m 0644 tools/man/wg.8 "/usr/share/man/man8/wg.8"; \
45 \
46 install -v -m 0700 -d "/etc/wireguard"; \
47 install -v -m 0755 tools/wg-quick/linux.bash "/usr/bin/wg-quick"; \
48 install -v -m 0644 tools/man/wg-quick.8 "/usr/share/man/man8/wg-quick.8"; \
49 \
50 yum clean all; \
51 rm -rf /tmp/WireGuard-${VERSION} /var/cache/yum
52
53ADD entrypoint.sh /
54
55ENTRYPOINT [ "/entrypoint.sh" ]
56CMD [ "sleep", "infinity" ]
diff --git a/al2-wireguard/Makefile b/al2-wireguard/Makefile
new file mode 100644
index 0000000..35797dc
--- /dev/null
+++ b/al2-wireguard/Makefile
@@ -0,0 +1,25 @@
1WG_VERSION=5.12.42-1e9446c323
2FULL_VERSION="$(shell uname -r)-wg-$(WG_VERSION)"
3IMAGE=docker.crute.me/al2-wireguard:$(FULL_VERSION)
4LATEST=$(subst :$(FULL_VERSION),,$(IMAGE)):latest
5REGION="us-west-2"
6
7all:
8 docker pull amazonlinux:2
9 docker build \
10 --build-arg=VERSION=$(WG_VERSION) \
11 --build-arg=REGION=$(REGION) \
12 -t $(IMAGE) .
13
14all-no-cache:
15 docker pull amazonlinux:2
16 docker build \
17 --no-cache \
18 --build-arg=VERSION=$(WG_VERSION) \
19 --build-arg=REGION=$(REGION) \
20 -t $(IMAGE) .
21
22publish:
23 docker push $(IMAGE)
24 docker tag $(IMAGE) $(LATEST)
25 docker push $(LATEST)
diff --git a/al2-wireguard/entrypoint.sh b/al2-wireguard/entrypoint.sh
new file mode 100755
index 0000000..93f59de
--- /dev/null
+++ b/al2-wireguard/entrypoint.sh
@@ -0,0 +1,18 @@
1#!/bin/sh
2
3# This needs the SYS_MODULES and NET_ADMIN capabilities
4#
5# /etc/wireguard should be mounted and include wg-quick configs
6#
7# /lib/modules/$(uname -r) should be mounted to same in container
8
9modprobe ip6_udp_tunnel
10modprobe udp_tunnel
11
12insmod /opt/wireguard/wireguard.ko
13
14for i in /etc/wireguard/*; do
15 wg-quick up "$(basename ${i/.conf/})"
16done
17
18exec "$@"