Unverified Commit 079e1844 by Leandro Nunes Committed by GitHub

Create a new parameter --cache-from in tvm/docker/build.sh, so that we can point…

Create a new parameter --cache-from in tvm/docker/build.sh, so that we 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
parent bf132251
...@@ -21,7 +21,7 @@ ...@@ -21,7 +21,7 @@
# Execute command within a docker container # Execute command within a docker container
# #
# Usage: build.sh <CONTAINER_TYPE> [--dockerfile <DOCKERFILE_PATH>] [-it] # 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., # CONTAINER_TYPE: Type of the docker container used the run the build: e.g.,
# (cpu | gpu) # (cpu | gpu)
...@@ -30,6 +30,9 @@ ...@@ -30,6 +30,9 @@
# this optional value is not supplied (via the --dockerfile # this optional value is not supplied (via the --dockerfile
# flag), will use Dockerfile.CONTAINER_TYPE in default # 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 # COMMAND: Command to be executed in the docker container
# #
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
...@@ -60,6 +63,13 @@ if [[ "$1" == "--net=host" ]]; then ...@@ -60,6 +63,13 @@ if [[ "$1" == "--net=host" ]]; then
shift 1 shift 1
fi 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 if [[ ! -f "${DOCKERFILE_PATH}" ]]; then
echo "Invalid Dockerfile path: \"${DOCKERFILE_PATH}\"" echo "Invalid Dockerfile path: \"${DOCKERFILE_PATH}\""
exit 1 exit 1
...@@ -126,7 +136,9 @@ echo "" ...@@ -126,7 +136,9 @@ echo ""
# Build the docker container. # Build the docker container.
echo "Building container (${DOCKER_IMG_NAME})..." echo "Building container (${DOCKER_IMG_NAME})..."
docker build -t ${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 # Check docker build status
if [[ $? != "0" ]]; then if [[ $? != "0" ]]; then
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment