From 53f0aae2e4b5472ed75f2fcb1e3461081502409a Mon Sep 17 00:00:00 2001 From: Walter Oggioni Date: Fri, 2 Aug 2024 20:19:27 +0800 Subject: [PATCH] added V2 Ray plugin to shadowsocks docker image --- shadowsocks-rust/Dockerfile | 9 +++++++-- shadowsocks-rust/download_v2ray.sh | 30 ++++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+), 2 deletions(-) create mode 100755 shadowsocks-rust/download_v2ray.sh diff --git a/shadowsocks-rust/Dockerfile b/shadowsocks-rust/Dockerfile index 7308272..858c3bf 100644 --- a/shadowsocks-rust/Dockerfile +++ b/shadowsocks-rust/Dockerfile @@ -3,7 +3,7 @@ FROM --platform=$BUILDPLATFORM rust:alpine AS builder ARG VERSION TARGETPLATFORM BUILDPLATFORM RUN set -x \ - && apk add --no-cache build-base cmake llvm15-dev clang15-libclang clang15 rust-bindgen git rustup + && apk add --no-cache build-base cmake llvm15-dev clang15-libclang clang15 rust-bindgen git rustup curl WORKDIR /root/shadowsocks-rust @@ -40,12 +40,16 @@ RUN case "$TARGETPLATFORM" in \ && RUSTFLAGS="-C linker=$CC" CC=$CC cargo build --target "$RUST_TARGET" --release --features "full-extra" \ && mv target/$RUST_TARGET/release/ss* target/release/ -FROM --platform=$TARGETPLATFORM alpine:3.20 AS sslocal +COPY download_v2ray.sh download_v2ray.sh +RUN ./download_v2ray.sh "$TARGETPLATFORM" + +FROM alpine:3.20 AS sslocal # NOTE: Please be careful to change the path of these binaries, refer to #1149 for more information. COPY --from=builder /root/shadowsocks-rust/target/release/sslocal /usr/bin/ COPY --from=builder /root/shadowsocks-rust/examples/config.json /etc/shadowsocks-rust/ COPY --from=builder /root/shadowsocks-rust/docker/docker-entrypoint.sh /usr/bin/ +COPY --from=builder /tmp/v2ray-plugin /usr/bin/v2ray-plugin ENTRYPOINT [ "docker-entrypoint.sh" ] CMD [ "sslocal", "--log-without-time", "-c", "/etc/shadowsocks-rust/config.json" ] @@ -55,6 +59,7 @@ FROM alpine:3.17 AS ssserver COPY --from=builder /root/shadowsocks-rust/target/release/ssserver /usr/bin/ COPY --from=builder /root/shadowsocks-rust/examples/config.json /etc/shadowsocks-rust/ COPY --from=builder /root/shadowsocks-rust/docker/docker-entrypoint.sh /usr/bin/ +COPY --from=builder /tmp/v2ray-plugin /usr/bin/v2ray-plugin ENTRYPOINT [ "docker-entrypoint.sh" ] diff --git a/shadowsocks-rust/download_v2ray.sh b/shadowsocks-rust/download_v2ray.sh new file mode 100755 index 0000000..f6e64c7 --- /dev/null +++ b/shadowsocks-rust/download_v2ray.sh @@ -0,0 +1,30 @@ +#!/usr/bin/env sh +TARGETPLATFORM=$1 +mkdir /tmp/v2ray_plugin.d +cd /tmp/v2ray_plugin.d +case "$TARGETPLATFORM" in + "linux/386") + url="curl -OJ https://gitea.woggioni.net/api/packages/woggioni/generic/v2ray_plugin-linux-386/v1.3.2-6-g5ffaa81/v2ray-plugin-linux-386-v1.3.2-6-g5ffaa81.tar.gz" + curl --retry 3 "$url" | tar -xvz + mv v2ray-plugin* /tmp/v2ray-plugin + ;; + "linux/amd64") + url="https://gitea.woggioni.net/api/packages/woggioni/generic/v2ray_plugin-linux-amd64/v1.3.2-6-g5ffaa81/v2ray-plugin-linux-amd64-v1.3.2-6-g5ffaa81.tar.gz" + curl --retry 3 "$url" | tar -xvz + mv v2ray-plugin* /tmp/v2ray-plugin + ;; + "linux/arm64") + url="https://gitea.woggioni.net/api/packages/woggioni/generic/v2ray_plugin-linux-arm64/v1.3.2-6-g5ffaa81/v2ray-plugin-linux-arm64-v1.3.2-6-g5ffaa81.tar.gz" + curl --retry 3 "$url" | tar -xvz + mv v2ray-plugin_linux_arm64 /tmp/v2ray-plugin + ;; + "linux/arm/v7") + url="https://gitea.woggioni.net/api/packages/woggioni/generic/v2ray_plugin-linux-arm/v1.3.2-6-g5ffaa81/v2ray-plugin-linux-arm-v1.3.2-6-g5ffaa81.tar.gz" + curl --retry 3 "$url" | tar -xvz + mv v2ray-plugin_linux_armv7 /tmp/v2ray-plugin + ;; + *) + echo "Doesn't support $TARGETPLATFORM architecture" + exit 1 + ;; +esac