Skip to content

Commit 0083434

Browse files
committed
Combine the compiler Dockerfiles and use the Docker registry
1 parent 6debe11 commit 0083434

File tree

7 files changed

+61
-69
lines changed

7 files changed

+61
-69
lines changed

compiler/base/Dockerfile

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,24 @@ RUN curl https://sh.rustup.rs -sSf | sh -s -- -y && rustup toolchain uninstall
1717
ADD Cargo.toml /root/Cargo.toml
1818
ADD entrypoint.sh /root/
1919
ADD fix-modification-time.sh /root/
20+
21+
# Now that we have set up our basic environment, let's set up the
22+
# specific channel.
23+
24+
ARG channel
25+
ARG date
26+
RUN rustup default "${channel}-${date}"
27+
28+
RUN cd / && \
29+
cargo new playground
30+
31+
WORKDIR /playground
32+
33+
RUN mv /root/Cargo.toml ./Cargo.toml && \
34+
cargo build && \
35+
cargo build --release
36+
37+
RUN find . -name '*.json' -print0 | xargs -0 -n1 /root/fix-modification-time.sh
38+
RUN rm src/*.rs
39+
40+
ENTRYPOINT ["/root/entrypoint.sh"]

compiler/beta/Dockerfile

Lines changed: 0 additions & 18 deletions
This file was deleted.

compiler/build.sh

Lines changed: 38 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,62 @@
11
#!/bin/bash
22

3-
set -eu -o pipefail
3+
set -euv -o pipefail
44

5-
cd base
6-
docker build -t 'rust-base' .
7-
cd ..
5+
channels_to_build="${CHANNELS_TO_BUILD-stable beta nightly}"
6+
tools_to_build="${TOOLS_TO_BUILD-rustfmt clippy}"
7+
perform_push="${PERFORM_PUSH-false}"
88

9-
date_url_base=https://static.rust-lang.org/dist
9+
repository=shepmaster
1010

11-
for channel in stable beta nightly; do
12-
filename="channel-rust-${channel}-date.txt"
11+
date_url_base=https://static.rust-lang.org/dist
1312

14-
cd "$channel"
13+
for channel in $channels_to_build; do
14+
cd "base"
1515

16+
filename="channel-rust-${channel}-date.txt"
1617
curl -o "${filename}" "${date_url_base}/${filename}"
1718
date=$(cat "${filename}")
1819

19-
docker build -t "rust-${channel}" --build-arg date="${date}" .
20+
image_name="rust-${channel}"
21+
full_name="${repository}/${image_name}"
22+
23+
docker pull "${full_name}"
24+
docker build -t "${full_name}" \
25+
--cache-from "${full_name}" \
26+
--build-arg channel="${channel}" \
27+
--build-arg date="${date}" \
28+
.
29+
docker tag "${full_name}" "${image_name}"
30+
31+
if [[ "${perform_push}" == 'true' ]]; then
32+
docker push "${full_name}"
33+
fi
2034

2135
cd ..
2236
done
2337

2438
crate_api_base=https://crates.io/api/v1/crates
2539

26-
for tool in rustfmt clippy; do
27-
filename="version-${tool}.txt"
28-
40+
for tool in $tools_to_build; do
2941
cd "${tool}"
3042

43+
filename="version-${tool}.txt"
3144
curl -o "${filename}" "${crate_api_base}/${tool}"
3245
version=$(jq -r '.crate.max_version' "${filename}")
3346

34-
docker build -t "${tool}" --build-arg version="${version}" .
47+
image_name="${tool}"
48+
full_name="${repository}/${image_name}"
49+
50+
docker pull "${full_name}"
51+
docker build -t "${full_name}" \
52+
--cache-from "${full_name}" \
53+
--build-arg version="${version}" \
54+
.
55+
docker tag "${full_name}" "${image_name}"
56+
57+
if [[ "${perform_push}" == 'true' ]]; then
58+
docker push "${full_name}"
59+
fi
3560

3661
cd ..
3762
done

compiler/clippy/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM rust-nightly
1+
FROM shepmaster/rust-nightly
22

33
ARG version
44

compiler/nightly/Dockerfile

Lines changed: 0 additions & 18 deletions
This file was deleted.

compiler/rustfmt/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM rust-stable
1+
FROM shepmaster/rust-stable
22

33
ARG version
44

compiler/stable/Dockerfile

Lines changed: 0 additions & 18 deletions
This file was deleted.

0 commit comments

Comments
 (0)