Skip to content

Commit

Permalink
docker: add IPTABLES_MODE env
Browse files Browse the repository at this point in the history
  • Loading branch information
Markson Hon committed Dec 16, 2023
1 parent 46e056e commit c5979fd
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 2 deletions.
5 changes: 3 additions & 2 deletions install/docker/Dockerfile.Action
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
FROM alpine:latest AS builder
WORKDIR /build
WORKDIR /
COPY ./install/docker/docker_helper.sh ./docker_helper.sh
COPY ./install/docker/iptables.sh ./iptables.sh
COPY ./install/docker/ip6tables.sh ./ip6tables.sh
RUN sh -c "$(cat ./docker_helper.sh)"
RUN apk add --no-cache iptables ip6tables nftables tzdata
RUN rm ./docker_helper.sh
EXPOSE 2017
VOLUME /etc/v2raya
Expand Down
11 changes: 11 additions & 0 deletions install/docker/docker_helper.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ case "$(arch)" in
*)
;;
esac
mkdir -p build && cd build || exit
wget https://github.com/v2fly/v2ray-core/releases/latest/download/v2ray-linux-$v2ray_arch.zip
wget https://github.com/XTLS/Xray-core/releases/latest/download/Xray-linux-$v2ray_arch.zip
wget https://github.com/v2rayA/v2rayA/releases/download/vRealv2rayAVersion/v2raya_linux_"$v2raya_arch"_Realv2rayAVersion
Expand All @@ -33,3 +34,13 @@ wget -O /usr/local/share/v2raya/LoyalsoldierSite.dat https://raw.githubuserconte
wget -O /usr/local/share/v2raya/geosite.dat https://raw.githubusercontent.com/mzz2017/dist-v2ray-rules-dat/master/geosite.dat
wget -O /usr/local/share/v2raya/geoip.dat https://raw.githubusercontent.com/mzz2017/dist-v2ray-rules-dat/master/geoip.dat
cd "$current_dir" && rm -rf "$current_dir"/cache
apk add --no-cache tzdata iptables-legacy nftables
cd ..
rm -rf build
[ -d /usr/local/sbin ] || mkdir -p /usr/local/sbin
install ./iptables.sh /usr/local/sbin/iptables
install ./ip6tables.sh /usr/local/sbin/ip6tables
install ./iptables.sh /usr/local/sbin/iptables-nft
install ./ip6tables.sh /usr/local/sbin/ip6tables-nft
install ./iptables.sh /usr/local/sbin/iptables-legacy
install ./ip6tables.sh /usr/local/sbin/ip6tables-legacy
11 changes: 11 additions & 0 deletions install/docker/ip6tables.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/sh

if [ "$V2RAYA_NFTABLES_SUPPORT" != on ]; then
if [ "$IPTABLES_MODE" = "nftables" ]; then
/sbin/ip6tables-nft "$@"
elif [ "$IPTABLES_MODE" = "legacy" ]; then
/sbin/ip6tables-legacy "$@"
else
/sbin/ip6tables "$@"
fi
fi
11 changes: 11 additions & 0 deletions install/docker/iptables.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/sh

if [ "$V2RAYA_NFTABLES_SUPPORT" != on ]; then
if [ "$IPTABLES_MODE" = "nftables" ]; then
/sbin/iptables-nft "$@"
elif [ "$IPTABLES_MODE" = "legacy" ]; then
/sbin/iptables-legacy "$@"
else
/sbin/iptables "$@"
fi
fi

0 comments on commit c5979fd

Please sign in to comment.