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