]> git.lizzy.rs Git - rust.git/blob - src/ci/docker/run.sh
Rollup merge of #41249 - GuillaumeGomez:rustdoc-render, r=steveklabnik,frewsxcv
[rust.git] / src / ci / docker / run.sh
1 #!/bin/bash
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 source "$ci_dir/shared.sh"
23
24 retry docker \
25   build \
26   --rm \
27   -t rust-ci \
28   "`dirname "$script"`/$image"
29
30 objdir=$root_dir/obj
31
32 mkdir -p $HOME/.cargo
33 mkdir -p $objdir/tmp
34
35 args=
36 if [ "$SCCACHE_BUCKET" != "" ]; then
37     args="$args --env SCCACHE_BUCKET=$SCCACHE_BUCKET"
38     args="$args --env AWS_ACCESS_KEY_ID=$AWS_ACCESS_KEY_ID"
39     args="$args --env AWS_SECRET_ACCESS_KEY=$AWS_SECRET_ACCESS_KEY"
40     args="$args --env SCCACHE_ERROR_LOG=/tmp/sccache/sccache.log"
41     args="$args --volume $objdir/tmp:/tmp/sccache"
42 else
43     mkdir -p $HOME/.cache/sccache
44     args="$args --env SCCACHE_DIR=/sccache --volume $HOME/.cache/sccache:/sccache"
45 fi
46
47 exec docker \
48   run \
49   --volume "$root_dir:/checkout:ro" \
50   --volume "$objdir:/checkout/obj" \
51   --workdir /checkout/obj \
52   --env SRC=/checkout \
53   $args \
54   --env CARGO_HOME=/cargo \
55   --env DEPLOY=$DEPLOY \
56   --env DEPLOY_ALT=$DEPLOY_ALT \
57   --env LOCAL_USER_ID=`id -u` \
58   --volume "$HOME/.cargo:/cargo" \
59   --volume "$HOME/rustsrc:$HOME/rustsrc" \
60   --privileged \
61   --rm \
62   rust-ci \
63   /checkout/src/ci/run.sh