From 6f8380b861822a3a960f411b21bd3193f22fed3e Mon Sep 17 00:00:00 2001 From: xZero707 Date: Sat, 25 Sep 2021 03:19:05 +0200 Subject: [PATCH] Use buildx bake for parallel builds --- .github/workflows/image.yml | 2 +- build/bin/build | 35 +-------- build/docker-bake.hcl | 143 ++++++++++++++++++++++++++++++++++++ 3 files changed, 145 insertions(+), 35 deletions(-) create mode 100644 build/docker-bake.hcl diff --git a/.github/workflows/image.yml b/.github/workflows/image.yml index a2067dd..c3f162a 100644 --- a/.github/workflows/image.yml +++ b/.github/workflows/image.yml @@ -32,4 +32,4 @@ jobs: username: ${{ secrets.DOCKER_USERNAME }} password: ${{ secrets.DOCKER_PASSWORD }} - name: Build image - run: build/bin/build "5.3.0 5.3.1 5.3.2 5.4.0 5.4.1 5.4.2 5.5.1 5.5.3 5.6.0 5.6.1 5.6.2 5.7.0 5.7.1 5.7.2 5.8.0 5.8.1" "5.8.1" \ No newline at end of file + run: build/bin/build \ No newline at end of file diff --git a/build/bin/build b/build/bin/build index 06234de..1a33099 100755 --- a/build/bin/build +++ b/build/bin/build @@ -1,36 +1,3 @@ #!/usr/bin/env bash -WP_VERSIONS=${1:-""} -WP_LATEST_VERSION=${2:-""} -TARGET_PLATFORMS="linux/amd64,linux/armhf,linux/aarch64" - -CACHE_DIR="/tmp/.buildx-cache" - -if [ -z "${WP_VERSIONS}" ]; then - echo "Error: WP_VERSIONS is null" - exit 1 -fi - -docker buildx create --use --name build --node build --driver-opt network=host - -# Loop through requested versions -for TARGET_VERSION in ${WP_VERSIONS}; do - echo "> Building WordPress ${TARGET_VERSION}" - - IMAGE_TAGS="--tag nlss/wordpress:${TARGET_VERSION}" - - if [ "${TARGET_VERSION}" = "${WP_LATEST_VERSION}" ]; then - IMAGE_TAGS="${IMAGE_TAGS} --tag nlss/wordpress:latest" - fi - - docker buildx build . \ - --pull \ - --push \ - --cache-from "type=local,src=${CACHE_DIR}" \ - --cache-to "type=local,dest=${CACHE_DIR},mode=max" \ - --build-arg "WP_VERSION=${TARGET_VERSION}" \ - --platform "${TARGET_PLATFORMS}" \ - ${IMAGE_TAGS[@]} & - - sleep 2 -done +docker buildx bake --print --push --file build/docker-bake.hcl \ No newline at end of file diff --git a/build/docker-bake.hcl b/build/docker-bake.hcl new file mode 100644 index 0000000..86393bd --- /dev/null +++ b/build/docker-bake.hcl @@ -0,0 +1,143 @@ +group "default" { + targets = ["5.3.0", "5.3.1", "5.3.2", "5.4.0", "5.4.1", "5.4.2", "5.5.1", "5.5.3", "5.6.0", "5.6.1", "5.6.2", "5.7.0", "5.7.1", "5.7.2", "5.8.0", "5.8.1"] +} + +target "build-dockerfile" { + dockerfile = "Dockerfile" +} + +target "build-platforms" { + platforms = ["linux/amd64", "linux/armhf", "linux/aarch64"] +} + +target "build-common" { + pull = true +} + +target "5.3.0" { + inherits = ["build-dockerfile", "build-platforms", "build-common"] + tags = ["docker.io/nlss/wordpress:5.3.0"] + args = { + WP_VERSION = "5.3.0" + } +} + +target "5.3.1" { + inherits = ["build-dockerfile", "build-platforms", "build-common"] + tags = ["docker.io/nlss/wordpress:5.3.1"] + args = { + WP_VERSION = "5.3.1" + } +} + +target "5.3.2" { + inherits = ["build-dockerfile", "build-platforms", "build-common"] + tags = ["docker.io/nlss/wordpress:5.3.2"] + args = { + WP_VERSION = "5.3.2" + } +} + +target "5.4.0" { + inherits = ["build-dockerfile", "build-platforms", "build-common"] + tags = ["docker.io/nlss/wordpress:5.4.0"] + args = { + WP_VERSION = "5.4.0" + } +} + +target "5.4.1" { + inherits = ["build-dockerfile", "build-platforms", "build-common"] + tags = ["docker.io/nlss/wordpress:5.4.1"] + args = { + WP_VERSION = "5.4.1" + } +} + +target "5.4.2" { + inherits = ["build-dockerfile", "build-platforms", "build-common"] + tags = ["docker.io/nlss/wordpress:5.4.2"] + args = { + WP_VERSION = "5.4.2" + } +} + +target "5.5.1" { + inherits = ["build-dockerfile", "build-platforms", "build-common"] + tags = ["docker.io/nlss/wordpress:5.5.1"] + args = { + WP_VERSION = "5.5.1" + } +} + +target "5.5.3" { + inherits = ["build-dockerfile", "build-platforms", "build-common"] + tags = ["docker.io/nlss/wordpress:5.5.3"] + args = { + WP_VERSION = "5.5.3" + } +} + +target "5.6.0" { + inherits = ["build-dockerfile", "build-platforms", "build-common"] + tags = ["docker.io/nlss/wordpress:5.6.0"] + args = { + WP_VERSION = "5.6.0" + } +} + +target "5.6.1" { + inherits = ["build-dockerfile", "build-platforms", "build-common"] + tags = ["docker.io/nlss/wordpress:5.6.1"] + args = { + WP_VERSION = "5.6.1" + } +} + +target "5.6.2" { + inherits = ["build-dockerfile", "build-platforms", "build-common"] + tags = ["docker.io/nlss/wordpress:5.6.2"] + args = { + WP_VERSION = "5.6.2" + } +} + +target "5.7.0" { + inherits = ["build-dockerfile", "build-platforms", "build-common"] + tags = ["docker.io/nlss/wordpress:5.7.0"] + args = { + WP_VERSION = "5.7.0" + } +} + +target "5.7.1" { + inherits = ["build-dockerfile", "build-platforms", "build-common"] + tags = ["docker.io/nlss/wordpress:5.7.1"] + args = { + WP_VERSION = "5.7.1" + } +} + +target "5.7.2" { + inherits = ["build-dockerfile", "build-platforms", "build-common"] + tags = ["docker.io/nlss/wordpress:5.7.2"] + args = { + WP_VERSION = "5.7.2" + } +} + +target "5.8.0" { + inherits = ["build-dockerfile", "build-platforms", "build-common"] + tags = ["docker.io/nlss/wordpress:5.8.0"] + args = { + WP_VERSION = "5.8.0" + } +} + +target "5.8.1" { + inherits = ["build-dockerfile", "build-platforms", "build-common"] + tags = ["docker.io/nlss/wordpress:5.8.1", "docker.io/nlss/wordpress:latest"] + args = { + WP_VERSION = "5.8.1" + } +}