From 0e7cc38249169b203aecce9249333012585ff82b Mon Sep 17 00:00:00 2001 From: xZero707 Date: Thu, 23 Sep 2021 18:46:49 +0200 Subject: [PATCH] Improve code, implement cache --- build/bin/build | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/build/bin/build b/build/bin/build index d5d5c09..e704aac 100755 --- a/build/bin/build +++ b/build/bin/build @@ -3,6 +3,8 @@ WP_VERSIONS=${1:-""} WP_LATEST_VERSION=${2:-""} +CACHE_DIR="/tmp/.buildx-cache" + if [ -z "${WP_VERSIONS}" ]; then echo "Error: WP_VERSIONS is null" exit 1 @@ -14,9 +16,16 @@ docker buildx create --use --name build --node build --driver-opt network=host for TARGET_VERSION in ${WP_VERSIONS}; do echo "> Building WordPress ${TARGET_VERSION}" - docker buildx build --pull --push --build-arg "WP_VERSION=${TARGET_VERSION}" --platform "linux/amd64,linux/armhf,linux/aarch64" --tag "nlss/wordpress:${TARGET_VERSION}" . - if [ "${TARGET_VERSION}" = "${WP_LATEST_VERSION}" ]; then - docker buildx build --pull --push --build-arg "WP_VERSION=${TARGET_VERSION}" --platform "linux/amd64,linux/armhf,linux/aarch64" --tag "nlss/wordpress:latest" . + TARGET_VERSION="latest" fi + + docker buildx build \ + --pull \ + --push \ + --cache-from "type=local,src=${CACHE_DIR}" \ + --cache-to "type=local,dest=${CACHE_DIR}" \ + --build-arg "WP_VERSION=${TARGET_VERSION}" \ + --platform "linux/amd64,linux/armhf,linux/aarch64" \ + --tag "nlss/wordpress:${TARGET_VERSION}" . done