From 9c8194cb1a5a6be03eb152be6b8f1a1dfb2c279b Mon Sep 17 00:00:00 2001 From: Lev Rusanov <30170278+JDM170@users.noreply.github.com> Date: Wed, 13 Aug 2025 13:56:32 +0700 Subject: [PATCH] Upload files Signed-off-by: Lev Rusanov <30170278+JDM170@users.noreply.github.com> --- Dockerfile | 54 +++++++++++++++++++++++++++++++--------------- docker-compose.yml | 6 +++--- init.sh | 3 +++ 3 files changed, 43 insertions(+), 20 deletions(-) diff --git a/Dockerfile b/Dockerfile index bca78f2..e03cd71 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,26 +1,46 @@ -FROM alpine:3.19.2 +ARG GOLANG_VERSION=1.24 +ARG ALPINE_VERSION=3.21 -ARG AWGTOOLS_RELEASE=1.0.20240213 -# ARG AWGTOOLS_RELEASE=1.0.20250706 +# BUILD IMAGE +FROM golang:${GOLANG_VERSION}-alpine${ALPINE_VERSION} AS builder -RUN apk --no-cache add iproute2 iptables bash && \ - cd /usr/bin/ && \ - wget https://github.com/amnezia-vpn/amneziawg-tools/releases/download/v${AWGTOOLS_RELEASE}/alpine-3.19-amneziawg-tools.zip && \ - unzip -j alpine-3.19-amneziawg-tools.zip && \ - chmod +x /usr/bin/awg /usr/bin/awg-quick && \ +WORKDIR /go + +RUN apk add --no-cache git make bash build-base linux-headers && \ + git clone --depth=1 https://github.com/amnezia-vpn/amneziawg-tools.git && \ + git clone --depth=1 https://github.com/amnezia-vpn/amneziawg-go.git && \ + cd /go/amneziawg-tools/src && make && \ + cd /go/amneziawg-go && make && \ + mkdir -p /tmp/build/usr/bin/ && \ + mv /go/amneziawg-go/amneziawg-go /tmp/build/usr/bin/amneziawg-go && \ + mv /go/amneziawg-tools/src/wg /tmp/build/usr/bin/awg && \ + mv /go/amneziawg-tools/src/wg-quick/linux.bash /tmp/build/usr/bin/awg-quick + + +# FINAL IMAGE +FROM alpine:${ALPINE_VERSION} + +COPY --from=builder /tmp/build/ / + +RUN apk --no-cache add iproute2 iptables bash openresolv dpkg dumb-init iptables-legacy && \ + chmod +x /usr/bin/awg /usr/bin/awg-quick /usr/bin/amneziawg-go && \ ln -s /usr/bin/awg /usr/bin/wg && \ - ln -s /usr/bin/awg-quick /usr/bin/wg-quick - -# COPY /usr/bin/amneziawg-go /usr/bin/amneziawg-go - -RUN apk add --no-cache openresolv dpkg dumb-init iptables-legacy && \ - update-alternatives --install /sbin/iptables iptables /sbin/iptables-legacy 10 --slave /sbin/iptables-restore iptables-restore /sbin/iptables-legacy-restore --slave /sbin/iptables-save iptables-save /sbin/iptables-legacy-save && \ + ln -s /usr/bin/awg-quick /usr/bin/wg-quick && \ mkdir /config && \ - mkdir -p /etc/amnezia/amneziawg + mkdir -p /etc/amnezia/amneziawg && \ + # IPv4 + rm /usr/sbin/iptables /usr/sbin/iptables-save /usr/sbin/iptables-restore && \ + ln -s /usr/sbin/iptables-legacy /usr/sbin/iptables && \ + ln -s /usr/sbin/iptables-legacy-save /usr/sbin/iptables-save && \ + ln -s /usr/sbin/iptables-legacy-restore /usr/sbin/iptables-restore && \ + # IPv6 + rm /usr/sbin/ip6tables /usr/sbin/ip6tables-save /usr/sbin/ip6tables-restore && \ + ln -s /usr/sbin/ip6tables-legacy /usr/sbin/ip6tables && \ + ln -s /usr/sbin/ip6tables-legacy-save /usr/sbin/ip6tables-save && \ + ln -s /usr/sbin/ip6tables-legacy-restore /usr/sbin/ip6tables-restore -COPY init.sh init.sh -RUN chmod +x init.sh +COPY --chmod=775 init.sh init.sh HEALTHCHECK --interval=1m --timeout=5s --retries=3 CMD /usr/bin/timeout 5s /bin/sh -c \"awg show | grep interface || exit 1\" ENTRYPOINT ["/usr/bin/dumb-init", "/init.sh"] diff --git a/docker-compose.yml b/docker-compose.yml index a7ce297..86334d9 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,5 +1,5 @@ services: - awgtest: + amneziawg-client: build: context: . dockerfile: Dockerfile @@ -14,5 +14,5 @@ services: devices: - /dev/net/tun:/dev/net/tun volumes: - - ./config:/config - restart: unless-stopped \ No newline at end of file + - ./config:/config:ro + restart: unless-stopped diff --git a/init.sh b/init.sh index a6cfb58..bb56c65 100644 --- a/init.sh +++ b/init.sh @@ -22,3 +22,6 @@ if [[ $COUNTER -lt 1 ]] then echo "There are no config files in the /config folder" fi + +/bin/sh +