-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
59 lines (49 loc) · 2.01 KB
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
FROM rust:1.71-alpine3.18 AS builder
LABEL maintainer="WavE Docker Maintainers <[email protected]>"
ENV COMMIT_ID="0b62554e1de3bdc2afc3ffe98ca679680523bee0"
RUN set -x \
&& apk add --no-cache build-base git \
&& mkdir /src \
&& cd /src \
&& git clone https://github.com/shadowsocks/shadowsocks-rust.git \
&& apkArch="$(apk --print-arch)" \
&& case "$apkArch" in \
"x86") \
RUST_TARGET="i686-unknown-linux-musl" \
MUSL="i686-linux-musl" \
;; \
"x86_64") \
RUST_TARGET="x86_64-unknown-linux-musl" \
MUSL="x86_64-linux-musl" \
;; \
"aarch64") \
RUST_TARGET="aarch64-unknown-linux-musl" \
MUSL="aarch64-linux-musl" \
;; \
*) \
echo "ERROR: Doesn't support $apkArch architecture!" \
exit 1 \
;; \
esac \
&& wget -qO- "https://musl.cc/$MUSL-cross.tgz" | tar -xzC /src/ \
&& CC=/src/$MUSL-cross/bin/$MUSL-gcc \
&& cd shadowsocks-rust \
&& git reset --hard ${COMMIT_ID} \
&& rustup target add $RUST_TARGET \
&& RUSTFLAGS="-C linker=$CC" \
&& CC=$CC \
&& cargo build --target "$RUST_TARGET" --release --features "local-tun local-redir stream-cipher aead-cipher-2022" \
&& mv target/$RUST_TARGET/release/ss* target/release/
FROM alpine:3.18 AS ssserver
COPY --from=builder /src/shadowsocks-rust/target/release/sslocal /usr/local/bin/
COPY --from=builder /src/shadowsocks-rust/target/release/ssserver /usr/local/bin/
COPY --from=builder /src/shadowsocks-rust/target/release/ssmanager /usr/local/bin/
COPY --from=builder /src/shadowsocks-rust/target/release/ssservice /usr/local/bin/
COPY --from=builder /src/shadowsocks-rust/examples/config.json /etc/shadowsocks-rust/
COPY docker-entrypoint.sh /usr/local/bin/
RUN set -x \
&& apk add --no-cache iproute2-ss
ENTRYPOINT ["docker-entrypoint.sh"]
EXPOSE 8388
STOPSIGNAL SIGINT
CMD ["ssserver", "--log-without-time", "-a", "nobody", "-c", "/etc/shadowsocks-rust/config.json"]