diff --git a/build/Dockerfile b/build/Dockerfile new file mode 100644 index 00000000..647f0095 --- /dev/null +++ b/build/Dockerfile @@ -0,0 +1,13 @@ +FROM ekidd/rust-musl-builder + +# Build a static copy of libsodium. +RUN VERS=1.0.13 && \ + cd /home/rust/libs && \ + curl -LO https://download.libsodium.org/libsodium/releases/libsodium-$VERS.tar.gz && \ + tar xzf libsodium-$VERS.tar.gz && cd libsodium-$VERS && \ + CC=musl-gcc ./configure --prefix=/usr/local/musl && \ + make && sudo make install && \ + cd .. && rm -rf libsodium-$VERS.tar.gz libsodium-$VERS + +ENV SODIUM_STATIC=yes +ENV SODIUM_LIB_DIR=/usr/local/musl/lib diff --git a/build/README.md b/build/README.md new file mode 100644 index 00000000..936df429 --- /dev/null +++ b/build/README.md @@ -0,0 +1,11 @@ +Compile static-linked binaries with [`rust-musl-builder`](https://github.com/emk/rust-musl-builder): + +```sh +# build image use Dockerfile in build dir. +docker build -t shadowsocks_rust:0.0.1 . +# run command in project root. +alias rust-musl-builder='docker run --rm -it -v "$(pwd)":/home/rust/src shadowsocks_rust:0.0.1' +rust-musl-builder cargo build --release +``` + +At the moment, it doesn't attempt to cache libraries between builds, so this is best reserved for making final release builds. \ No newline at end of file