Merge "build-docker-images: allow docker cache"
This commit is contained in:
commit
443f851e74
@ -36,6 +36,7 @@ CLEAN=no
|
||||
TAG_LATEST=no
|
||||
LATEST_TAG=latest
|
||||
HOST=${HOSTNAME}
|
||||
USE_DOCKER_CACHE=no
|
||||
declare -i MAX_ATTEMPTS=1
|
||||
|
||||
function usage {
|
||||
@ -65,6 +66,9 @@ Options:
|
||||
--attempts: Max attempts, in case of failure (default: 1)
|
||||
--config-file:Specify a path to a config file which will specify additional arguments to be passed into the command
|
||||
|
||||
--cache: Allow docker to use cached filesystem layers when building
|
||||
CAUTION: this option may ignore locally-generated packages
|
||||
and is meant for debugging the build scripts.
|
||||
EOF
|
||||
}
|
||||
|
||||
@ -114,7 +118,7 @@ function get_args_from_file {
|
||||
done <"$1"
|
||||
}
|
||||
|
||||
OPTS=$(getopt -o h -l help,os:,os-version:,version:,stream:,release:,repo:,push,proxy:,latest,latest-tag:,user:,registry:,local,clean,hostname:,attempts:,config-file: -- "$@")
|
||||
OPTS=$(getopt -o h -l help,os:,os-version:,version:,stream:,release:,repo:,push,proxy:,latest,latest-tag:,user:,registry:,local,clean,cache,hostname:,attempts:,config-file: -- "$@")
|
||||
if [ $? -ne 0 ]; then
|
||||
usage
|
||||
exit 1
|
||||
@ -186,6 +190,10 @@ while true; do
|
||||
CLEAN=yes
|
||||
shift
|
||||
;;
|
||||
--cache)
|
||||
USE_DOCKER_CACHE=yes
|
||||
shift
|
||||
;;
|
||||
--hostname)
|
||||
HOST=$2
|
||||
shift 2
|
||||
@ -358,7 +366,9 @@ if [ ! -z "$PROXY" ]; then
|
||||
fi
|
||||
|
||||
# Don't use docker cache
|
||||
BUILD_ARGS+=("--no-cache")
|
||||
if [[ "$USE_DOCKER_CACHE" != "yes" ]] ; then
|
||||
BUILD_ARGS+=("--no-cache")
|
||||
fi
|
||||
|
||||
BUILD_ARGS+=(--tag ${IMAGE_NAME} ${BUILDDIR})
|
||||
|
||||
|
@ -36,6 +36,7 @@ BASE=
|
||||
WHEELS=
|
||||
WHEELS_PY2=
|
||||
CLEAN=no
|
||||
export USE_DOCKER_CACHE=no
|
||||
TAG_LATEST=no
|
||||
TAG_LIST_FILE=
|
||||
TAG_LIST_LATEST_FILE=
|
||||
@ -80,6 +81,11 @@ Options:
|
||||
multiple --skip arguments.
|
||||
--attempts: Max attempts, in case of failure (default: 1)
|
||||
|
||||
--cache: Allow docker to use filesystem cache when building
|
||||
CAUTION: this option may ignore locally-generated
|
||||
packages and is meant for debugging the build
|
||||
scripts.
|
||||
|
||||
|
||||
EOF
|
||||
}
|
||||
@ -540,9 +546,14 @@ function build_image_loci {
|
||||
# Use patched docker file
|
||||
BUILD_ARGS+=(--file "${WORKDIR}/loci/Dockerfile.stx")
|
||||
|
||||
# Disable build cache
|
||||
if [[ "$USE_DOCKER_CACHE" != "yes" ]] ; then
|
||||
BUILD_ARGS+=("--no-cache")
|
||||
fi
|
||||
|
||||
local build_image_name="${USER}/${LABEL}:${IMAGE_TAG_BUILD}"
|
||||
|
||||
with_retries ${MAX_ATTEMPTS} docker build ${WORKDIR}/loci --no-cache \
|
||||
with_retries ${MAX_ATTEMPTS} docker build ${WORKDIR}/loci \
|
||||
"${BUILD_ARGS[@]}" \
|
||||
--tag ${build_image_name} 2>&1 | tee ${WORKDIR}/docker-${LABEL}-${OS}-${BUILD_STREAM}.log
|
||||
if [ ${PIPESTATUS[0]} -ne 0 ]; then
|
||||
@ -655,7 +666,7 @@ function build_image_docker {
|
||||
local build_image_name="${USER}/${LABEL}:${IMAGE_TAG_BUILD}"
|
||||
|
||||
local -a BASE_BUILD_ARGS
|
||||
BASE_BUILD_ARGS+=(${real_docker_context} --no-cache)
|
||||
BASE_BUILD_ARGS+=(${real_docker_context})
|
||||
BASE_BUILD_ARGS+=(--file ${real_docker_file})
|
||||
BASE_BUILD_ARGS+=(--build-arg "BASE=${BASE}")
|
||||
if [ ! -z "$HTTP_PROXY" ]; then
|
||||
@ -670,6 +681,10 @@ function build_image_docker {
|
||||
BASE_BUILD_ARGS+=(--build-arg no_proxy=$NO_PROXY)
|
||||
fi
|
||||
|
||||
if [[ "$USE_DOCKER_CACHE" != "yes" ]] ; then
|
||||
BASE_BUILD_ARGS+=("--no-cache")
|
||||
fi
|
||||
|
||||
BASE_BUILD_ARGS+=(--tag ${build_image_name})
|
||||
with_retries ${MAX_ATTEMPTS} docker build ${BASE_BUILD_ARGS[@]} 2>&1 | tee ${WORKDIR}/docker-${LABEL}-${OS}-${BUILD_STREAM}.log
|
||||
|
||||
@ -784,7 +799,7 @@ function build_image {
|
||||
esac
|
||||
}
|
||||
|
||||
OPTS=$(getopt -o hN -l help,os:,version:,release:,stream:,push,http_proxy:,https_proxy:,no_proxy:,user:,registry:,base:,wheels:,wheels-alternate:,wheels-py2:,only:,skip:,prefix:,latest,latest-prefix:,clean,attempts:,no-pull-base -- "$@")
|
||||
OPTS=$(getopt -o hN -l help,os:,version:,release:,stream:,push,http_proxy:,https_proxy:,no_proxy:,user:,registry:,base:,wheels:,wheels-alternate:,wheels-py2:,only:,skip:,prefix:,latest,latest-prefix:,clean,cache,attempts:,no-pull-base -- "$@")
|
||||
if [ $? -ne 0 ]; then
|
||||
usage
|
||||
exit 1
|
||||
@ -864,6 +879,10 @@ while true; do
|
||||
CLEAN=yes
|
||||
shift
|
||||
;;
|
||||
--cache)
|
||||
USE_DOCKER_CACHE=yes
|
||||
shift
|
||||
;;
|
||||
--only)
|
||||
# Read comma-separated values into array
|
||||
ONLY+=(${2//,/ })
|
||||
|
Loading…
x
Reference in New Issue
Block a user