Skip to content

Commit

Permalink
docker/util.sh: disable docker cache for releases
Browse files Browse the repository at this point in the history
Add --docker-cache/--no-docker-cache parameters
to the script, and default to --no-docker-cache
when building releases.

Having the on/off option defaults to
the safe choice, but when explicitly passed,
it's possible to do local experimentation
with building the release image and
benefitting from the cache.
  • Loading branch information
pjonsson committed Oct 9, 2024
1 parent 4e28921 commit f055d34
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion docker/util.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ fi

usage()
{
echo "Usage: build.sh [--push] [--docker-repository repo] [--tag name] [--gdal tag|sha1|master] [--gdal-repository repo] [--proj tag|sha1|master] [--release]"
echo "Usage: build.sh [--push] [--docker-repository repo] [--tag name] [--gdal tag|sha1|master] [--gdal-repository repo] [--proj tag|sha1|master] [--release] [--docker-cache|--no-docker-cache]"
# Non-documented: --test-python
echo ""
echo "--push: push image to docker repository (defaults to ghcr.io)"
Expand All @@ -26,6 +26,7 @@ usage()
echo "--proj tag|sha1|master: PROJ version to use. Defaults to master"
echo "--gdal-repository repo: github repository. Defaults to OSGeo/gdal"
echo "--release. Whether this is a release build. In which case --gdal tag must be used."
echo "--docker-cache/--no-docker-cache: instruct Docker to build with/without using its cache. Defaults to no cache for release builds."
echo "--with-debug-symbols/--without-debug-symbols. Whether to include debug symbols. Only applies to ubuntu-full, default is to include for non-release builds."
exit 1
}
Expand Down Expand Up @@ -100,6 +101,15 @@ do
shift
;;

--docker-cache)
DOCKER_CACHE_PARAM=""
shift
;;
--no-docker-cache)
DOCKER_CACHE_PARAM="--no-cache"
shift
;;

--without-debug-symbols)
WITH_DEBUG_SYMBOLS=no
shift
Expand Down Expand Up @@ -145,13 +155,15 @@ if test "${RELEASE}" = "yes"; then
if test "${WITH_DEBUG_SYMBOLS}" = ""; then
WITH_DEBUG_SYMBOLS=no
fi
[ -v DOCKER_CACHE_PARAM ] || DOCKER_CACHE_PARAM="--no-cache"
else
if test "${TAG_NAME}" = ""; then
TAG_NAME=latest
fi
if test "${WITH_DEBUG_SYMBOLS}" = ""; then
WITH_DEBUG_SYMBOLS=yes
fi
[ -v DOCKER_CACHE_PARAM ] || DOCKER_CACHE_PARAM=""
fi

check_image()
Expand Down Expand Up @@ -196,6 +208,7 @@ REPO_IMAGE_NAME="${DOCKER_REPO}/${IMAGE_NAME}"

if test "${RELEASE}" = "yes"; then
BUILD_ARGS=(
$DOCKER_CACHE_PARAM \
"--build-arg" "PROJ_DATUMGRID_LATEST_LAST_MODIFIED=${PROJ_DATUMGRID_LATEST_LAST_MODIFIED}" \
"--build-arg" "PROJ_VERSION=${PROJ_VERSION}" \
"--build-arg" "GDAL_VERSION=${GDAL_VERSION}" \
Expand Down Expand Up @@ -300,6 +313,7 @@ EOF
RSYNC_REMOTE="rsync://127.0.0.1:23985/gdal-docker-cache/${TARGET_IMAGE}"

BUILD_ARGS=(
$DOCKER_CACHE_PARAM \
"--build-arg" "PROJ_DATUMGRID_LATEST_LAST_MODIFIED=${PROJ_DATUMGRID_LATEST_LAST_MODIFIED}" \
"--build-arg" "PROJ_VERSION=${PROJ_VERSION}" \
"--build-arg" "GDAL_VERSION=${GDAL_VERSION}" \
Expand Down

0 comments on commit f055d34

Please sign in to comment.