summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDave Wallace <dwallacelf@gmail.com>2024-06-18 17:10:07 -0400
committerFlorin Coras <florin.coras@gmail.com>2024-06-21 19:30:54 +0000
commit5eaa15dd0e870db9f83d3b01afed82864656d4c8 (patch)
tree887dda64e9d03355abce8d71f533ad0227c8171d
parentd8efd6e31041693d548390f1a8fede53234fdcf8 (diff)
hs-test: cache docker build in local filesystem
- when running in the CI, cache the docker build layers in the local filesystem to allow docker executor images to contain cached docker build layers Type: test Change-Id: Ie728a8370d3fb8144d01dff566aaa846ca6fd81b Signed-off-by: Dave Wallace <dwallacelf@gmail.com>
-rwxr-xr-xextras/hs-test/script/build_hst.sh32
1 files changed, 24 insertions, 8 deletions
diff --git a/extras/hs-test/script/build_hst.sh b/extras/hs-test/script/build_hst.sh
index f3a8e272207..0f5c0a43630 100755
--- a/extras/hs-test/script/build_hst.sh
+++ b/extras/hs-test/script/build_hst.sh
@@ -18,6 +18,20 @@ if [ -z "$(which wrk)" ]; then
fi
export VPP_WS=../..
+OS_ARCH="$(uname -m)"
+DOCKER_BUILD_DIR="/scratch/docker-build"
+DOCKER_CACHE_DIR="${DOCKER_BUILD_DIR}/docker_cache"
+
+if [ -d "${DOCKER_BUILD_DIR}" ] ; then
+ mkdir -p "${DOCKER_CACHE_DIR}"
+ DOCKER_HST_BUILDER="hst_builder"
+ set -x
+ if ! docker buildx ls --format "{{.Name}}" | grep -q "${DOCKER_HST_BUILDER}"; then
+ docker buildx create --name=${DOCKER_HST_BUILDER} --driver=docker-container --use --bootstrap || true
+ fi
+ set -x
+ DOCKER_CACHE_ARGS="--builder=${DOCKER_HST_BUILDER} --load --cache-to type=local,dest=${DOCKER_CACHE_DIR},mode=max --cache-from type=local,src=${DOCKER_CACHE_DIR}"
+fi
if [ "$1" == "debug" ]; then
VPP_BUILD_ROOT=${VPP_WS}/build-root/build-vpp_debug-native/vpp
@@ -31,7 +45,7 @@ echo "Taking build objects from ${VPP_BUILD_ROOT}"
export UBUNTU_VERSION=${UBUNTU_VERSION:-"$(lsb_release -rs)"}
echo "Ubuntu version is set to ${UBUNTU_VERSION}"
-export HST_LDPRELOAD=${VPP_BUILD_ROOT}/lib/x86_64-linux-gnu/libvcl_ldpreload.so
+export HST_LDPRELOAD=${VPP_BUILD_ROOT}/lib/${OS_ARCH}-linux-gnu/libvcl_ldpreload.so
echo "HST_LDPRELOAD is set to ${HST_LDPRELOAD}"
export PATH=${VPP_BUILD_ROOT}/bin:$PATH
@@ -45,7 +59,7 @@ rm -rf vpp-data/lib/* || true
cp ${VPP_BUILD_ROOT}/bin/* ${bin}
res+=$?
-cp -r ${VPP_BUILD_ROOT}/lib/x86_64-linux-gnu/* ${lib}
+cp -r ${VPP_BUILD_ROOT}/lib/"${OS_ARCH}"-linux-gnu/* ${lib}
res+=$?
if [ $res -ne 0 ]; then
echo "Failed to copy VPP files. Is VPP built? Try running 'make build' in VPP directory."
@@ -56,12 +70,14 @@ docker_build () {
tag=$1
dockername=$2
set -x
- docker build --build-arg UBUNTU_VERSION \
- --build-arg http_proxy="$HTTP_PROXY" \
- --build-arg https_proxy="$HTTP_PROXY" \
- --build-arg HTTP_PROXY="$HTTP_PROXY" \
- --build-arg HTTPS_PROXY="$HTTP_PROXY" \
- -t "$tag" -f docker/Dockerfile."$dockername" .
+ # shellcheck disable=2086
+ docker buildx build ${DOCKER_CACHE_ARGS} \
+ --build-arg UBUNTU_VERSION \
+ --build-arg http_proxy="$HTTP_PROXY" \
+ --build-arg https_proxy="$HTTP_PROXY" \
+ --build-arg HTTP_PROXY="$HTTP_PROXY" \
+ --build-arg HTTPS_PROXY="$HTTP_PROXY" \
+ -t "$tag" -f docker/Dockerfile."$dockername" .
set +x
}