Upload files

Signed-off-by: Lev Rusanov <30170278+JDM170@users.noreply.github.com>
This commit is contained in:
2025-08-12 23:12:26 +07:00
parent 94a6b86de6
commit 85f50360b2
3 changed files with 68 additions and 0 deletions

26
Dockerfile Normal file
View File

@@ -0,0 +1,26 @@
FROM alpine:3.19.2
ARG AWGTOOLS_RELEASE=1.0.20240213
# ARG AWGTOOLS_RELEASE=1.0.20250706
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 && \
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 && \
mkdir /config && \
mkdir -p /etc/amnezia/amneziawg
COPY init.sh init.sh
RUN chmod +x 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"]

18
docker-compose.yml Normal file
View File

@@ -0,0 +1,18 @@
services:
awgtest:
build:
context: .
dockerfile: Dockerfile
container_name: awgtest
cap_add:
- NET_ADMIN
- SYS_MODULE
# sysctls:
# - net.ipv4.ip_forward=1
# - net.ipv4.conf.all.src_valid_mark=1
network_mode: host
devices:
- /dev/net/tun:/dev/net/tun
volumes:
- ./config:/config
restart: unless-stopped

24
init.sh Normal file
View File

@@ -0,0 +1,24 @@
#!/bin/bash
find /etc/amnezia/amneziawg -mindepth 1 -delete
COUNTER=0
for s in $(find /config -name "*.conf")
do
if test -f ${s}
then
COUNTER=$(( COUNTER + 1 ))
basename=$(basename ${s})
name=${basename%.conf}
echo awg interface "${name}" will be created from config file "${basename}"
cp ${s} /etc/amnezia/amneziawg/${name}.conf
chmod 600 /etc/amnezia/amneziawg/${name}.conf
awg-quick up ${name}
iptables -A FORWARD -i ${name} -j ACCEPT
iptables -A FORWARD -o ${name} -j ACCEPT
iptables -A FORWARD -i ${name} -o ${name} -j ACCEPT
fi
done
if [[ $COUNTER -lt 1 ]]
then
echo "There are no config files in the /config folder"
fi