1- # NOTE: Most of Dockerfile and related files were borrowed from
2- # https://hub.docker.com/r/joseluisq /rust-linux-darwin -builder
1+ # NOTE: Most of Dockerfile and related were borrowed from
2+ # https://hub.docker.com/r/ekidd /rust-musl -builder
33
44FROM debian:buster-slim
55
@@ -8,10 +8,21 @@ LABEL maintainer="Jose Quintana <git.io/joseluisq>"
88# The Rust toolchain to use when building our image. Set by `hooks/build`.
99ARG TOOLCHAIN=stable
1010
11- # The OpenSSL version to use. We parameterize this because many Rust
12- # projects will fail to build with 1.1.
13- # File: openssl-1.0.2u.tar.gz (2019-Dec-20 13:25:43)
14- ARG OPENSSL_VERSION=1.0.2
11+
12+ # Dependencies
13+
14+ # OpenSSL v1.1.1
15+ ARG OPENSSL_VERSION=1.1.1g
16+
17+ # zlib - http://zlib.net/
18+ ARG ZLIB_VERSION=1.2.11
19+
20+ # libpq - https://ftp.postgresql.org/pub/source/
21+ ARG POSTGRESQL_VERSION=11.7
22+
23+ # Mac OS X SDK version for OS X Cross
24+ ARG MACOSX_SDK_VERSION=10.11
25+
1526
1627# Make sure we have basic dev tools for building C libraries. Our goal
1728# here is to support the musl-libc builds and Cargo builds needed for a
@@ -47,35 +58,38 @@ RUN set -eux \
4758 zlib1g-dev \
4859# Clean up local repository of retrieved packages and remove the package lists
4960 && apt-get clean \
50- && rm -rf /var/lib/apt/lists/*
61+ && rm -rf /var/lib/apt/lists/* \
62+ && true
5163
5264# Static linking for C++ code
5365RUN set -eux \
5466 && ln -s "/usr/bin/g++" "/usr/bin/musl-g++" \
5567# Create appropriate directories for current user
56- && mkdir -p /root/libs /root/src
68+ && mkdir -p /root/libs /root/src \
69+ && true
5770
5871# Set up our path with all our binary directories, including those for the
5972# musl-gcc toolchain and for our Rust toolchain.
6073ENV PATH=/root/.cargo/bin:/usr/local/musl/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
6174
62- # Install our Rust toolchain and the `musl` target. We patch the
75+ # Install our Rust toolchain and the `musl` target. We patch the
6376# command-line we pass to the installer so that it won't attempt to
64- # interact with the user or fool around with TTYs. We also set the default
65- # `--target` to musl so that our users don't need to keep overriding it
66- # manually.
77+ # interact with the user or fool around with TTYs. We also set the default
78+ # `--target` to musl so that our users don't need to keep overriding it manually.
6779RUN set -eux \
6880 && curl https://sh.rustup.rs -sSf | sh -s -- -y --default-toolchain $TOOLCHAIN \
6981 && rustup target add x86_64-unknown-linux-musl \
7082 && rustup target add armv7-unknown-linux-musleabihf \
71- && rustup target add x86_64-apple-darwin
83+ && rustup target add x86_64-apple-darwin \
84+ && true
7285ADD docker/cargo-config.toml /root/.cargo/config
7386
7487# Set up a `git credentials` helper for using GH_USER and GH_TOKEN to access
7588# private repositories if desired.
7689ADD docker/git-credential-ghtoken /usr/local/bin
7790RUN set -eux \
78- && git config --global credential.https://github.com.helper ghtoken
91+ && git config --global credential.https://github.com.helper ghtoken \
92+ && true
7993
8094# Build a static library version of OpenSSL using musl-libc. This is needed by
8195# the popular Rust `hyper` crate.
@@ -87,47 +101,50 @@ RUN set -eux \
87101RUN set -eux \
88102 && echo "Building OpenSSL..." \
89103 && ls /usr/include/linux \
90- && sudo mkdir -p /usr/local/musl/include \
91- && sudo ln -s /usr/include/linux /usr/local/musl/include/linux \
92- && sudo ln -s /usr/include/x86_64-linux-gnu/asm /usr/local/musl/include/asm \
93- && sudo ln -s /usr/include/asm-generic /usr/local/musl/include/asm-generic \
104+ && mkdir -p /usr/local/musl/include \
105+ && ln -s /usr/include/linux /usr/local/musl/include/linux \
106+ && ln -s /usr/include/x86_64-linux-gnu/asm /usr/local/musl/include/asm \
107+ && ln -s /usr/include/asm-generic /usr/local/musl/include/asm-generic \
94108 && cd /tmp \
95- && curl -LO "https://www.openssl.org/source/old/${OPENSSL_VERSION}/openssl-${OPENSSL_VERSION}u.tar.gz" \
96- && tar xvzf "openssl-${OPENSSL_VERSION}u.tar.gz" && cd "openssl-${OPENSSL_VERSION}u" \
109+ && curl -LO "https://www.openssl.org/source/openssl-$OPENSSL_VERSION.tar.gz" \
110+ && tar xvzf "openssl-$OPENSSL_VERSION.tar.gz" \
111+ && cd "openssl-$OPENSSL_VERSION" \
97112 && env CC=musl-gcc ./Configure no-shared no-zlib -fPIC --prefix=/usr/local/musl -DOPENSSL_NO_SECURE_MEMORY linux-x86_64 \
98113 && env C_INCLUDE_PATH=/usr/local/musl/include/ make depend \
99114 && env C_INCLUDE_PATH=/usr/local/musl/include/ make \
100- && sudo make install \
101- && sudo rm /usr/local/musl/include/linux /usr/local/musl/include/asm /usr/local/musl/include/asm-generic \
102- && rm -r /tmp/*
115+ && make install \
116+ && rm /usr/local/musl/include/linux /usr/local/musl/include/asm /usr/local/musl/include/asm-generic \
117+ && openssl version \
118+ && rm -r /tmp/* \
119+ && true
103120
104121RUN set -eux \
105122 && echo "Building zlib..." \
106123 && cd /tmp \
107- && ZLIB_VERSION=1.2.11 \
108124 && curl -LO "http://zlib.net/zlib-$ZLIB_VERSION.tar.gz" \
109125 && tar xzf "zlib-$ZLIB_VERSION.tar.gz" \
110126 && cd "zlib-$ZLIB_VERSION" \
111- && CC=musl-gcc ./configure --static --prefix=/usr/local/musl \
127+ && env CC=musl-gcc ./configure --static --prefix=/usr/local/musl \
112128 && make \
113- && sudo make install \
114- && rm -r /tmp/*
129+ && make install \
130+ && rm -r /tmp/* \
131+ && true
115132
116133RUN set -eux \
117134 && echo "Building libpq..." \
118135 && cd /tmp \
119- && POSTGRESQL_VERSION=11.2 \
120136 && curl -LO "https://ftp.postgresql.org/pub/source/v$POSTGRESQL_VERSION/postgresql-$POSTGRESQL_VERSION.tar.gz" \
121137 && tar xzf "postgresql-$POSTGRESQL_VERSION.tar.gz" \
122138 && cd "postgresql-$POSTGRESQL_VERSION" \
123- && CC=musl-gcc CPPFLAGS=-I/usr/local/musl/include LDFLAGS=-L/usr/local/musl/lib ./configure --with-openssl --without-readline --prefix=/usr/local/musl \
139+ && env CC=musl-gcc CPPFLAGS=-I/usr/local/musl/include LDFLAGS=-L/usr/local/musl/lib ./configure --with-openssl --without-readline --prefix=/usr/local/musl \
124140 && cd src/interfaces/libpq \
125141 && make all-static-lib \
126- && sudo make install-lib-static \
142+ && make install-lib-static \
127143 && cd ../../bin/pg_config \
128144 && make \
129- && sudo make install \
130- && rm -r /tmp/*
145+ && make install \
146+ && rm -r /tmp/* \
147+ && true
131148
132149ENV OPENSSL_DIR=/usr/local/musl/ \
133150 OPENSSL_INCLUDE_DIR=/usr/local/musl/include/ \
@@ -145,22 +162,24 @@ ENV OPENSSL_DIR=/usr/local/musl/ \
145162# libraries needed by the most popular and common Rust crates, to avoid
146163# everybody needing to build them manually.)
147164
148- ENV OSXCROSS_SDK_VERSION 10.11
165+
166+ # Install OS X Cross
167+ # A Mac OS X cross toolchain for Linux, FreeBSD, OpenBSD and Android
149168
150169RUN set -eux \
151170 && echo "Building osxcross..." \
152171 && cd /usr/local/ \
153172 && git clone --depth 1 https://github.com/tpoechtrager/osxcross \
154173 && cd osxcross \
155- && curl -L -o ./tarballs/MacOSX${OSXCROSS_SDK_VERSION} .sdk.tar.xz \
156- https://s3.amazonaws.com/andrew-osx-sdks/MacOSX${OSXCROSS_SDK_VERSION} .sdk.tar.xz \
174+ && curl -L -o " ./tarballs/MacOSX$MACOSX_SDK_VERSION .sdk.tar.xz" \
175+ " https://s3.amazonaws.com/andrew-osx-sdks/MacOSX$MACOSX_SDK_VERSION .sdk.tar.xz" \
157176 && env UNATTENDED=yes OSX_VERSION_MIN=10.7 ./build.sh \
158177 && rm -rf *~ taballs *.tar.xz \
159- && rm -rf /tmp/*
178+ && rm -rf /tmp/* \
179+ && true
160180
161181ENV PATH $PATH:/usr/local/osxcross/target/bin
162182
163- # Expect our source code to live in /root/src
164183WORKDIR /root/src
165184
166185CMD ["bash" ]
@@ -170,5 +189,5 @@ LABEL org.opencontainers.image.vendor="Jose Quintana" \
170189 org.opencontainers.image.url="https://github.com/joseluisq/rust-linux-darwin-builder" \
171190 org.opencontainers.image.title="Rust Linux / Darwin Builder" \
172191 org.opencontainers.image.description="Use same Docker image for compiling Rust programs for Linux (musl libc) & macOS (osxcross)." \
173- org.opencontainers.image.version="v1.42 .0" \
192+ org.opencontainers.image.version="v1.43 .0" \
174193 org.opencontainers.image.documentation="https://github.com/joseluisq/rust-linux-darwin-builder"
0 commit comments