Use DOCKER_TAG to pick correct toolchain

This commit is contained in:
Eric Kidd 2016-11-25 07:45:10 -05:00
parent 67f9e0c858
commit a61815dd1a
2 changed files with 21 additions and 3 deletions

View file

@ -2,6 +2,9 @@
# https://github.com/rust-lang/rust/issues/34978 (as of Rust 1.11). # https://github.com/rust-lang/rust/issues/34978 (as of Rust 1.11).
FROM ubuntu:16.04 FROM ubuntu:16.04
# The Rust toolchain to use when building our image. Set by `hooks/build`.
ARG TOOLCHAIN=stable
# Make sure we have basic dev tools for building C libraries. Our goal # Make sure we have basic dev tools for building C libraries. Our goal
# here is to support the musl-libc builds and Cargo builds needed for a # here is to support the musl-libc builds and Cargo builds needed for a
# large selection of the most popular crates. # large selection of the most popular crates.
@ -40,9 +43,10 @@ ENV PATH=/home/rust/.cargo/bin:/usr/local/musl/bin:/usr/local/bin:/usr/bin:/bin
# interact with the user or fool around with TTYs. We also set the default # interact with the user or fool around with TTYs. We also set the default
# `--target` to musl so that our users don't need to keep overriding it # `--target` to musl so that our users don't need to keep overriding it
# manually. # manually.
RUN curl https://sh.rustup.rs -sSf | sh -s -- -y && \ RUN curl https://sh.rustup.rs -sSf |
rustup default stable && \ sh -s -- -y \
rustup target add x86_64-unknown-linux-musl --default-toolchain $TOOLCHAIN \
--default-target x86_64-unknown-linux-musl
ADD cargo-config.toml /home/rust/.cargo/config ADD cargo-config.toml /home/rust/.cargo/config
# We'll build our libraries in subdirectories of /home/rust/libs. Please # We'll build our libraries in subdirectories of /home/rust/libs. Please

14
hooks/build Executable file
View file

@ -0,0 +1,14 @@
#!/bin/sh
# Abort if anything goes wrong.
set -euo pipefail
# Always map the Docker tag `latest` to stable Rust.
if [ "$DOCKER_TAG" == "latest" ]; then
TOOLCHAIN=stable
else
TOOLCHAIN="$DOCKER_TAG"
fi
# Run the build.
docker build --build-arg TOOLCHAIN="$TOOLCHAIN" -t "$IMAGE_NAME" .