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
3
3
4
4
FROM debian:buster-slim
5
5
@@ -8,10 +8,21 @@ LABEL maintainer="Jose Quintana <git.io/joseluisq>"
8
8
# The Rust toolchain to use when building our image. Set by `hooks/build`.
9
9
ARG TOOLCHAIN=stable
10
10
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
+
15
26
16
27
# Make sure we have basic dev tools for building C libraries. Our goal
17
28
# here is to support the musl-libc builds and Cargo builds needed for a
@@ -47,35 +58,38 @@ RUN set -eux \
47
58
zlib1g-dev \
48
59
# Clean up local repository of retrieved packages and remove the package lists
49
60
&& apt-get clean \
50
- && rm -rf /var/lib/apt/lists/*
61
+ && rm -rf /var/lib/apt/lists/* \
62
+ && true
51
63
52
64
# Static linking for C++ code
53
65
RUN set -eux \
54
66
&& ln -s "/usr/bin/g++" "/usr/bin/musl-g++" \
55
67
# Create appropriate directories for current user
56
- && mkdir -p /root/libs /root/src
68
+ && mkdir -p /root/libs /root/src \
69
+ && true
57
70
58
71
# Set up our path with all our binary directories, including those for the
59
72
# musl-gcc toolchain and for our Rust toolchain.
60
73
ENV PATH=/root/.cargo/bin:/usr/local/musl/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
61
74
62
- # Install our Rust toolchain and the `musl` target. We patch the
75
+ # Install our Rust toolchain and the `musl` target. We patch the
63
76
# 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.
67
79
RUN set -eux \
68
80
&& curl https://sh.rustup.rs -sSf | sh -s -- -y --default-toolchain $TOOLCHAIN \
69
81
&& rustup target add x86_64-unknown-linux-musl \
70
82
&& 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
72
85
ADD docker/cargo-config.toml /root/.cargo/config
73
86
74
87
# Set up a `git credentials` helper for using GH_USER and GH_TOKEN to access
75
88
# private repositories if desired.
76
89
ADD docker/git-credential-ghtoken /usr/local/bin
77
90
RUN set -eux \
78
- && git config --global credential.https://github.com.helper ghtoken
91
+ && git config --global credential.https://github.com.helper ghtoken \
92
+ && true
79
93
80
94
# Build a static library version of OpenSSL using musl-libc. This is needed by
81
95
# the popular Rust `hyper` crate.
@@ -87,47 +101,50 @@ RUN set -eux \
87
101
RUN set -eux \
88
102
&& echo "Building OpenSSL..." \
89
103
&& 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 \
94
108
&& 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" \
97
112
&& env CC=musl-gcc ./Configure no-shared no-zlib -fPIC --prefix=/usr/local/musl -DOPENSSL_NO_SECURE_MEMORY linux-x86_64 \
98
113
&& env C_INCLUDE_PATH=/usr/local/musl/include/ make depend \
99
114
&& 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
103
120
104
121
RUN set -eux \
105
122
&& echo "Building zlib..." \
106
123
&& cd /tmp \
107
- && ZLIB_VERSION=1.2.11 \
108
124
&& curl -LO "http://zlib.net/zlib-$ZLIB_VERSION.tar.gz" \
109
125
&& tar xzf "zlib-$ZLIB_VERSION.tar.gz" \
110
126
&& 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 \
112
128
&& make \
113
- && sudo make install \
114
- && rm -r /tmp/*
129
+ && make install \
130
+ && rm -r /tmp/* \
131
+ && true
115
132
116
133
RUN set -eux \
117
134
&& echo "Building libpq..." \
118
135
&& cd /tmp \
119
- && POSTGRESQL_VERSION=11.2 \
120
136
&& curl -LO "https://ftp.postgresql.org/pub/source/v$POSTGRESQL_VERSION/postgresql-$POSTGRESQL_VERSION.tar.gz" \
121
137
&& tar xzf "postgresql-$POSTGRESQL_VERSION.tar.gz" \
122
138
&& 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 \
124
140
&& cd src/interfaces/libpq \
125
141
&& make all-static-lib \
126
- && sudo make install-lib-static \
142
+ && make install-lib-static \
127
143
&& cd ../../bin/pg_config \
128
144
&& make \
129
- && sudo make install \
130
- && rm -r /tmp/*
145
+ && make install \
146
+ && rm -r /tmp/* \
147
+ && true
131
148
132
149
ENV OPENSSL_DIR=/usr/local/musl/ \
133
150
OPENSSL_INCLUDE_DIR=/usr/local/musl/include/ \
@@ -145,22 +162,24 @@ ENV OPENSSL_DIR=/usr/local/musl/ \
145
162
# libraries needed by the most popular and common Rust crates, to avoid
146
163
# everybody needing to build them manually.)
147
164
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
149
168
150
169
RUN set -eux \
151
170
&& echo "Building osxcross..." \
152
171
&& cd /usr/local/ \
153
172
&& git clone --depth 1 https://github.com/tpoechtrager/osxcross \
154
173
&& 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" \
157
176
&& env UNATTENDED=yes OSX_VERSION_MIN=10.7 ./build.sh \
158
177
&& rm -rf *~ taballs *.tar.xz \
159
- && rm -rf /tmp/*
178
+ && rm -rf /tmp/* \
179
+ && true
160
180
161
181
ENV PATH $PATH:/usr/local/osxcross/target/bin
162
182
163
- # Expect our source code to live in /root/src
164
183
WORKDIR /root/src
165
184
166
185
CMD ["bash" ]
@@ -170,5 +189,5 @@ LABEL org.opencontainers.image.vendor="Jose Quintana" \
170
189
org.opencontainers.image.url="https://github.com/joseluisq/rust-linux-darwin-builder" \
171
190
org.opencontainers.image.title="Rust Linux / Darwin Builder" \
172
191
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" \
174
193
org.opencontainers.image.documentation="https://github.com/joseluisq/rust-linux-darwin-builder"
0 commit comments