Browse Source

Chore: optimize docker files

pull/76/head v2.1.0-beta2
xjasonlyu 4 years ago
parent
commit
2fe6caab12
  1. 5
      Dockerfile
  2. 7
      docker/docker-compose.yml
  3. 11
      docker/entrypoint.sh

5
Dockerfile

@ -17,12 +17,13 @@ COPY --from=builder /tun2socks /usr/bin/tun2socks
RUN apk add --update --no-cache iptables iproute2 \
&& chmod +x /entrypoint.sh
ENV TUN tun0
ENV ETH eth0
ENV TUN=tun0
ENV ETH=eth0
ENV TUN_ADDR=198.18.0.1
ENV TUN_MASK=255.254.0.0
ENV LOGLEVEL=INFO
ENV PROXY=direct://
ENV MTU=9000
ENV STATS=
ENV TOKEN=
ENV EXTRA_COMMANDS=

7
docker/docker-compose.yml

@ -9,10 +9,15 @@ services:
- '/dev/net/tun:/dev/net/tun'
environment:
- GODEBUG=madvdontneed=1
- LOGLEVEL=WARN
- LOGLEVEL=
- TUN=
- ETH=
- TUN_ADDR=
- TUN_MASK=
- PROXY=
- STATS=
- TOKEN=
- MTU=
- EXTRA_COMMANDS=
- TUN_INCLUDED_ROUTES=
- TUN_EXCLUDED_ROUTES=

11
docker/entrypoint.sh

@ -43,11 +43,6 @@ config_route() {
ip rule add from "$eth" priority 9999 table main
ip rule add from all priority 10000 table "$TABLE"
# reserved IP addresses
ip rule add to 0.0.0.0/8 table main
ip rule add to 192.0.2.0/24 table main
ip rule add to 224.0.0.0/4 table main
# add tun included routes
for addr in $(echo "$TUN_INCLUDED_ROUTES" | tr ',' '\n'); do
ip rule add to "$addr" table "$TABLE"
@ -68,8 +63,12 @@ main() {
sh -c "$EXTRA_COMMANDS"
fi
if [ -n "$MTU" ]; then
ARGS="--mtu $MTU"
fi
if [ -n "$STATS" ]; then
ARGS="--stats $STATS"
ARGS="$ARGS --stats $STATS"
fi
if [ -n "$TOKEN" ]; then

Loading…
Cancel
Save