Skip to content

Commit

Permalink
Combine the compiler Dockerfiles and use the Docker registry
Browse files Browse the repository at this point in the history
  • Loading branch information
shepmaster committed May 13, 2017
1 parent 6debe11 commit 0083434
Show file tree
Hide file tree
Showing 7 changed files with 61 additions and 69 deletions.
21 changes: 21 additions & 0 deletions compiler/base/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,24 @@ RUN curl https://sh.rustup.rs -sSf | sh -s -- -y && rustup toolchain uninstall
ADD Cargo.toml /root/Cargo.toml
ADD entrypoint.sh /root/
ADD fix-modification-time.sh /root/

# Now that we have set up our basic environment, let's set up the
# specific channel.

ARG channel
ARG date
RUN rustup default "${channel}-${date}"

RUN cd / && \
cargo new playground

WORKDIR /playground

RUN mv /root/Cargo.toml ./Cargo.toml && \
cargo build && \
cargo build --release

RUN find . -name '*.json' -print0 | xargs -0 -n1 /root/fix-modification-time.sh
RUN rm src/*.rs

ENTRYPOINT ["/root/entrypoint.sh"]
18 changes: 0 additions & 18 deletions compiler/beta/Dockerfile

This file was deleted.

51 changes: 38 additions & 13 deletions compiler/build.sh
Original file line number Diff line number Diff line change
@@ -1,37 +1,62 @@
#!/bin/bash

set -eu -o pipefail
set -euv -o pipefail

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

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

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

cd "$channel"
for channel in $channels_to_build; do
cd "base"

filename="channel-rust-${channel}-date.txt"
curl -o "${filename}" "${date_url_base}/${filename}"
date=$(cat "${filename}")

docker build -t "rust-${channel}" --build-arg date="${date}" .
image_name="rust-${channel}"
full_name="${repository}/${image_name}"

docker pull "${full_name}"
docker build -t "${full_name}" \
--cache-from "${full_name}" \

This comment has been minimized.

Copy link
@dwrensha

dwrensha May 18, 2017

FYI, --cache-from is new in docker 1.13 (moby/moby#26839), so this flag breaks the build in a stock AMI environment, which currently has only docker 1.12.

This comment has been minimized.

Copy link
@shepmaster

shepmaster May 18, 2017

Author Member

Hmm. My plan is to move building of the containers off of the frontends themselves. Instead, I've got the fetch.sh script to just download the built containers from the Docker Hub.

It is still annoying for people who might want to be doing something special...

Feel free to open an issue if fetch.sh doesn't work as a useful replacement.

--build-arg channel="${channel}" \
--build-arg date="${date}" \
.
docker tag "${full_name}" "${image_name}"

if [[ "${perform_push}" == 'true' ]]; then
docker push "${full_name}"
fi

cd ..
done

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

for tool in rustfmt clippy; do
filename="version-${tool}.txt"

for tool in $tools_to_build; do
cd "${tool}"

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

docker build -t "${tool}" --build-arg version="${version}" .
image_name="${tool}"
full_name="${repository}/${image_name}"

docker pull "${full_name}"
docker build -t "${full_name}" \
--cache-from "${full_name}" \
--build-arg version="${version}" \
.
docker tag "${full_name}" "${image_name}"

if [[ "${perform_push}" == 'true' ]]; then
docker push "${full_name}"
fi

cd ..
done
2 changes: 1 addition & 1 deletion compiler/clippy/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM rust-nightly
FROM shepmaster/rust-nightly

ARG version

Expand Down
18 changes: 0 additions & 18 deletions compiler/nightly/Dockerfile

This file was deleted.

2 changes: 1 addition & 1 deletion compiler/rustfmt/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM rust-stable
FROM shepmaster/rust-stable

ARG version

Expand Down
18 changes: 0 additions & 18 deletions compiler/stable/Dockerfile

This file was deleted.

0 comments on commit 0083434

Please sign in to comment.