]> git.lizzy.rs Git - rust.git/blob - src/ci/docker/run.sh
Rollup merge of #40019 - alexcrichton:fix-musl, r=brson
[rust.git] / src / ci / docker / run.sh
1 #!/bin/sh
2 # Copyright 2016 The Rust Project Developers. See the COPYRIGHT
3 # file at the top-level directory of this distribution and at
4 # http://rust-lang.org/COPYRIGHT.
5 #
6 # Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
7 # http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
8 # <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
9 # option. This file may not be copied, modified, or distributed
10 # except according to those terms.
11
12 set -e
13
14 script=`cd $(dirname $0) && pwd`/`basename $0`
15 image=$1
16
17 docker_dir="`dirname $script`"
18 ci_dir="`dirname $docker_dir`"
19 src_dir="`dirname $ci_dir`"
20 root_dir="`dirname $src_dir`"
21
22 docker \
23   build \
24   --rm \
25   -t rust-ci \
26   "`dirname "$script"`/$image"
27
28 objdir=$root_dir/obj
29
30 mkdir -p $HOME/.cargo
31 mkdir -p $objdir
32
33 args=
34 if [ "$SCCACHE_BUCKET" != "" ]; then
35     args="$args --env SCCACHE_BUCKET=$SCCACHE_BUCKET"
36     args="$args --env AWS_ACCESS_KEY_ID=$AWS_ACCESS_KEY_ID"
37     args="$args --env AWS_SECRET_ACCESS_KEY=$AWS_SECRET_ACCESS_KEY"
38 else
39     mkdir -p $HOME/.cache/sccache
40     args="$args --env SCCACHE_DIR=/sccache --volume $HOME/.cache/sccache:/sccache"
41 fi
42
43 exec docker \
44   run \
45   --volume "$root_dir:/checkout:ro" \
46   --volume "$objdir:/checkout/obj" \
47   --workdir /checkout/obj \
48   --env SRC=/checkout \
49   $args \
50   --env CARGO_HOME=/cargo \
51   --env DEPLOY=$DEPLOY \
52   --env DEPLOY_ALT=$DEPLOY_ALT \
53   --env LOCAL_USER_ID=`id -u` \
54   --volume "$HOME/.cargo:/cargo" \
55   --rm \
56   rust-ci \
57   /checkout/src/ci/run.sh