2016-08-01 16:44:11 -07:00
|
|
|
#!/bin/bash
|
|
|
|
|
2017-02-28 18:57:51 -08:00
|
|
|
while [[ $# -gt 0 ]]
|
|
|
|
do
|
|
|
|
key="$1"
|
|
|
|
case $key in
|
|
|
|
--no-cache)
|
|
|
|
NO_CACHE="--no-cache"
|
|
|
|
;;
|
|
|
|
--skip-examples)
|
|
|
|
SKIP_EXAMPLES=YES
|
|
|
|
;;
|
2017-03-18 23:44:54 -07:00
|
|
|
--output-sha)
|
|
|
|
# output the SHA sum of the last built file (either ray-project/deploy
|
|
|
|
# or ray-project/examples, suppressing all other output. This is useful
|
|
|
|
# for scripting tests, especially when builds of different versions
|
|
|
|
# are running on the same machine. It also can facilitate cleanup.
|
|
|
|
OUTPUT_SHA=YES
|
|
|
|
;;
|
2017-02-28 18:57:51 -08:00
|
|
|
*)
|
2017-03-18 23:44:54 -07:00
|
|
|
echo "Usage: build-docker.sh [ --no-cache ] [ --skip-examples ] [ --sha-sums ]"
|
2017-02-28 18:57:51 -08:00
|
|
|
exit 1
|
|
|
|
esac
|
|
|
|
shift
|
|
|
|
done
|
2016-12-31 17:21:33 -08:00
|
|
|
|
2017-02-28 18:57:51 -08:00
|
|
|
# Build base dependencies, allow caching
|
2017-03-18 23:44:54 -07:00
|
|
|
if [ $OUTPUT_SHA ]; then
|
|
|
|
IMAGE_SHA=$(docker build $NO_CACHE -q -t ray-project/base-deps docker/base-deps)
|
|
|
|
else
|
|
|
|
docker build $NO_CACHE -t ray-project/base-deps docker/base-deps
|
|
|
|
fi
|
2017-02-28 18:57:51 -08:00
|
|
|
|
|
|
|
# Build the current Ray source
|
|
|
|
git rev-parse HEAD > ./docker/deploy/git-rev
|
|
|
|
git archive -o ./docker/deploy/ray.tar $(git rev-parse HEAD)
|
2017-03-18 23:44:54 -07:00
|
|
|
if [ $OUTPUT_SHA ]; then
|
|
|
|
IMAGE_SHA=$(docker build --no-cache -q -t ray-project/deploy docker/deploy)
|
|
|
|
else
|
|
|
|
docker build --no-cache -t ray-project/deploy docker/deploy
|
|
|
|
fi
|
2017-02-28 18:57:51 -08:00
|
|
|
rm ./docker/deploy/ray.tar ./docker/deploy/git-rev
|
|
|
|
|
2017-03-18 23:44:54 -07:00
|
|
|
# Build the examples, unless skipped
|
2017-02-28 18:57:51 -08:00
|
|
|
if [ ! $SKIP_EXAMPLES ]; then
|
2017-03-18 23:44:54 -07:00
|
|
|
if [ $OUTPUT_SHA ]; then
|
|
|
|
IMAGE_SHA=$(docker build $NO_CACHE -q -t ray-project/examples docker/examples)
|
2017-05-06 18:57:08 -07:00
|
|
|
else
|
|
|
|
docker build --no-cache -t ray-project/examples docker/examples
|
2017-03-18 23:44:54 -07:00
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ $OUTPUT_SHA ]; then
|
|
|
|
echo $IMAGE_SHA | sed 's/sha256://'
|
2017-02-28 18:57:51 -08:00
|
|
|
fi
|