]> git.lizzy.rs Git - rust.git/blob - src/ci/docker/run.sh
Attempt to cache git modules
[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 --env SCCACHE_LOG_LEVEL=debug"
42     args="$args --volume $objdir/tmp:/tmp/sccache"
43 else
44     mkdir -p $HOME/.cache/sccache
45     args="$args --env SCCACHE_DIR=/sccache --volume $HOME/.cache/sccache:/sccache"
46 fi
47
48 exec docker \
49   run \
50   --volume "$root_dir:/checkout:ro" \
51   --volume "$objdir:/checkout/obj" \
52   --workdir /checkout/obj \
53   --env SRC=/checkout \
54   $args \
55   --env CARGO_HOME=/cargo \
56   --env DEPLOY=$DEPLOY \
57   --env DEPLOY_ALT=$DEPLOY_ALT \
58   --env LOCAL_USER_ID=`id -u` \
59   --volume "$HOME/.cargo:/cargo" \
60   --volume "$HOME/rustsrc:$HOME/rustsrc" \
61   --privileged \
62   --rm \
63   rust-ci \
64   /checkout/src/ci/run.sh