Browse Source

build: update docker image

dev
dnomd343 2 years ago
parent
commit
2aaf1e17f2
  1. 263
      Dockerfile

263
Dockerfile

@ -1,32 +1,32 @@
ARG ALPINE_IMG="alpine:3.16" ARG ALPINE_IMG="alpine:3.16"
ARG RUST_IMG="rust:1.62-alpine3.16" ARG RUST_IMG="rust:1.63-alpine3.16"
ARG GO14_IMG="golang:1.14-alpine3.13" ARG GO14_IMG="golang:1.14-alpine3.13"
ARG GO16_IMG="golang:1.16-alpine3.15" ARG GO16_IMG="golang:1.16-alpine3.15"
ARG GO17_IMG="golang:1.17-alpine3.16" ARG GO17_IMG="golang:1.17-alpine3.16"
ARG GO18_IMG="golang:1.18-alpine3.16" ARG GO18_IMG="golang:1.18-alpine3.16"
ARG GO19_IMG="golang:1.19-alpine3.16"
ARG PYTHON_IMG="python:3.10-alpine3.16" ARG PYTHON_IMG="python:3.10-alpine3.16"
# Download build-base # Download build-base
FROM ${ALPINE_IMG} AS build-base FROM ${ALPINE_IMG} AS build-base
WORKDIR /apk/ WORKDIR /apk/
RUN apk add build-base | grep -oE 'Installing \S+' | cut -b 12- > ./build-base RUN echo "apk add --no-network \\" > ./build-base && chmod +x ./build-base && \
RUN chmod +x ./build-base && cat ./build-base | xargs -n1 apk fetch && \ apk update && apk fetch -R build-base | grep -oE '\S+$' | awk '{print "/apk/"$0".apk \\"}' >> ./build-base
sed -i 's/^/ \/apk\/&/g;s/$/&-*.apk/g;1i\apk add' ./build-base && sed -i ':a;N;s/\n//g;ba' ./build-base
# Compile numpy # Compile python3 module numpy
FROM ${PYTHON_IMG} AS numpy FROM ${PYTHON_IMG} AS numpy
WORKDIR /wheels/ WORKDIR /wheels/
COPY --from=build-base /apk/ /apk/ COPY --from=build-base /apk/ /apk/
RUN /apk/build-base && pip wheel numpy RUN /apk/build-base && pip wheel numpy
# Compile gevent # Compile python3 module gevent
FROM ${PYTHON_IMG} AS gevent FROM ${PYTHON_IMG} AS gevent
WORKDIR /wheels/ WORKDIR /wheels/
RUN apk add libffi-dev RUN apk add libffi-dev
COPY --from=build-base /apk/ /apk/ COPY --from=build-base /apk/ /apk/
RUN /apk/build-base && pip wheel gevent RUN /apk/build-base && pip wheel gevent
# Build python wheels # Build python3 wheels
FROM ${PYTHON_IMG} AS wheels FROM ${PYTHON_IMG} AS wheels
WORKDIR /wheels/ WORKDIR /wheels/
RUN apk add linux-headers RUN apk add linux-headers
@ -35,13 +35,11 @@ RUN /apk/build-base && pip wheel colorlog flask IPy psutil pysocks pyyaml reques
COPY --from=gevent /wheels/*.whl /wheels/ COPY --from=gevent /wheels/*.whl /wheels/
COPY --from=numpy /wheels/*.whl /wheels/ COPY --from=numpy /wheels/*.whl /wheels/
# Compile upx (under gcc10) # Compile upx (use gcc10 for now)
FROM ${ALPINE_IMG} AS upx FROM ${ALPINE_IMG} AS upx
ENV UPX_VERSION="3.96" ENV UPX_VERSION="3.96"
RUN sed -i 's/v3.\d\d/v3.15/' /etc/apk/repositories && \ RUN sed -i 's/v3.\d\d/v3.15/' /etc/apk/repositories && apk add bash build-base perl ucl-dev zlib-dev
apk add bash build-base perl ucl-dev zlib-dev RUN wget https://github.com/upx/upx/releases/download/v${UPX_VERSION}/upx-${UPX_VERSION}-src.tar.xz && tar xf upx-${UPX_VERSION}-src.tar.xz
RUN wget https://github.com/upx/upx/releases/download/v${UPX_VERSION}/upx-${UPX_VERSION}-src.tar.xz && \
tar xf upx-${UPX_VERSION}-src.tar.xz
WORKDIR ./upx-${UPX_VERSION}-src/ WORKDIR ./upx-${UPX_VERSION}-src/
RUN make -C ./src/ && mkdir -p /upx/bin/ && mv ./src/upx.out /upx/bin/upx && \ RUN make -C ./src/ && mkdir -p /upx/bin/ && mv ./src/upx.out /upx/bin/upx && \
mkdir -p /upx/lib/ && cd /usr/lib/ && cp -d ./libgcc_s.so* ./libstdc++.so* ./libucl.so* /upx/lib/ mkdir -p /upx/lib/ && cd /usr/lib/ && cp -d ./libgcc_s.so* ./libstdc++.so* ./libucl.so* /upx/lib/
@ -50,14 +48,13 @@ RUN make -C ./src/ && mkdir -p /upx/bin/ && mv ./src/upx.out /upx/bin/upx && \
FROM ${RUST_IMG} AS ss-rust FROM ${RUST_IMG} AS ss-rust
ENV SS_RUST="1.15.0-alpha.8" ENV SS_RUST="1.15.0-alpha.8"
COPY --from=build-base /apk/ /apk/ COPY --from=build-base /apk/ /apk/
RUN wget https://github.com/shadowsocks/shadowsocks-rust/archive/refs/tags/v${SS_RUST}.tar.gz && \ RUN /apk/build-base && \
tar xf v${SS_RUST}.tar.gz && /apk/build-base wget https://github.com/shadowsocks/shadowsocks-rust/archive/refs/tags/v${SS_RUST}.tar.gz && tar xf v${SS_RUST}.tar.gz
WORKDIR ./shadowsocks-rust-${SS_RUST}/ WORKDIR ./shadowsocks-rust-${SS_RUST}/
RUN cargo fetch RUN cargo fetch
RUN cargo build --target-dir ./ --release --bin sslocal --bin ssserver \ RUN cargo build --target-dir ./ --release --bin sslocal --bin ssserver \
--features "stream-cipher aead-cipher-extra aead-cipher-2022 aead-cipher-2022-extra" && \ --features "stream-cipher aead-cipher-extra aead-cipher-2022 aead-cipher-2022-extra" && \
mv ./release/sslocal /tmp/ss-rust-local && mv ./release/ssserver /tmp/ss-rust-server && \ mv ./release/sslocal /tmp/ss-rust-local && mv ./release/ssserver /tmp/ss-rust-server && strip /tmp/ss-rust-*
strip /tmp/ss-rust-*
COPY --from=upx /upx/ /usr/ COPY --from=upx /upx/ /usr/
RUN ls /tmp/ss-rust-* | xargs -P0 -n1 upx -9 RUN ls /tmp/ss-rust-* | xargs -P0 -n1 upx -9
@ -66,12 +63,11 @@ FROM ${ALPINE_IMG} AS ss-libev
ENV SS_LIBEV="3.3.5" ENV SS_LIBEV="3.3.5"
RUN apk add c-ares-dev libev-dev libsodium-dev linux-headers mbedtls-dev pcre-dev RUN apk add c-ares-dev libev-dev libsodium-dev linux-headers mbedtls-dev pcre-dev
COPY --from=build-base /apk/ /apk/ COPY --from=build-base /apk/ /apk/
RUN wget https://github.com/shadowsocks/shadowsocks-libev/releases/download/v${SS_LIBEV}/shadowsocks-libev-${SS_LIBEV}.tar.gz && \ RUN /apk/build-base && \
tar xf shadowsocks-libev-*.tar.gz && /apk/build-base wget https://github.com/shadowsocks/shadowsocks-libev/releases/download/v${SS_LIBEV}/shadowsocks-libev-${SS_LIBEV}.tar.gz && tar xf shadowsocks-libev-*.tar.gz
WORKDIR ./shadowsocks-libev-${SS_LIBEV}/ WORKDIR ./shadowsocks-libev-${SS_LIBEV}/
RUN ./configure --disable-documentation && make && \ RUN ./configure --disable-documentation && make && \
mv ./src/ss-local /tmp/ss-libev-local && mv ./src/ss-server /tmp/ss-libev-server && \ mv ./src/ss-local /tmp/ss-libev-local && mv ./src/ss-server /tmp/ss-libev-server && strip /tmp/ss-libev-*
strip /tmp/ss-libev-*
# Package shadowsocks-python (lastest version, legacy version, R version aka ssr) # Package shadowsocks-python (lastest version, legacy version, R version aka ssr)
FROM ${PYTHON_IMG} AS ss-python FROM ${PYTHON_IMG} AS ss-python
@ -79,8 +75,7 @@ ENV SS_PYTHON_LEGACY="2.6.2"
RUN apk add git && mkdir /packages/ && \ RUN apk add git && mkdir /packages/ && \
git clone https://github.com/dnomd343/shadowsocksr.git && \ git clone https://github.com/dnomd343/shadowsocksr.git && \
git clone https://github.com/shadowsocks/shadowsocks.git && \ git clone https://github.com/shadowsocks/shadowsocks.git && \
wget https://github.com/shadowsocks/shadowsocks/archive/refs/tags/${SS_PYTHON_LEGACY}.tar.gz && \ wget https://github.com/shadowsocks/shadowsocks/archive/refs/tags/${SS_PYTHON_LEGACY}.tar.gz && tar xf ${SS_PYTHON_LEGACY}.tar.gz
tar xf ${SS_PYTHON_LEGACY}.tar.gz
# shadowsocks-python (R version) # shadowsocks-python (R version)
WORKDIR ./shadowsocksr/ WORKDIR ./shadowsocksr/
RUN sed -i 's/MutableMapping/abc.MutableMapping/' ./shadowsocks/lru_cache.py && \ RUN sed -i 's/MutableMapping/abc.MutableMapping/' ./shadowsocks/lru_cache.py && \
@ -88,9 +83,8 @@ RUN sed -i 's/MutableMapping/abc.MutableMapping/' ./shadowsocks/lru_cache.py &&
sed -i "s/find_library(p)/'libcrypto.so.1.0.0'/g" ./shadowsocks/crypto/ctypes_openssl.py && \ sed -i "s/find_library(p)/'libcrypto.so.1.0.0'/g" ./shadowsocks/crypto/ctypes_openssl.py && \
sed -i "/for path in paths:/a\ if 'libcrypto.so' in path:" ./shadowsocks/crypto/util.py && \ sed -i "/for path in paths:/a\ if 'libcrypto.so' in path:" ./shadowsocks/crypto/util.py && \
sed -i "/libcrypto.so/a\ path = 'libcrypto.so.1.0.0'" ./shadowsocks/crypto/util.py && \ sed -i "/libcrypto.so/a\ path = 'libcrypto.so.1.0.0'" ./shadowsocks/crypto/util.py && \
python3 setup.py build && cd ./build/lib/shadowsocks/ && \ python3 setup.py build && cd ./build/lib/shadowsocks/ && chmod +x ./local.py ./server.py && \
chmod +x ./local.py ./server.py && mv ./local.py ./server.py ../ && \ mv ./local.py ./server.py ../ && mv ../../lib/ /packages/ssr-python/
mv ../../lib/ /packages/ssr-python/
# shadowsocks-python (latest version) # shadowsocks-python (latest version)
WORKDIR ../shadowsocks/ WORKDIR ../shadowsocks/
RUN git checkout master && \ RUN git checkout master && \
@ -98,17 +92,15 @@ RUN git checkout master && \
sed -i 's/and ip is not/and ip !=/g' ./shadowsocks/common.py && \ sed -i 's/and ip is not/and ip !=/g' ./shadowsocks/common.py && \
sed -i 's/if len(block) is/if len(block) ==/g' ./shadowsocks/common.py && \ sed -i 's/if len(block) is/if len(block) ==/g' ./shadowsocks/common.py && \
sed -i 's/MutableMapping/abc.MutableMapping/' ./shadowsocks/lru_cache.py && \ sed -i 's/MutableMapping/abc.MutableMapping/' ./shadowsocks/lru_cache.py && \
python3 setup.py build && cd ./build/lib/shadowsocks/ && \ python3 setup.py build && cd ./build/lib/shadowsocks/ && chmod +x ./local.py ./server.py && \
chmod +x ./local.py ./server.py && mv ./local.py ./server.py ../ && \ mv ./local.py ./server.py ../ && mv ../../lib/ /packages/ss-python/
mv ../../lib/ /packages/ss-python/
# shadowsocks-python (legacy version) # shadowsocks-python (legacy version)
WORKDIR ../shadowsocks-${SS_PYTHON_LEGACY}/ WORKDIR ../shadowsocks-${SS_PYTHON_LEGACY}/
RUN sed -i 's/MutableMapping/abc.MutableMapping/' ./shadowsocks/lru_cache.py && \ RUN sed -i 's/MutableMapping/abc.MutableMapping/' ./shadowsocks/lru_cache.py && \
sed -i "s/find_library(p)/'libsodium.so.23'/g" ./shadowsocks/crypto/ctypes_libsodium.py && \ sed -i "s/find_library(p)/'libsodium.so.23'/g" ./shadowsocks/crypto/ctypes_libsodium.py && \
sed -i "s/find_library(p)/'libcrypto.so.1.0.0'/g" ./shadowsocks/crypto/ctypes_openssl.py && \ sed -i "s/find_library(p)/'libcrypto.so.1.0.0'/g" ./shadowsocks/crypto/ctypes_openssl.py && \
python3 setup.py build && cd ./build/lib/shadowsocks/ && \ python3 setup.py build && cd ./build/lib/shadowsocks/ && chmod +x ./local.py ./server.py && \
chmod +x ./local.py ./server.py && mv ./local.py ./server.py ../ && \ mv ./local.py ./server.py ../ && mv ../../lib/ /packages/ss-python-legacy/
mv ../../lib/ /packages/ss-python-legacy/
# Compile shadowsocks-bootstrap # Compile shadowsocks-bootstrap
FROM ${ALPINE_IMG} AS ss-bootstrap FROM ${ALPINE_IMG} AS ss-bootstrap
@ -117,8 +109,7 @@ COPY --from=build-base /apk/ /apk/
RUN git clone https://github.com/dnomd343/shadowsocks-bootstrap.git && /apk/build-base RUN git clone https://github.com/dnomd343/shadowsocks-bootstrap.git && /apk/build-base
WORKDIR ./shadowsocks-bootstrap/build/ WORKDIR ./shadowsocks-bootstrap/build/
RUN cmake -DCMAKE_BUILD_TYPE=Release .. && make && \ RUN cmake -DCMAKE_BUILD_TYPE=Release .. && make && \
mv ../bin/ss-bootstrap-* /tmp/ && \ mv ../bin/ss-bootstrap-* /tmp/ && strip /tmp/ss-bootstrap-*
strip /tmp/ss-bootstrap-*
# Combine shadowsocks dependencies # Combine shadowsocks dependencies
FROM ${PYTHON_IMG} AS shadowsocks FROM ${PYTHON_IMG} AS shadowsocks
@ -133,46 +124,41 @@ RUN ln -s /usr/local/lib/python${PYTHON}/site-packages/ssr-python/local.py /rele
ln -s /usr/local/lib/python${PYTHON}/site-packages/ss-python-legacy/local.py /release/ss-python-legacy-local && \ ln -s /usr/local/lib/python${PYTHON}/site-packages/ss-python-legacy/local.py /release/ss-python-legacy-local && \
ln -s /usr/local/lib/python${PYTHON}/site-packages/ss-python-legacy/server.py /release/ss-python-legacy-server ln -s /usr/local/lib/python${PYTHON}/site-packages/ss-python-legacy/server.py /release/ss-python-legacy-server
# Pack python modules # Pack python3 modules
FROM ${ALPINE_IMG} AS python-pkg FROM ${ALPINE_IMG} AS python-pkg
COPY --from=wheels /wheels/*.whl /site-packages/ COPY --from=wheels /wheels/*.whl /site-packages/
COPY --from=ss-python /packages/ /site-packages/ COPY --from=ss-python /packages/ /site-packages/
WORKDIR /site-packages/ WORKDIR /site-packages/
RUN ls ./*.whl | xargs -n1 unzip && rm ./*.whl && \ RUN ls ./*.whl | xargs -n1 unzip && rm ./*.whl && \
rm -rf $(find ./ -name '__pycache__') && \ rm -rf $(find ./ -name '__pycache__') && tar czf /packages.tar.gz ./
BZIP2=-9 tar czf /packages.tar.gz ./
# Compile openssl (old version, for shadowsocks method -> idea-cfb / seed-cfb) # Compile openssl (old version, for shadowsocks method -> idea-cfb / seed-cfb)
FROM ${ALPINE_IMG} AS openssl FROM ${ALPINE_IMG} AS openssl
ENV OPENSSL_VER="1.0.2" ENV OPENSSL_VER="1.0.2"
ENV OPENSSL_SUB_VER="u" ENV OPENSSL_SUB_VER="u"
RUN apk add perl
COPY --from=build-base /apk/ /apk/ COPY --from=build-base /apk/ /apk/
RUN wget https://www.openssl.org/source/old/${OPENSSL_VER}/openssl-${OPENSSL_VER}${OPENSSL_SUB_VER}.tar.gz && \ RUN apk add perl && /apk/build-base && \
tar xf openssl-*.tar.gz && /apk/build-base wget https://www.openssl.org/source/old/${OPENSSL_VER}/openssl-${OPENSSL_VER}${OPENSSL_SUB_VER}.tar.gz && tar xf openssl-*.tar.gz
WORKDIR ./openssl-${OPENSSL_VER}${OPENSSL_SUB_VER}/ WORKDIR ./openssl-${OPENSSL_VER}${OPENSSL_SUB_VER}/
RUN ./config --shared --prefix=/usr && make && \ RUN ./config --shared --prefix=/usr && make && \
mv ./libcrypto.so.1.0.0 /tmp/ && \ mv ./libcrypto.so.1.0.0 /tmp/ && strip /tmp/libcrypto.so.1.0.0
strip /tmp/libcrypto.so.1.0.0
# Compile sip003 plugins (part1 -> gcc & cargo) # Compile sip003 plugins (part1 -> gcc & cargo)
FROM ${RUST_IMG} AS plugin-1 FROM ${RUST_IMG} AS plugin-1
RUN apk add autoconf automake git libev-dev libtool linux-headers RUN apk add autoconf automake git libev-dev libtool linux-headers
COPY --from=build-base /apk/ /apk/ COPY --from=build-base /apk/ /apk/
RUN git clone https://github.com/shadowsocks/qtun.git && \ RUN /apk/build-base && mkdir -p /plugins/ && \
git clone https://github.com/shadowsocks/simple-obfs.git && \ git clone https://github.com/shadowsocks/qtun.git && \
/apk/build-base && mkdir -p /plugins/ git clone https://github.com/shadowsocks/simple-obfs.git
# Compile simple-obfs # Compile simple-obfs
WORKDIR ./simple-obfs/ WORKDIR ./simple-obfs/
RUN git submodule update --init --recursive && \ RUN git submodule update --init --recursive && ./autogen.sh && \
./autogen.sh && ./configure --disable-documentation && make && \ ./configure --disable-documentation && make && mv ./src/obfs-local ./src/obfs-server /plugins/
mv ./src/obfs-local ./src/obfs-server /plugins/
# Compile qtun # Compile qtun
WORKDIR ../qtun/ WORKDIR ../qtun/
RUN cargo fetch RUN cargo fetch
RUN cargo build --target-dir ./ --release && \ RUN cargo build --target-dir ./ --release && \
mv ./release/qtun-client ./release/qtun-server /plugins/ && \ mv ./release/qtun-client ./release/qtun-server /plugins/ && strip /plugins/*
strip /plugins/*
COPY --from=upx /upx/ /usr/ COPY --from=upx /upx/ /usr/
RUN ls /plugins/qtun-* | xargs -P0 -n1 upx -9 RUN ls /plugins/qtun-* | xargs -P0 -n1 upx -9
@ -190,8 +176,7 @@ RUN git clone https://github.com/Qv2ray/gun.git && \
git clone https://github.com/IrineSistiana/mos-tls-tunnel.git git clone https://github.com/IrineSistiana/mos-tls-tunnel.git
# Compile v2ray-plugin # Compile v2ray-plugin
WORKDIR ./v2ray-plugin/ WORKDIR ./v2ray-plugin/
RUN env CGO_ENABLED=0 go build -v -trimpath -ldflags "-X main.VERSION=$(git describe --tags) -s -w" && \ RUN env CGO_ENABLED=0 go build -v -trimpath -ldflags "-X main.VERSION=$(git describe --tags) -s -w" && mv ./v2ray-plugin /plugins/
mv ./v2ray-plugin /plugins/
# Compile kcptun # Compile kcptun
WORKDIR ../kcptun/ WORKDIR ../kcptun/
RUN git checkout sip003 && \ RUN git checkout sip003 && \
@ -202,8 +187,7 @@ RUN env CGO_ENABLED=0 go build -v -o kcptun-client -trimpath -ldflags "-X main.V
# Compile gost-plugin # Compile gost-plugin
WORKDIR ../gost-plugin/ WORKDIR ../gost-plugin/
RUN git checkout ${GOST_PLUGIN} && go mod download -x RUN git checkout ${GOST_PLUGIN} && go mod download -x
RUN env CGO_ENABLED=0 go build -v -trimpath -ldflags "-X main.VERSION=$(git describe --tags) -s -w" && \ RUN env CGO_ENABLED=0 go build -v -trimpath -ldflags "-X main.VERSION=$(git describe --tags) -s -w" && mv ./gost-plugin /plugins/
mv ./gost-plugin /plugins/
# Compile GoQuiet # Compile GoQuiet
WORKDIR ../GoQuiet/ WORKDIR ../GoQuiet/
RUN go mod init github.com/cbeuw/GoQuiet RUN go mod init github.com/cbeuw/GoQuiet
@ -219,18 +203,15 @@ RUN env CGO_ENABLED=0 go build -v -mod=vendor -trimpath -ldflags "-s -w" ./cmd/m
# Compile rabbit-plugin # Compile rabbit-plugin
WORKDIR ../rabbit-plugin/ WORKDIR ../rabbit-plugin/
RUN go mod download -x RUN go mod download -x
RUN env CGO_ENABLED=0 go build -v -trimpath -ldflags "-s -w" && \ RUN env CGO_ENABLED=0 go build -v -trimpath -ldflags "-s -w" && mv ./rabbit-plugin /plugins/
mv ./rabbit-plugin /plugins/
# Compile rabbit-tcp # Compile rabbit-tcp
WORKDIR ../rabbit-tcp/ WORKDIR ../rabbit-tcp/
RUN go mod download -x RUN go mod download -x
RUN env CGO_ENABLED=0 go build -v -trimpath -ldflags "-X main.Version=$(git describe --tags) -s -w" ./cmd/rabbit.go && \ RUN env CGO_ENABLED=0 go build -v -trimpath -ldflags "-X main.Version=$(git describe --tags) -s -w" ./cmd/rabbit.go && mv ./rabbit /plugins/
mv ./rabbit /plugins/
# Compile gun-plugin # Compile gun-plugin
WORKDIR ../gun/ WORKDIR ../gun/
RUN go mod download -x RUN go mod download -x
RUN env CGO_ENABLED=0 go build -v -o gun-plugin -trimpath -ldflags "-s -w" ./cmd/sip003/ && \ RUN env CGO_ENABLED=0 go build -v -o gun-plugin -trimpath -ldflags "-s -w" ./cmd/sip003/ && mv ./gun-plugin /plugins/
mv ./gun-plugin /plugins/
COPY --from=upx /upx/ /usr/ COPY --from=upx /upx/ /usr/
RUN ls /plugins/* | xargs -P0 -n1 upx -9 RUN ls /plugins/* | xargs -P0 -n1 upx -9
@ -240,19 +221,12 @@ ENV SIMPLE_TLS="v0.7.0"
ENV CLOAK="v2.6.0" ENV CLOAK="v2.6.0"
RUN apk add git && mkdir /plugins/ RUN apk add git && mkdir /plugins/
RUN git clone https://github.com/cbeuw/Cloak.git && \ RUN git clone https://github.com/cbeuw/Cloak.git && \
git clone https://github.com/teddysun/xray-plugin.git && \
git clone https://github.com/IrineSistiana/simple-tls.git git clone https://github.com/IrineSistiana/simple-tls.git
# Compile simple-tls # Compile simple-tls
WORKDIR ./simple-tls/ WORKDIR ./simple-tls/
RUN git checkout ${SIMPLE_TLS} && go mod download -x RUN git checkout ${SIMPLE_TLS} && go mod download -x
RUN sed -i 's/version = "unknown\/dev"/version = "'$(git describe --tags)'"/g' main.go && \ RUN sed -i 's/version = "unknown\/dev"/version = "'$(git describe --tags)'"/g' main.go && \
env CGO_ENABLED=0 go build -v -trimpath -ldflags "-s -w" && \ env CGO_ENABLED=0 go build -v -trimpath -ldflags "-s -w" && mv ./simple-tls /plugins/
mv ./simple-tls /plugins/
# Compile xray-plugin
WORKDIR ../xray-plugin/
RUN go mod download -x
RUN env CGO_ENABLED=0 go build -v -trimpath -ldflags "-X main.VERSION=$(git describe --tags) -s -w" && \
mv ./xray-plugin /plugins/
# Compile Cloak # Compile Cloak
WORKDIR ../Cloak/ WORKDIR ../Cloak/
RUN git checkout ${CLOAK} && go mod download -x RUN git checkout ${CLOAK} && go mod download -x
@ -262,41 +236,63 @@ RUN env CGO_ENABLED=0 go build -v -trimpath -ldflags "-X main.version=$(git desc
COPY --from=upx /upx/ /usr/ COPY --from=upx /upx/ /usr/
RUN ls /plugins/* | xargs -P0 -n1 upx -9 RUN ls /plugins/* | xargs -P0 -n1 upx -9
# Compile sip003 plugins (part4 -> go1.18)
FROM ${GO18_IMG} AS plugin-4
RUN apk add git && mkdir /plugins/
RUN git clone https://github.com/teddysun/xray-plugin.git
# Compile xray-plugin
WORKDIR ./xray-plugin/
RUN go mod download -x
RUN env CGO_ENABLED=0 go build -v -trimpath -ldflags "-X main.VERSION=$(git describe --tags) -s -w" && mv ./xray-plugin /plugins/
COPY --from=upx /upx/ /usr/
RUN ls /plugins/* | xargs -P0 -n1 upx -9
# Combine sip003 plugins # Combine sip003 plugins
FROM ${ALPINE_IMG} AS plugin FROM ${ALPINE_IMG} AS plugin
COPY --from=plugin-1 /plugins/ /plugins/ COPY --from=plugin-1 /plugins/ /plugins/
COPY --from=plugin-2 /plugins/ /plugins/ COPY --from=plugin-2 /plugins/ /plugins/
COPY --from=plugin-3 /plugins/ /plugins/ COPY --from=plugin-3 /plugins/ /plugins/
COPY --from=plugin-4 /plugins/ /plugins/
# Compile xray-core and v2fly-core # Compile xray-core
FROM ${GO18_IMG} AS v2ray FROM golang:1.18-alpine3.16 AS xray
ENV XRAY_VERSION="1.5.9" ENV XRAY_VERSION="1.5.10"
ENV V2FLY_VERSION="4.45.2" RUN wget https://github.com/XTLS/Xray-core/archive/refs/tags/v${XRAY_VERSION}.tar.gz && tar xf v${XRAY_VERSION}.tar.gz
RUN wget https://github.com/XTLS/Xray-core/archive/refs/tags/v${XRAY_VERSION}.tar.gz && \
tar xf v${XRAY_VERSION}.tar.gz
RUN wget https://github.com/v2fly/v2ray-core/archive/refs/tags/v${V2FLY_VERSION}.tar.gz && \
tar xf v${V2FLY_VERSION}.tar.gz
WORKDIR ./Xray-core-${XRAY_VERSION}/ WORKDIR ./Xray-core-${XRAY_VERSION}/
RUN go mod download -x RUN go mod download -x
RUN env CGO_ENABLED=0 go build -v -o xray -trimpath -ldflags "-s -w" ./main && \ RUN env CGO_ENABLED=0 go build -v -o xray -trimpath -ldflags "-s -w" ./main/ && mv ./xray /tmp/
mv ./xray /tmp/ COPY --from=upx /upx/ /usr/
WORKDIR ../v2ray-core-${V2FLY_VERSION}/ RUN upx -9 /tmp/xray
# Compile v2ray-core
FROM golang:1.18-alpine3.16 AS v2ray
ENV V2FLY_VERSION="4.45.2"
RUN wget https://github.com/v2fly/v2ray-core/archive/refs/tags/v${V2FLY_VERSION}.tar.gz && tar xf v${V2FLY_VERSION}.tar.gz
WORKDIR ./v2ray-core-${V2FLY_VERSION}/
RUN go mod download -x RUN go mod download -x
RUN env CGO_ENABLED=0 go build -v -o v2ray -trimpath -ldflags "-s -w" ./main && \ RUN env CGO_ENABLED=0 go build -v -o v2ray -trimpath -ldflags "-s -w" ./main/ && mv ./v2ray /tmp/
mv ./v2ray /tmp/
COPY --from=upx /upx/ /usr/ COPY --from=upx /upx/ /usr/
RUN ls /tmp/*ray | xargs -P0 -n1 upx -9 RUN upx -9 /tmp/v2ray
# Compile v2ray-core (Sagernet version)
FROM golang:1.18-alpine3.16 AS sagray
ENV SAGER_VERSION="5.0.16"
RUN wget https://github.com/SagerNet/v2ray-core/archive/refs/tags/v${SAGER_VERSION}.tar.gz && tar xf v${SAGER_VERSION}.tar.gz
WORKDIR ./v2ray-core-${SAGER_VERSION}/
RUN go mod download -x
RUN env CGO_ENABLED=0 go build -v -o sagray -trimpath -ldflags "-s -w" ./main/ && mv ./sagray /tmp/
COPY --from=upx /upx/ /usr/
RUN upx -9 /tmp/sagray
# Compile trojan-go # Compile trojan-go
FROM ${GO17_IMG} AS trojan-go FROM ${GO17_IMG} AS trojan-go
ENV TROJAN_GO_VERSION="v0.10.6" ENV TROJAN_GO_VERSION="v0.10.6"
RUN apk add git RUN apk add git && git clone https://github.com/p4gefau1t/trojan-go.git
RUN git clone https://github.com/p4gefau1t/trojan-go.git
WORKDIR ./trojan-go/ WORKDIR ./trojan-go/
RUN git checkout ${TROJAN_GO_VERSION} && go mod download -x RUN git checkout ${TROJAN_GO_VERSION} && go mod download -x
RUN env CGO_ENABLED=0 go build -v -trimpath -ldflags " \ RUN env CGO_ENABLED=0 go build -v -tags "full" -trimpath -ldflags " \
-X github.com/p4gefau1t/trojan-go/constant.Version=$(git describe --dirty) \ -X github.com/p4gefau1t/trojan-go/constant.Version=$(git describe --dirty) \
-X github.com/p4gefau1t/trojan-go/constant.Commit=$(git rev-parse HEAD) -s -w" -tags "full" && \ -X github.com/p4gefau1t/trojan-go/constant.Commit=$(git rev-parse HEAD) -s -w" && \
mv ./trojan-go /tmp/ mv ./trojan-go /tmp/
COPY --from=upx /upx/ /usr/ COPY --from=upx /upx/ /usr/
RUN upx -9 /tmp/trojan-go RUN upx -9 /tmp/trojan-go
@ -306,49 +302,42 @@ FROM ${ALPINE_IMG} AS trojan
ENV TROJAN_VERSION="1.16.0" ENV TROJAN_VERSION="1.16.0"
RUN apk add boost-dev cmake openssl-dev RUN apk add boost-dev cmake openssl-dev
COPY --from=build-base /apk/ /apk/ COPY --from=build-base /apk/ /apk/
RUN wget https://github.com/trojan-gfw/trojan/archive/refs/tags/v${TROJAN_VERSION}.tar.gz && \ RUN /apk/build-base && \
tar xf v${TROJAN_VERSION}.tar.gz && /apk/build-base wget https://github.com/trojan-gfw/trojan/archive/refs/tags/v${TROJAN_VERSION}.tar.gz && tar xf v${TROJAN_VERSION}.tar.gz
WORKDIR ./trojan-${TROJAN_VERSION}/build/ WORKDIR ./trojan-${TROJAN_VERSION}/build/
RUN cmake .. -DENABLE_MYSQL=OFF -DSYSTEMD_SERVICE=OFF && make && \ RUN cmake .. -DENABLE_MYSQL=OFF -DSYSTEMD_SERVICE=OFF && make && mv ./trojan /tmp/ && strip /tmp/trojan
mv ./trojan /tmp/ && \
strip /tmp/trojan
COPY --from=trojan-go /tmp/trojan-go /tmp/ COPY --from=trojan-go /tmp/trojan-go /tmp/
# Compile gost and gost-v3 # Compile gost and gost-v3
FROM ${GO18_IMG} AS gost FROM ${GO19_IMG} AS gost
ENV GOST_VERSION="2.11.2" ENV GOST_VERSION="2.11.3"
ENV GOST_V3_VERSION="3.0.0-beta.4"
RUN apk add git RUN apk add git
RUN git clone https://github.com/go-gost/gost.git ./gost-v3/ && \ RUN wget https://github.com/ginuerzh/gost/archive/refs/tags/v${GOST_VERSION}.tar.gz && tar xf v${GOST_VERSION}.tar.gz && \
wget https://github.com/ginuerzh/gost/archive/refs/tags/v${GOST_VERSION}.tar.gz && \ wget https://github.com/go-gost/gost/archive/refs/tags/v${GOST_V3_VERSION}.tar.gz && tar xf v${GOST_V3_VERSION}.tar.gz
tar xf v${GOST_VERSION}.tar.gz
WORKDIR ./gost-${GOST_VERSION}/ WORKDIR ./gost-${GOST_VERSION}/
RUN go mod download -x RUN go mod download -x
RUN env CGO_ENABLED=0 go build -v -trimpath -ldflags "-s -w" ./cmd/gost && \ RUN env CGO_ENABLED=0 go build -v -trimpath -ldflags "-s -w" ./cmd/gost && mv ./gost /tmp/
mv ./gost /tmp/ WORKDIR ../gost-${GOST_V3_VERSION}/
WORKDIR ../gost-v3/
RUN go mod download -x RUN go mod download -x
RUN env CGO_ENABLED=0 go build -v -trimpath -ldflags "-s -w" ./cmd/gost && \ RUN env CGO_ENABLED=0 go build -v -trimpath -ldflags "-s -w" ./cmd/gost && mv ./gost /tmp/gost-v3
mv ./gost /tmp/gost-v3
COPY --from=upx /upx/ /usr/ COPY --from=upx /upx/ /usr/
RUN ls /tmp/gost* | xargs -P0 -n1 upx -9 RUN ls /tmp/gost* | xargs -P0 -n1 upx -9
# Compile brook # Compile brook
FROM ${GO16_IMG} AS brook FROM ${GO16_IMG} AS brook
ENV BROOK_VERSION="20220707" ENV BROOK_VERSION="20220707"
RUN wget https://github.com/txthinking/brook/archive/refs/tags/v${BROOK_VERSION}.tar.gz && \ RUN wget https://github.com/txthinking/brook/archive/refs/tags/v${BROOK_VERSION}.tar.gz && tar xf v${BROOK_VERSION}.tar.gz
tar xf v${BROOK_VERSION}.tar.gz
WORKDIR ./brook-${BROOK_VERSION}/ WORKDIR ./brook-${BROOK_VERSION}/
RUN go mod download -x RUN go mod download -x
RUN env CGO_ENABLED=0 go build -v -trimpath -ldflags "-s -w" ./cli/brook && \ RUN env CGO_ENABLED=0 go build -v -trimpath -ldflags "-s -w" ./cli/brook && mv ./brook /tmp/
mv ./brook /tmp/
COPY --from=upx /upx/ /usr/ COPY --from=upx /upx/ /usr/
RUN upx -9 /tmp/brook RUN upx -9 /tmp/brook
# Compile clash # Compile clash
FROM ${GO18_IMG} AS clash FROM ${GO19_IMG} AS clash
ENV CLASH_VERSION="1.11.4" ENV CLASH_VERSION="1.11.8"
RUN wget https://github.com/Dreamacro/clash/archive/refs/tags/v${CLASH_VERSION}.tar.gz && \ RUN wget https://github.com/Dreamacro/clash/archive/refs/tags/v${CLASH_VERSION}.tar.gz && tar xf v${CLASH_VERSION}.tar.gz
tar xf v${CLASH_VERSION}.tar.gz
WORKDIR ./clash-${CLASH_VERSION}/ WORKDIR ./clash-${CLASH_VERSION}/
RUN go mod download -x RUN go mod download -x
RUN env CGO_ENABLED=0 go build -v -trimpath -ldflags "-s -w \ RUN env CGO_ENABLED=0 go build -v -trimpath -ldflags "-s -w \
@ -360,7 +349,7 @@ RUN upx -9 /tmp/clash
# Download naiveproxy # Download naiveproxy
FROM ${ALPINE_IMG} AS naive FROM ${ALPINE_IMG} AS naive
ENV NAIVE_VERSION="v104.0.5112.79-2" ENV NAIVE_VERSION="v105.0.5195.52-1"
RUN apk add curl libgcc jq RUN apk add curl libgcc jq
RUN curl -sL https://api.github.com/repos/klzgrad/naiveproxy/releases/tags/${NAIVE_VERSION} \ RUN curl -sL https://api.github.com/repos/klzgrad/naiveproxy/releases/tags/${NAIVE_VERSION} \
| jq .assets | jq .[].name | grep naiveproxy-${NAIVE_VERSION}-openwrt-$(uname -m) \ | jq .assets | jq .[].name | grep naiveproxy-${NAIVE_VERSION}-openwrt-$(uname -m) \
@ -376,8 +365,7 @@ RUN /apk/build-base && strip /tmp/naive
# Compile open-snell # Compile open-snell
FROM ${GO17_IMG} AS snell FROM ${GO17_IMG} AS snell
ENV SNELL_VERSION="3.0.1" ENV SNELL_VERSION="3.0.1"
RUN wget https://github.com/icpz/open-snell/archive/refs/tags/v${SNELL_VERSION}.tar.gz && \ RUN wget https://github.com/icpz/open-snell/archive/refs/tags/v${SNELL_VERSION}.tar.gz && tar xf v${SNELL_VERSION}.tar.gz
tar xf v${SNELL_VERSION}.tar.gz
WORKDIR ./open-snell-${SNELL_VERSION}/ WORKDIR ./open-snell-${SNELL_VERSION}/
RUN go mod download -x RUN go mod download -x
RUN env CGO_ENABLED=0 go build -v -trimpath -ldflags \ RUN env CGO_ENABLED=0 go build -v -trimpath -ldflags \
@ -389,8 +377,8 @@ COPY --from=upx /upx/ /usr/
RUN ls /tmp/snell-* | xargs -P0 -n1 upx -9 RUN ls /tmp/snell-* | xargs -P0 -n1 upx -9
# Compile hysteria # Compile hysteria
FROM ${GO17_IMG} AS hysteria FROM ${GO19_IMG} AS hysteria
ENV HYSTERIA_VERSION="v1.1.0" ENV HYSTERIA_VERSION="v1.2.0"
RUN apk add git RUN apk add git
RUN git clone https://github.com/HyNetwork/hysteria.git RUN git clone https://github.com/HyNetwork/hysteria.git
WORKDIR ./hysteria/ WORKDIR ./hysteria/
@ -407,58 +395,30 @@ RUN upx -9 /tmp/hysteria
FROM ${GO14_IMG} AS relaybaton FROM ${GO14_IMG} AS relaybaton
ENV RELAYBATON_VERSION="0.6.0" ENV RELAYBATON_VERSION="0.6.0"
RUN apk add build-base git perl rsync RUN apk add build-base git perl rsync
RUN wget https://github.com/iyouport-org/relaybaton/archive/refs/tags/v${RELAYBATON_VERSION}.tar.gz && \ RUN wget https://github.com/iyouport-org/relaybaton/archive/refs/tags/v${RELAYBATON_VERSION}.tar.gz && tar xf v${RELAYBATON_VERSION}.tar.gz
tar xf v${RELAYBATON_VERSION}.tar.gz
WORKDIR ./relaybaton-${RELAYBATON_VERSION}/ WORKDIR ./relaybaton-${RELAYBATON_VERSION}/
RUN go mod download -x RUN go mod download -x
RUN make && mv ./bin/relaybaton /tmp/ RUN make && mv ./bin/relaybaton /tmp/
COPY --from=upx /upx/ /usr/ COPY --from=upx /upx/ /usr/
RUN upx -9 /tmp/relaybaton RUN upx -9 /tmp/relaybaton
# Compile pingtunnel
FROM ${GO18_IMG} AS pingtunnel
RUN apk add git
RUN git clone https://github.com/esrrhs/pingtunnel.git
RUN env GO111MODULE=off go get -v github.com/esrrhs/pingtunnel/...
WORKDIR ./pingtunnel/
RUN env GO111MODULE=off CGO_ENABLED=0 go build -v -ldflags="-s -w" && \
mv ./pingtunnel /tmp/
COPY --from=upx /upx/ /usr/
RUN upx -9 /tmp/pingtunnel
# Compile wireproxy
FROM ${GO17_IMG} AS wireproxy
ENV WIREPROXY_VERSION="1.0.3"
RUN wget https://github.com/octeep/wireproxy/archive/refs/tags/v${WIREPROXY_VERSION}.tar.gz && \
tar xf v${WIREPROXY_VERSION}.tar.gz
WORKDIR ./wireproxy-${WIREPROXY_VERSION}/
RUN go mod download -x
RUN env CGO_ENABLED=0 go build -v -trimpath -ldflags "-s -w" ./cmd/wireproxy && \
mv ./wireproxy /tmp/
COPY --from=upx /upx/ /usr/
RUN upx -9 /tmp/wireproxy
# Compile dnsproxy # Compile dnsproxy
FROM ${GO18_IMG} AS dnsproxy FROM ${GO18_IMG} AS dnsproxy
ENV DNSPROXY_VERSION="0.43.1" ENV DNSPROXY_VERSION="0.44.0"
RUN wget https://github.com/AdguardTeam/dnsproxy/archive/refs/tags/v${DNSPROXY_VERSION}.tar.gz && \ RUN wget https://github.com/AdguardTeam/dnsproxy/archive/refs/tags/v${DNSPROXY_VERSION}.tar.gz && tar xf v${DNSPROXY_VERSION}.tar.gz
tar xf v${DNSPROXY_VERSION}.tar.gz
WORKDIR ./dnsproxy-${DNSPROXY_VERSION}/ WORKDIR ./dnsproxy-${DNSPROXY_VERSION}/
RUN go mod download -x RUN go mod download -x
RUN env CGO_ENABLED=0 go build -v -trimpath -ldflags "-X main.VersionString=${DNSPROXY_VERSION} -s -w" && \ RUN env CGO_ENABLED=0 go build -v -trimpath -ldflags "-X main.VersionString=${DNSPROXY_VERSION} -s -w" && mv ./dnsproxy /tmp/
mv ./dnsproxy /tmp/
COPY --from=upx /upx/ /usr/ COPY --from=upx /upx/ /usr/
RUN upx -9 /tmp/dnsproxy RUN upx -9 /tmp/dnsproxy
# Compile mad # Compile mad
FROM ${GO16_IMG} AS mad FROM ${GO16_IMG} AS mad
ENV MAD_VERSION="20210401" ENV MAD_VERSION="20210401"
RUN wget https://github.com/txthinking/mad/archive/refs/tags/v${MAD_VERSION}.tar.gz && \ RUN wget https://github.com/txthinking/mad/archive/refs/tags/v${MAD_VERSION}.tar.gz && tar xf v${MAD_VERSION}.tar.gz
tar xf v${MAD_VERSION}.tar.gz
WORKDIR ./mad-${MAD_VERSION}/ WORKDIR ./mad-${MAD_VERSION}/
RUN go mod download -x RUN go mod download -x
RUN env CGO_ENABLED=0 go build -v -ldflags="-s -w" ./cli/mad && \ RUN env CGO_ENABLED=0 go build -v -ldflags="-s -w" ./cli/mad && mv ./mad /tmp/
mv ./mad /tmp/
COPY --from=upx /upx/ /usr/ COPY --from=upx /upx/ /usr/
RUN upx -9 /tmp/mad RUN upx -9 /tmp/mad
@ -471,7 +431,9 @@ RUN mkdir -p /asset/usr/local/lib/python${PYTHON}/site-packages/ && \
COPY --from=openssl /tmp/libcrypto.so* /asset/lib/ COPY --from=openssl /tmp/libcrypto.so* /asset/lib/
COPY --from=shadowsocks /release/ /asset/usr/bin/ COPY --from=shadowsocks /release/ /asset/usr/bin/
COPY --from=plugin /plugins/ /asset/usr/bin/ COPY --from=plugin /plugins/ /asset/usr/bin/
COPY --from=v2ray /tmp/*ray /asset/usr/bin/ COPY --from=xray /tmp/xray /asset/usr/bin/
COPY --from=v2ray /tmp/v2ray /asset/usr/bin/
COPY --from=sagray /tmp/sagray /asset/usr/bin/
COPY --from=trojan /tmp/trojan* /asset/usr/bin/ COPY --from=trojan /tmp/trojan* /asset/usr/bin/
COPY --from=gost /tmp/gost* /asset/usr/bin/ COPY --from=gost /tmp/gost* /asset/usr/bin/
COPY --from=brook /tmp/brook /asset/usr/bin/ COPY --from=brook /tmp/brook /asset/usr/bin/
@ -480,16 +442,13 @@ COPY --from=naive /tmp/naive /asset/usr/bin/
COPY --from=snell /tmp/snell-* /asset/usr/bin/ COPY --from=snell /tmp/snell-* /asset/usr/bin/
COPY --from=hysteria /tmp/hysteria /asset/usr/bin/ COPY --from=hysteria /tmp/hysteria /asset/usr/bin/
COPY --from=relaybaton /tmp/relaybaton /asset/usr/bin/ COPY --from=relaybaton /tmp/relaybaton /asset/usr/bin/
COPY --from=pingtunnel /tmp/pingtunnel /asset/usr/bin/
COPY --from=wireproxy /tmp/wireproxy /asset/usr/bin/
COPY --from=dnsproxy /tmp/dnsproxy /asset/usr/bin/ COPY --from=dnsproxy /tmp/dnsproxy /asset/usr/bin/
COPY --from=mad /tmp/mad /asset/usr/bin/ COPY --from=mad /tmp/mad /asset/usr/bin/
COPY . /asset/usr/local/share/ProxyC/ COPY . /asset/usr/local/share/ProxyC/
# Release docker image # Release docker image
FROM ${PYTHON_IMG} FROM ${PYTHON_IMG}
RUN apk add --no-cache boost-program_options c-ares \ RUN apk add --no-cache boost-program_options c-ares ca-certificates glib libev libsodium libstdc++ mbedtls pcre && \
ca-certificates glib libev libsodium libstdc++ mbedtls pcre && \
ln -s /usr/local/share/ProxyC/main.py /usr/bin/proxyc ln -s /usr/local/share/ProxyC/main.py /usr/bin/proxyc
COPY --from=asset /asset / COPY --from=asset /asset /
EXPOSE 7839 EXPOSE 7839

Loading…
Cancel
Save