From a61815dd1a6848637854169ee45f851b7996c92c Mon Sep 17 00:00:00 2001 From: Eric Kidd Date: Fri, 25 Nov 2016 07:45:10 -0500 Subject: [PATCH] Use DOCKER_TAG to pick correct toolchain --- Dockerfile | 10 +++++++--- hooks/build | 14 ++++++++++++++ 2 files changed, 21 insertions(+), 3 deletions(-) create mode 100755 hooks/build diff --git a/Dockerfile b/Dockerfile index 2612436..f193ef0 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,6 +2,9 @@ # https://github.com/rust-lang/rust/issues/34978 (as of Rust 1.11). 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 # here is to support the musl-libc builds and Cargo builds needed for a # 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 # `--target` to musl so that our users don't need to keep overriding it # manually. -RUN curl https://sh.rustup.rs -sSf | sh -s -- -y && \ - rustup default stable && \ - rustup target add x86_64-unknown-linux-musl +RUN curl https://sh.rustup.rs -sSf | + sh -s -- -y \ + --default-toolchain $TOOLCHAIN \ + --default-target x86_64-unknown-linux-musl ADD cargo-config.toml /home/rust/.cargo/config # We'll build our libraries in subdirectories of /home/rust/libs. Please diff --git a/hooks/build b/hooks/build new file mode 100755 index 0000000..bbdbc1a --- /dev/null +++ b/hooks/build @@ -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" .