Use buildx bake for parallel builds

This commit is contained in:
xZero707 2021-09-25 03:19:05 +02:00
parent 1ac04287de
commit 6f8380b861
3 changed files with 145 additions and 35 deletions

View File

@ -32,4 +32,4 @@ jobs:
username: ${{ secrets.DOCKER_USERNAME }} username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }} password: ${{ secrets.DOCKER_PASSWORD }}
- name: Build image - 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" run: build/bin/build

View File

@ -1,36 +1,3 @@
#!/usr/bin/env bash #!/usr/bin/env bash
WP_VERSIONS=${1:-""} docker buildx bake --print --push --file build/docker-bake.hcl
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

143
build/docker-bake.hcl Normal file
View File

@ -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"
}
}