Skip to content

Commit 4e14797

Browse files
committed
feat: update openssl to v1.1.1 (LTS)
deprecated v1.0.2 according to https://www.openssl.org/policies/releasestrat.html
1 parent 92f12b0 commit 4e14797

File tree

2 files changed

+59
-44
lines changed

2 files changed

+59
-44
lines changed

README.md

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@
22

33
> Use same Docker image for compiling [Rust](https://www.rust-lang.org/) programs for Linux ([musl libc](https://doc.rust-lang.org/edition-guide/rust-2018/platform-and-target-support/musl-support-for-fully-static-binaries.html)) & macOS ([osxcross](https://github.com/tpoechtrager/osxcross)).
44
5+
## OpenSSL Release Notes
6+
7+
Until `v1.42.0` of this project, one old OpenSSL release `v1.0.2` was used.
8+
Now, since `v1.43.x` or greater, OpenSSL `v1.1.1` (LTS) is used which is supported until `2023-09-11`. View more at https://www.openssl.org/policies/releasestrat.html.
9+
510
## Overview
611

712
This is a __Linux Docker image__ based on [ekidd/rust-musl-builder](https://hub.docker.com/r/ekidd/rust-musl-builder) but using [debian:buster-slim](https://hub.docker.com/_/debian?tab=tags&page=1&name=buster-slim). It contains essential tools for compile [Rust](https://www.rust-lang.org/) projects such as __Linux__ static binaries via [musl-libc / musl-gcc](https://doc.rust-lang.org/edition-guide/rust-2018/platform-and-target-support/musl-support-for-fully-static-binaries.html) (`x86_64-unknown-linux-musl`) and __macOS__ binaries (`x86_64-apple-darwin`) via [osxcross](https://github.com/tpoechtrager/osxcross) just using the same Linux image.
@@ -18,7 +23,7 @@ By default the working directory is `/root/src`.
1823
docker run --rm \
1924
--volume "${PWD}/sample":/root/src \
2025
--workdir /root/src \
21-
joseluisq/rust-linux-darwin-builder:1.42.0 \
26+
joseluisq/rust-linux-darwin-builder:1.43.0 \
2227
sh -c "cargo build --release"
2328
```
2429

@@ -28,7 +33,7 @@ docker run --rm \
2833
docker run --rm \
2934
--volume "${PWD}/sample":/root/src \
3035
--workdir /root/src \
31-
joseluisq/rust-linux-darwin-builder:1.42.0 \
36+
joseluisq/rust-linux-darwin-builder:1.43.0 \
3237
sh -c "cargo build --release --target x86_64-apple-darwin"
3338
```
3439

@@ -37,7 +42,7 @@ docker run --rm \
3742
You can also use the image as a base for your own Dockerfile:
3843

3944
```Dockerfile
40-
FROM joseluisq/rust-linux-darwin-builder:1.42.0
45+
FROM joseluisq/rust-linux-darwin-builder:1.43.0
4146
```
4247

4348
### Cross-compilation example
@@ -56,7 +61,7 @@ compile:
5661
@docker run --rm -it \
5762
-v $(PWD):/drone/src \
5863
-w /drone/src \
59-
joseluisq/rust-linux-darwin-builder:1.42.0 \
64+
joseluisq/rust-linux-darwin-builder:1.43.0 \
6065
make cross-compile
6166
.PHONY: compile
6267

@@ -81,12 +86,12 @@ Just run the makefile `compile` target, then you will see two release binaries `
8186
make compile
8287
# 1. Cross compiling example...
8388

84-
# rustc 1.42.0 (b8cedc004 2020-03-09)
89+
# rustc 1.43.0 (b8cedc004 2020-03-09)
8590
# binary: rustc
8691
# commit-hash: b8cedc00407a4c56a3bda1ed605c6fc166655447
8792
# commit-date: 2020-03-09
8893
# host: x86_64-unknown-linux-gnu
89-
# release: 1.42.0
94+
# release: 1.43.0
9095
# LLVM version: 9.0
9196

9297
# 2. Compiling application (linux-musl x86_64)...

docker/tmpl.Dockerfile

Lines changed: 48 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,16 @@
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

4-
FROM debian:$DEBIAN_TAG
4+
FROM debian:buster-slim
55

66
LABEL maintainer="Jose Quintana <git.io/joseluisq>"
77

88
# The Rust toolchain to use when building our image. Set by `hooks/build`.
99
ARG 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+
# OpenSSL v1.1.1
12+
# File: openssl-1.1.1g.tar.gz (2020-Apr-21 13:01:56)
13+
ARG OPENSSL_VERSION=1.1.1
1514

1615
# Make sure we have basic dev tools for building C libraries. Our goal
1716
# here is to support the musl-libc builds and Cargo builds needed for a
@@ -47,35 +46,38 @@ RUN set -eux \
4746
zlib1g-dev \
4847
# Clean up local repository of retrieved packages and remove the package lists
4948
&& apt-get clean \
50-
&& rm -rf /var/lib/apt/lists/*
49+
&& rm -rf /var/lib/apt/lists/* \
50+
&& true
5151

5252
# Static linking for C++ code
5353
RUN set -eux \
5454
&& ln -s "/usr/bin/g++" "/usr/bin/musl-g++" \
5555
# Create appropriate directories for current user
56-
&& mkdir -p /root/libs /root/src
56+
&& mkdir -p /root/libs /root/src \
57+
&& true
5758

5859
# Set up our path with all our binary directories, including those for the
5960
# musl-gcc toolchain and for our Rust toolchain.
6061
ENV PATH=/root/.cargo/bin:/usr/local/musl/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
6162

62-
# Install our Rust toolchain and the `musl` target. We patch the
63+
# Install our Rust toolchain and the `musl` target. We patch the
6364
# 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.
65+
# interact with the user or fool around with TTYs. We also set the default
66+
# `--target` to musl so that our users don't need to keep overriding it manually.
6767
RUN set -eux \
6868
&& curl https://sh.rustup.rs -sSf | sh -s -- -y --default-toolchain $TOOLCHAIN \
6969
&& rustup target add x86_64-unknown-linux-musl \
7070
&& rustup target add armv7-unknown-linux-musleabihf \
71-
&& rustup target add x86_64-apple-darwin
71+
&& rustup target add x86_64-apple-darwin \
72+
&& true
7273
ADD docker/cargo-config.toml /root/.cargo/config
7374

7475
# Set up a `git credentials` helper for using GH_USER and GH_TOKEN to access
7576
# private repositories if desired.
7677
ADD docker/git-credential-ghtoken /usr/local/bin
7778
RUN set -eux \
78-
&& git config --global credential.https://github.com.helper ghtoken
79+
&& git config --global credential.https://github.com.helper ghtoken \
80+
&& true
7981

8082
# Build a static library version of OpenSSL using musl-libc. This is needed by
8183
# the popular Rust `hyper` crate.
@@ -87,47 +89,51 @@ RUN set -eux \
8789
RUN set -eux \
8890
&& echo "Building OpenSSL..." \
8991
&& 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 \
92+
&& mkdir -p /usr/local/musl/include \
93+
&& ln -s /usr/include/linux /usr/local/musl/include/linux \
94+
&& ln -s /usr/include/x86_64-linux-gnu/asm /usr/local/musl/include/asm \
95+
&& ln -s /usr/include/asm-generic /usr/local/musl/include/asm-generic \
9496
&& 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" \
97+
&& curl -LO "https://www.openssl.org/source/openssl-${OPENSSL_VERSION}g.tar.gz" \
98+
&& tar xvzf "openssl-${OPENSSL_VERSION}g.tar.gz" && cd "openssl-${OPENSSL_VERSION}g" \
9799
&& env CC=musl-gcc ./Configure no-shared no-zlib -fPIC --prefix=/usr/local/musl -DOPENSSL_NO_SECURE_MEMORY linux-x86_64 \
98100
&& env C_INCLUDE_PATH=/usr/local/musl/include/ make depend \
99101
&& 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/*
102+
&& make install \
103+
&& rm /usr/local/musl/include/linux /usr/local/musl/include/asm /usr/local/musl/include/asm-generic \
104+
&& openssl version \
105+
&& rm -r /tmp/* \
106+
&& true
103107

104108
RUN set -eux \
105109
&& echo "Building zlib..." \
106110
&& cd /tmp \
107-
&& ZLIB_VERSION=1.2.11 \
111+
&& env ZLIB_VERSION=1.2.11 \
108112
&& curl -LO "http://zlib.net/zlib-$ZLIB_VERSION.tar.gz" \
109113
&& tar xzf "zlib-$ZLIB_VERSION.tar.gz" \
110114
&& cd "zlib-$ZLIB_VERSION" \
111-
&& CC=musl-gcc ./configure --static --prefix=/usr/local/musl \
115+
&& env CC=musl-gcc ./configure --static --prefix=/usr/local/musl \
112116
&& make \
113-
&& sudo make install \
114-
&& rm -r /tmp/*
117+
&& make install \
118+
&& rm -r /tmp/* \
119+
&& true
115120

116121
RUN set -eux \
117122
&& echo "Building libpq..." \
118123
&& cd /tmp \
119-
&& POSTGRESQL_VERSION=11.2 \
124+
&& env POSTGRESQL_VERSION=11.2 \
120125
&& curl -LO "https://ftp.postgresql.org/pub/source/v$POSTGRESQL_VERSION/postgresql-$POSTGRESQL_VERSION.tar.gz" \
121126
&& tar xzf "postgresql-$POSTGRESQL_VERSION.tar.gz" \
122127
&& 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 \
128+
&& 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 \
124129
&& cd src/interfaces/libpq \
125130
&& make all-static-lib \
126-
&& sudo make install-lib-static \
131+
&& make install-lib-static \
127132
&& cd ../../bin/pg_config \
128133
&& make \
129-
&& sudo make install \
130-
&& rm -r /tmp/*
134+
&& make install \
135+
&& rm -r /tmp/* \
136+
&& true
131137

132138
ENV OPENSSL_DIR=/usr/local/musl/ \
133139
OPENSSL_INCLUDE_DIR=/usr/local/musl/include/ \
@@ -145,22 +151,26 @@ ENV OPENSSL_DIR=/usr/local/musl/ \
145151
# libraries needed by the most popular and common Rust crates, to avoid
146152
# everybody needing to build them manually.)
147153

148-
ENV OSXCROSS_SDK_VERSION 10.11
154+
155+
# Install OS X Cross
156+
# A Mac OS X cross toolchain for Linux, FreeBSD, OpenBSD and Android
157+
158+
ENV MACOSX_SDK_VERSION 10.11
149159

150160
RUN set -eux \
151161
&& echo "Building osxcross..." \
152162
&& cd /usr/local/ \
153163
&& git clone --depth 1 https://github.com/tpoechtrager/osxcross \
154164
&& 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 \
165+
&& curl -L -o ./tarballs/MacOSX${MACOSX_SDK_VERSION}.sdk.tar.xz \
166+
https://s3.amazonaws.com/andrew-osx-sdks/MacOSX${MACOSX_SDK_VERSION}.sdk.tar.xz \
157167
&& env UNATTENDED=yes OSX_VERSION_MIN=10.7 ./build.sh \
158168
&& rm -rf *~ taballs *.tar.xz \
159-
&& rm -rf /tmp/*
169+
&& rm -rf /tmp/* \
170+
&& true
160171

161172
ENV PATH $PATH:/usr/local/osxcross/target/bin
162173

163-
# Expect our source code to live in /root/src
164174
WORKDIR /root/src
165175

166176
CMD ["bash"]

0 commit comments

Comments
 (0)