Skip to content

Commit

Permalink
Create a new parameter --cache-from in tvm/docker/build.sh, so that w…
Browse files Browse the repository at this point in the history
…e can point to an image to be used as cache, from an external (#5173)

script.

 * Adjusts documentation to provide information about new optional
   parameter "--cache-from"
 * Includes --cache-from in the underlying "docker build" command
   triggered by build.sh, when required
  • Loading branch information
leandron authored Mar 30, 2020
1 parent bf13225 commit 079e184
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions docker/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
# Execute command within a docker container
#
# Usage: build.sh <CONTAINER_TYPE> [--dockerfile <DOCKERFILE_PATH>] [-it]
# <COMMAND>
# [--net=host] [--cache-from <IMAGE_NAME>] <COMMAND>
#
# CONTAINER_TYPE: Type of the docker container used the run the build: e.g.,
# (cpu | gpu)
Expand All @@ -30,6 +30,9 @@
# this optional value is not supplied (via the --dockerfile
# flag), will use Dockerfile.CONTAINER_TYPE in default
#
# IMAGE_NAME: An image to be as a source for cached layers when building the
# Docker image requested.
#
# COMMAND: Command to be executed in the docker container
#
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
Expand Down Expand Up @@ -60,6 +63,13 @@ if [[ "$1" == "--net=host" ]]; then
shift 1
fi

if [[ "$1" == "--cache-from" ]]; then
shift 1
cached_image="$1"
CI_DOCKER_BUILD_EXTRA_PARAMS+=("--cache-from $cached_image")
shift 1
fi

if [[ ! -f "${DOCKERFILE_PATH}" ]]; then
echo "Invalid Dockerfile path: \"${DOCKERFILE_PATH}\""
exit 1
Expand Down Expand Up @@ -126,7 +136,9 @@ echo ""
# Build the docker container.
echo "Building container (${DOCKER_IMG_NAME})..."
docker build -t ${DOCKER_IMG_NAME} \
-f "${DOCKERFILE_PATH}" "${DOCKER_CONTEXT_PATH}"
-f "${DOCKERFILE_PATH}" \
${CI_DOCKER_BUILD_EXTRA_PARAMS[@]} \
"${DOCKER_CONTEXT_PATH}"

# Check docker build status
if [[ $? != "0" ]]; then
Expand Down

0 comments on commit 079e184

Please sign in to comment.