1
- # Use Ubuntu 18.04 LTS as our base image.
2
- FROM ubuntu:18.04
1
+ # syntax=docker/dockerfile:1
2
+
3
+ # Use Ubuntu 20.04 LTS as our base image.
4
+ FROM ubuntu:20.04
3
5
4
6
# The Rust toolchain to use when building our image. Set by `hooks/build`.
5
7
ARG TOOLCHAIN=stable
@@ -10,6 +12,10 @@ ARG TOOLCHAIN=stable
10
12
#
11
13
# ALSO UPDATE hooks/build!
12
14
ARG OPENSSL_VERSION=1.1.1m
15
+ # Needs evaluation;
16
+ # fails for libpq with:
17
+ # "configure: error: library 'crypto' is required for OpenSSL"
18
+ # ARG OPENSSL_VERSION=3.0.0
13
19
14
20
# Versions for other dependencies. Here are the places to check for new
15
21
# releases:
@@ -38,8 +44,8 @@ ARG POSTGRESQL_VERSION=11.14
38
44
#
39
45
# We also set up a `rust` user by default. This user has sudo privileges if you
40
46
# need to install any more software.
41
- RUN apt-get update && \
42
- export DEBIAN_FRONTEND=noninteractive && \
47
+ RUN export DEBIAN_FRONTEND=noninteractive && \
48
+ apt-get update && \
43
49
apt-get install -yq \
44
50
build-essential \
45
51
cmake \
@@ -61,32 +67,6 @@ RUN apt-get update && \
61
67
apt-get clean && rm -rf /var/lib/apt/lists/* && \
62
68
useradd rust --user-group --create-home --shell /bin/bash --groups sudo
63
69
64
- # - `mdbook` is the standard Rust tool for making searchable HTML manuals.
65
- # - `mdbook-graphviz` allows using inline GraphViz drawing commands to add illustrations.
66
- # - `cargo-about` generates a giant license file for all dependencies.
67
- # - `cargo-audit` checks for security vulnerabilities. We include it for backwards compat.
68
- # - `cargo-deny` does everything `cargo-audit` does, plus check licenses & many other things.
69
- RUN curl -fLO https://github.com/rust-lang-nursery/mdBook/releases/download/v$MDBOOK_VERSION/mdbook-v$MDBOOK_VERSION-x86_64-unknown-linux-gnu.tar.gz && \
70
- tar xf mdbook-v$MDBOOK_VERSION-x86_64-unknown-linux-gnu.tar.gz && \
71
- mv mdbook /usr/local/bin/ && \
72
- rm -f mdbook-v$MDBOOK_VERSION-x86_64-unknown-linux-gnu.tar.gz && \
73
- curl -fLO https://github.com/dylanowen/mdbook-graphviz/releases/download/v$MDBOOK_GRAPHVIZ_VERSION/mdbook-graphviz_v${MDBOOK_GRAPHVIZ_VERSION}_x86_64-unknown-linux-musl.zip && \
74
- unzip mdbook-graphviz_v${MDBOOK_GRAPHVIZ_VERSION}_x86_64-unknown-linux-musl.zip && \
75
- mv mdbook-graphviz /usr/local/bin/ && \
76
- rm -f mdbook-graphviz_v${MDBOOK_GRAPHVIZ_VERSION}_x86_64-unknown-linux-musl.zip && \
77
- curl -fLO https://github.com/EmbarkStudios/cargo-about/releases/download/$CARGO_ABOUT_VERSION/cargo-about-$CARGO_ABOUT_VERSION-x86_64-unknown-linux-musl.tar.gz && \
78
- tar xf cargo-about-$CARGO_ABOUT_VERSION-x86_64-unknown-linux-musl.tar.gz && \
79
- mv cargo-about-$CARGO_ABOUT_VERSION-x86_64-unknown-linux-musl/cargo-about /usr/local/bin/ && \
80
- rm -rf cargo-about-$CARGO_ABOUT_VERSION-x86_64-unknown-linux-musl.tar.gz cargo-about-$CARGO_ABOUT_VERSION-x86_64-unknown-linux-musl && \
81
- curl -fLO https://github.com/rustsec/rustsec/releases/download/cargo-audit%2Fv${CARGO_AUDIT_VERSION}/cargo-audit-x86_64-unknown-linux-gnu-v${CARGO_AUDIT_VERSION}.tgz && \
82
- tar xf cargo-audit-x86_64-unknown-linux-gnu-v${CARGO_AUDIT_VERSION}.tgz && \
83
- cp cargo-audit-x86_64-unknown-linux-gnu-v${CARGO_AUDIT_VERSION}/cargo-audit /usr/local/bin/ && \
84
- rm -rf cargo-audit-x86_64-unknown-linux-gnu-v${CARGO_AUDIT_VERSION}.tgz cargo-audit-x86_64-unknown-linux-gnu-v${CARGO_AUDIT_VERSION} && \
85
- curl -fLO https://github.com/EmbarkStudios/cargo-deny/releases/download/$CARGO_DENY_VERSION/cargo-deny-$CARGO_DENY_VERSION-x86_64-unknown-linux-musl.tar.gz && \
86
- tar xf cargo-deny-$CARGO_DENY_VERSION-x86_64-unknown-linux-musl.tar.gz && \
87
- mv cargo-deny-$CARGO_DENY_VERSION-x86_64-unknown-linux-musl/cargo-deny /usr/local/bin/ && \
88
- rm -rf cargo-deny-$CARGO_DENY_VERSION-x86_64-unknown-linux-musl cargo-deny-$CARGO_DENY_VERSION-x86_64-unknown-linux-musl.tar.gz
89
-
90
70
# Static linking for C++ code
91
71
RUN ln -s "/usr/bin/g++" "/usr/bin/musl-g++"
92
72
@@ -97,36 +77,36 @@ RUN ln -s "/usr/bin/g++" "/usr/bin/musl-g++"
97
77
# necessarily the right ones) in an effort to compile OpenSSL 1.1's "engine"
98
78
# component. It's possible that this will cause bizarre and terrible things to
99
79
# happen. There may be "sanitized" header
100
- RUN echo "Building OpenSSL" && \
80
+ RUN echo "Building OpenSSL ${OPENSSL_VERSION} " && \
101
81
ls /usr/include/linux && \
102
82
mkdir -p /usr/local/musl/include && \
103
83
ln -s /usr/include/linux /usr/local/musl/include/linux && \
104
84
ln -s /usr/include/x86_64-linux-gnu/asm /usr/local/musl/include/asm && \
105
85
ln -s /usr/include/asm-generic /usr/local/musl/include/asm-generic && \
106
86
cd /tmp && \
107
- short_version="$(echo " $OPENSSL_VERSION" | sed s'/[a-z]$//' )" && \
108
- curl -fLO "https://www.openssl.org/source/openssl-$OPENSSL_VERSION.tar.gz" || \
87
+ short_version="$(echo " ${ OPENSSL_VERSION} " | sed s'/[a-z]$//' )" && \
88
+ curl -fLO "https://www.openssl.org/source/openssl-${ OPENSSL_VERSION} .tar.gz" || \
109
89
curl -fLO "https://www.openssl.org/source/old/$short_version/openssl-$OPENSSL_VERSION.tar.gz" && \
110
- tar xvzf "openssl-$OPENSSL_VERSION.tar.gz" && cd "openssl-$OPENSSL_VERSION" && \
90
+ tar xvzf "openssl-${ OPENSSL_VERSION} .tar.gz" && cd "openssl-${ OPENSSL_VERSION} " && \
111
91
env CC=musl-gcc ./Configure no-shared no-zlib -fPIC --prefix=/usr/local/musl -DOPENSSL_NO_SECURE_MEMORY linux-x86_64 && \
112
92
env C_INCLUDE_PATH=/usr/local/musl/include/ make depend && \
113
93
env C_INCLUDE_PATH=/usr/local/musl/include/ make && \
114
94
make install && \
115
95
rm /usr/local/musl/include/linux /usr/local/musl/include/asm /usr/local/musl/include/asm-generic && \
116
96
rm -r /tmp/*
117
97
118
- RUN echo "Building zlib" && \
98
+ RUN echo "Building zlib ${ZLIB_VERSION} " && \
119
99
cd /tmp && \
120
- curl -fLO "http://zlib.net/zlib-$ZLIB_VERSION.tar.gz" && \
121
- tar xzf "zlib-$ZLIB_VERSION.tar.gz" && cd "zlib-$ZLIB_VERSION" && \
100
+ curl -fLO "http://zlib.net/zlib-${ ZLIB_VERSION} .tar.gz" && \
101
+ tar xzf "zlib-${ ZLIB_VERSION} .tar.gz" && cd "zlib-${ ZLIB_VERSION} " && \
122
102
CC=musl-gcc ./configure --static --prefix=/usr/local/musl && \
123
103
make && make install && \
124
104
rm -r /tmp/*
125
105
126
- RUN echo "Building libpq" && \
106
+ RUN echo "Building libpq ${POSTGRESQL_VERSION} " && \
127
107
cd /tmp && \
128
- curl -fLO "https://ftp.postgresql.org/pub/source/v$POSTGRESQL_VERSION/postgresql-$POSTGRESQL_VERSION.tar.gz" && \
129
- tar xzf "postgresql-$POSTGRESQL_VERSION.tar.gz" && cd "postgresql-$POSTGRESQL_VERSION" && \
108
+ curl -fLO "https://ftp.postgresql.org/pub/source/v${ POSTGRESQL_VERSION} /postgresql-${ POSTGRESQL_VERSION} .tar.gz" && \
109
+ tar xzf "postgresql-${ POSTGRESQL_VERSION} .tar.gz" && cd "postgresql-${ POSTGRESQL_VERSION} " && \
130
110
CC=musl-gcc CPPFLAGS=-I/usr/local/musl/include LDFLAGS=-L/usr/local/musl/lib ./configure --with-openssl --without-readline --prefix=/usr/local/musl && \
131
111
cd src/interfaces/libpq && make all-static-lib && make install-lib-static && \
132
112
cd ../../bin/pg_config && make && make install && \
@@ -139,7 +119,7 @@ RUN echo "Building libpq" && \
139
119
# Install a `git credentials` helper for using GH_USER and GH_TOKEN to access
140
120
# private repositories if desired. We make sure this is configured for root,
141
121
# here, and for the `rust` user below.
142
- ADD git-credential-ghtoken /usr/local/bin/ghtoken
122
+ COPY git-credential-ghtoken /usr/local/bin/ghtoken
143
123
RUN git config --global credential.https://github.com.helper ghtoken
144
124
145
125
# Set up our path with all our binary directories, including those for the
@@ -155,16 +135,23 @@ ENV RUSTUP_HOME=/opt/rust/rustup \
155
135
# interact with the user or fool around with TTYs. We also set the default
156
136
# `--target` to musl so that our users don't need to keep overriding it
157
137
# manually.
158
- RUN curl https://sh.rustup.rs -sSf | \
138
+ RUN echo "Installing Rust (${TOOLCHAIN} toolchain)" && \
139
+ curl https://sh.rustup.rs -sSf | \
159
140
env CARGO_HOME=/opt/rust/cargo \
160
- sh -s -- -y --default-toolchain $TOOLCHAIN --profile minimal --no-modify-path && \
141
+ sh -s -- -y --default-toolchain ${ TOOLCHAIN} --profile minimal --no-modify-path && \
161
142
env CARGO_HOME=/opt/rust/cargo \
162
143
rustup component add rustfmt && \
163
144
env CARGO_HOME=/opt/rust/cargo \
164
145
rustup component add clippy && \
165
146
env CARGO_HOME=/opt/rust/cargo \
166
147
rustup target add x86_64-unknown-linux-musl
167
- ADD cargo-config.toml /opt/rust/cargo/config
148
+ # if we also install other target's build dependencies (like tools, libs, and linkers)
149
+ # rustup target add x86_64-unknown-linux-musl \
150
+ # rustup target add aarch64-unknown-linux-musl \
151
+ # rustup target add armv7-unknown-linux-musleabihf \
152
+ # rustup target add armv7-unknown-linux-musleabi
153
+
154
+ COPY cargo-config.toml /opt/rust/cargo/config
168
155
169
156
# Set up our environment variables so that we cross-compile using musl-libc by
170
157
# default.
@@ -181,12 +168,38 @@ ENV X86_64_UNKNOWN_LINUX_MUSL_OPENSSL_DIR=/usr/local/musl/ \
181
168
# slow down image builds). This will use the static linking toolchain, but that
182
169
# should be OK.
183
170
#
184
- # - `cargo-deb` builds Debian packages.
185
- RUN env CARGO_HOME=/opt/rust/cargo cargo install -f cargo-deb && \
186
- rm -rf /opt/rust/cargo/registry/
171
+ # - `cargo-deb` is a helper command which automatically creates binary Debian packages (.deb) from Cargo projects.
172
+ # - `mdbook` is the standard Rust tool for making searchable HTML manuals.
173
+ # - `mdbook-graphviz` allows using inline GraphViz drawing commands to add illustrations.
174
+ # - `cargo-about` generates a giant license file for all dependencies.
175
+ # - `cargo-audit` checks for security vulnerabilities. We include it for backwards compat.
176
+ # - `cargo-deny` does everything `cargo-audit` does, plus check licenses & many other things.
177
+ RUN echo "Installing cargo tools" && \
178
+ env CARGO_HOME=/opt/rust/cargo cargo install -f cargo-deb && \
179
+ rm -rf /opt/rust/cargo/registry/ && \
180
+ curl -fLO https://github.com/rust-lang-nursery/mdBook/releases/download/v${MDBOOK_VERSION}/mdbook-v${MDBOOK_VERSION}-x86_64-unknown-linux-gnu.tar.gz && \
181
+ tar xf mdbook-v${MDBOOK_VERSION}-x86_64-unknown-linux-gnu.tar.gz && \
182
+ mv mdbook /usr/local/bin/ && \
183
+ rm -f mdbook-v${MDBOOK_VERSION}-x86_64-unknown-linux-gnu.tar.gz && \
184
+ curl -fLO https://github.com/dylanowen/mdbook-graphviz/releases/download/v${MDBOOK_GRAPHVIZ_VERSION}/mdbook-graphviz_v${MDBOOK_GRAPHVIZ_VERSION}_x86_64-unknown-linux-musl.zip && \
185
+ unzip mdbook-graphviz_v${MDBOOK_GRAPHVIZ_VERSION}_x86_64-unknown-linux-musl.zip && \
186
+ mv mdbook-graphviz /usr/local/bin/ && \
187
+ rm -f mdbook-graphviz_v${MDBOOK_GRAPHVIZ_VERSION}_x86_64-unknown-linux-musl.zip && \
188
+ curl -fLO https://github.com/EmbarkStudios/cargo-about/releases/download/${CARGO_ABOUT_VERSION}/cargo-about-${CARGO_ABOUT_VERSION}-x86_64-unknown-linux-musl.tar.gz && \
189
+ tar xf cargo-about-${CARGO_ABOUT_VERSION}-x86_64-unknown-linux-musl.tar.gz && \
190
+ mv cargo-about-${CARGO_ABOUT_VERSION}-x86_64-unknown-linux-musl/cargo-about /usr/local/bin/ && \
191
+ rm -rf cargo-about-${CARGO_ABOUT_VERSION}-x86_64-unknown-linux-musl.tar.gz cargo-about-${CARGO_ABOUT_VERSION}-x86_64-unknown-linux-musl && \
192
+ curl -fLO https://github.com/rustsec/rustsec/releases/download/cargo-audit%2Fv${CARGO_AUDIT_VERSION}/cargo-audit-x86_64-unknown-linux-gnu-v${CARGO_AUDIT_VERSION}.tgz && \
193
+ tar xf cargo-audit-x86_64-unknown-linux-gnu-v${CARGO_AUDIT_VERSION}.tgz && \
194
+ cp cargo-audit-x86_64-unknown-linux-gnu-v${CARGO_AUDIT_VERSION}/cargo-audit /usr/local/bin/ && \
195
+ rm -rf cargo-audit-x86_64-unknown-linux-gnu-v${CARGO_AUDIT_VERSION}.tgz cargo-audit-x86_64-unknown-linux-gnu-v${CARGO_AUDIT_VERSION} && \
196
+ curl -fLO https://github.com/EmbarkStudios/cargo-deny/releases/download/${CARGO_DENY_VERSION}/cargo-deny-${CARGO_DENY_VERSION}-x86_64-unknown-linux-musl.tar.gz && \
197
+ tar xf cargo-deny-${CARGO_DENY_VERSION}-x86_64-unknown-linux-musl.tar.gz && \
198
+ mv cargo-deny-${CARGO_DENY_VERSION}-x86_64-unknown-linux-musl/cargo-deny /usr/local/bin/ && \
199
+ rm -rf cargo-deny-${CARGO_DENY_VERSION}-x86_64-unknown-linux-musl cargo-deny-${CARGO_DENY_VERSION}-x86_64-unknown-linux-musl.tar.gz
187
200
188
201
# Allow sudo without a password.
189
- ADD sudoers /etc/sudoers.d/nopasswd
202
+ COPY sudoers /etc/sudoers.d/nopasswd
190
203
191
204
# Run all further code as user `rust`, create our working directories, install
192
205
# our config file, and set up our credential helper.
0 commit comments