diff --git a/Dockerfile b/Dockerfile index 4cebd36..d181016 100644 --- a/Dockerfile +++ b/Dockerfile @@ -54,18 +54,39 @@ WORKDIR /home/rust/libs # Build a static library version of OpenSSL using musl-libc. This is # needed by the popular Rust `hyper` crate. -RUN VERS=1.0.2l && \ +RUN echo "Building OpenSSL" && \ + VERS=1.0.2l && \ curl -O https://www.openssl.org/source/openssl-$VERS.tar.gz && \ tar xvzf openssl-$VERS.tar.gz && cd openssl-$VERS && \ env CC=musl-gcc ./config --prefix=/usr/local/musl && \ env C_INCLUDE_PATH=/usr/local/musl/include/ make depend && \ make && sudo make install && \ - cd .. && rm -rf openssl-$VERS.tar.gz openssl-$VERS + cd .. && rm -rf openssl-$VERS.tar.gz openssl-$VERS && \ + echo "Building zlib" && \ + VERS=1.2.11 && \ + cd /home/rust/libs && \ + curl -LO http://zlib.net/zlib-$VERS.tar.gz && \ + tar xzf zlib-$VERS.tar.gz && cd zlib-$VERS && \ + CC=musl-gcc ./configure --static --prefix=/usr/local/musl && \ + make && sudo make install && \ + cd .. && rm -rf zlib-$VERS.tar.gz zlib-$VERS && \ + echo "Building libpq" && \ + VERS=9.6.5 && \ + curl -o postgres.tar.gz https://ftp.postgresql.org/pub/source/v$VERS/postgresql-$VERS.tar.gz && \ + tar xzf postgres.tar.gz && \ + cd postgresql-$VERS && \ + CC=musl-gcc CPPFLAGS=-I/usr/local/musl/include LDFLAGS=-L/usr/local/musl/lib ./configure --with-openssl --without-readline --prefix=/usr/local/musl && \ + cd src/interfaces/libpq && \ + make all-static-lib && sudo make install-lib-static && \ + cd ../../../.. && rm -rf postgres.tar.gz postgresql-$VERS + ENV OPENSSL_DIR=/usr/local/musl/ \ OPENSSL_INCLUDE_DIR=/usr/local/musl/include/ \ DEP_OPENSSL_INCLUDE=/usr/local/musl/include/ \ OPENSSL_LIB_DIR=/usr/local/musl/lib/ \ - OPENSSL_STATIC=1 + OPENSSL_STATIC=1 \ + PQ_LIB_DIR=/usr/local/musl/lib \ + PQ_LIB_STATIC=1 # (Please feel free to submit pull requests for musl-libc builds of other C # libraries needed by the most popular and common Rust crates, to avoid diff --git a/Dockerfile.example b/Dockerfile.example index b299596..5f1d8b8 100644 --- a/Dockerfile.example +++ b/Dockerfile.example @@ -6,6 +6,8 @@ FROM ekidd/rust-musl-builder # Build a static copy of zlib. +# +# EXAMPLE ONLY! libz is already included. RUN VERS=1.2.11 && \ cd /home/rust/libs && \ curl -LO http://zlib.net/zlib-$VERS.tar.gz && \ diff --git a/README.md b/README.md index 53058b7..be836f7 100644 --- a/README.md +++ b/README.md @@ -32,6 +32,10 @@ libraries: - The standard `musl-libc` libraries. - OpenSSL, which is needed by many Rust applications. +- `libpq`, which is needed for applications that use `diesel` with PostgreSQL. +- `libz`, which is needed by `libpq`. + +This library also sets up the environment variables needed to compile popular Rust crates using these libraries. ## Making OpenSSL work @@ -55,7 +59,8 @@ installed, you can create a Dockerfile based on this one, and use ```Dockerfile FROM ekidd/rust-musl-builder -RUN VERS=1.2.8 && \ +# EXAMPLE ONLY! libz is already included. +RUN VERS=1.2.11 && \ cd /home/rust/libs && \ curl -LO http://zlib.net/zlib-$VERS.tar.gz && \ tar xzf zlib-$VERS.tar.gz && cd zlib-$VERS && \ @@ -111,27 +116,17 @@ build new Linux binaries using `rust-musl-builder`, and new Mac binaries with Cargo, and it will upload both to the GitHub releases page for your repository. -For a working example, see [faradayio/conductor][conductor]. +For a working example, see [faradayio/cage][cage]. [rust-cross]: https://github.com/japaric/rust-cross [uploading]: https://docs.travis-ci.com/user/deployment/releases -[conductor]: https://github.com/faradayio/conductor +[cage]: https://github.com/faradayio/cage ## Development notes After modifying the image, run `./test-image` to make sure that everything works. -MAINTAINERS ONLY: After making changes, they must be pushed to the `stable` -branch to build the official `stable` and `latest` images on Docker Hub. -Tagged versions of Rust (such as `1.11`) must be given their own branches -and manually configured on Docker Hub. - -```sh -git push origin master:stable -git push origin master:rust-$(rustc --version | awk '{ print $2 }') -``` - ## License Either the [Apache 2.0 license](./LICENSE-APACHE.txt), or the