ray/ci/travis/build-autoscaler-images.sh
mehrdadn 56d2cf6479
Shellcheck rewrites (#9597)
* Fix SC2001: See if you can use ${variable//search/replace} instead.

* Fix SC2010: Don't use ls | grep. Use a glob or a for loop with a condition to allow non-alphanumeric filenames.

* Fix SC2012: Use find instead of ls to better handle non-alphanumeric filenames.

* Fix SC2015: Note that A && B || C is not if-then-else. C may run when A is true.

* Fix SC2028: echo may not expand escape sequences. Use printf.

* Fix SC2034: variable appears unused. Verify use (or export if used externally).

* Fix SC2035: Use ./*glob* or -- *glob* so names with dashes won't become options.

* Fix SC2071: > is for string comparisons. Use -gt instead.

* Fix SC2154: variable is referenced but not assigned

* Fix SC2164: Use 'cd ... || exit' or 'cd ... || return' in case cd fails.

* Fix SC2188: This redirection doesn't have a command. Move to its command (or use 'true' as no-op).

* Fix SC2236: Use -n instead of ! -z.

* Fix SC2242: Can only exit with status 0-255. Other data should be written to stdout/stderr.

* Fix SC2086: Double quote to prevent globbing and word splitting.

Co-authored-by: Mehrdad <noreply@github.com>
2020-07-24 17:24:19 -05:00

48 lines
1.9 KiB
Bash
Executable file

#!/usr/bin/env bash
# This script build docker images for autoscaler.
# For now, we only build python3.6 images.
set -e
set -x
SCRIPT_DIR=$(cd "$(dirname "${BASH_SOURCE:-$0}")"; pwd)
ROOT_DIR=$(cd "$SCRIPT_DIR"/../../; pwd)
DOCKER_USERNAME="raytravisbot"
# We will only build and push when we are building branch build.
if [[ "$TRAVIS" == "true" && "$TRAVIS_PULL_REQUEST" == "false" ]]; then
echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin
wheel="$(basename "$ROOT_DIR"/.whl/*cp36m-manylinux*)"
commit_sha=$(echo "$TRAVIS_COMMIT" | head -c 6)
cp -r "$ROOT_DIR"/.whl "$ROOT_DIR"/docker/autoscaler/.whl
docker build -q -t rayproject/base-deps docker/base-deps
docker build \
--build-arg WHEEL_PATH=".whl/$wheel" \
--build-arg WHEEL_NAME="$wheel" \
-t rayproject/autoscaler:"$commit_sha" \
"$ROOT_DIR"/docker/autoscaler
docker tag rayproject/base-deps rayproject/base-deps:"$commit_sha"
docker push rayproject/base-deps:"$commit_sha"
docker push rayproject/autoscaler:"$commit_sha"
# We have a branch build, e.g. release/v0.7.0
if [[ "$TRAVIS_BRANCH" != "master" ]]; then
# Replace / in branch name to - so it is legal tag name
normalized_branch_name=$(echo "$TRAVIS_BRANCH" | sed -e "s/\//-/")
docker tag rayproject/autoscaler:"$commit_sha" rayproject/autoscaler:"$normalized_branch_name"
docker tag rayproject/base-deps:"$commit_sha" rayproject/base-deps:"$normalized_branch_name"
docker push rayproject/autoscaler:"$normalized_branch_name"
docker push rayproject/base-deps:"$normalized_branch_name"
else
docker tag rayproject/autoscaler:"$commit_sha" rayproject/autoscaler:latest
docker tag rayproject/base-deps:"$commit_sha" rayproject/base-deps:latest
docker push rayproject/autoscaler:latest
docker push rayproject/base-deps:latest
fi
fi