diff --git a/docker-bake.hcl b/docker-bake.hcl index 95963a8..64c1c65 100644 --- a/docker-bake.hcl +++ b/docker-bake.hcl @@ -6,23 +6,19 @@ variable "BUILDREV" { default = "" } -target "common" { - platforms = ["linux/amd64", "linux/arm64", "linux/arm/v7", "linux/s390x", "linux/ppc64le"] - args = {"GOCRONVER" = "v0.0.10"} -} - target "debian" { - inherits = ["common"] + args = {"GOCRONVER" = "v0.0.10"} dockerfile = "debian.Dockerfile" } target "alpine" { - inherits = ["common"] + args = {"GOCRONVER" = "v0.0.10"} dockerfile = "alpine.Dockerfile" } target "debian-latest" { inherits = ["debian"] + platforms = ["linux/amd64", "linux/arm64", "linux/arm/v7", "linux/s390x", "linux/ppc64le"] args = {"BASETAG" = "14"} tags = [ "prodrigestivill/postgres-backup-local:latest", @@ -33,6 +29,7 @@ target "debian-latest" { target "alpine-latest" { inherits = ["alpine"] + platforms = ["linux/amd64", "linux/arm64", "linux/arm/v7", "linux/s390x", "linux/ppc64le"] args = {"BASETAG" = "14-alpine"} tags = [ "prodrigestivill/postgres-backup-local:alpine", @@ -43,6 +40,7 @@ target "alpine-latest" { target "debian-13" { inherits = ["debian"] + platforms = ["linux/amd64", "linux/arm64", "linux/arm/v7", "linux/s390x", "linux/ppc64le"] args = {"BASETAG" = "13"} tags = [ "prodrigestivill/postgres-backup-local:13", @@ -52,6 +50,7 @@ target "debian-13" { target "alpine-13" { inherits = ["alpine"] + platforms = ["linux/amd64", "linux/arm64", "linux/arm/v7", "linux/s390x", "linux/ppc64le"] args = {"BASETAG" = "13-alpine"} tags = [ "prodrigestivill/postgres-backup-local:13-alpine", @@ -61,6 +60,7 @@ target "alpine-13" { target "debian-12" { inherits = ["debian"] + platforms = ["linux/amd64", "linux/arm64", "linux/arm/v7", "linux/s390x", "linux/ppc64le"] args = {"BASETAG" = "12"} tags = [ "prodrigestivill/postgres-backup-local:12", @@ -70,6 +70,7 @@ target "debian-12" { target "alpine-12" { inherits = ["alpine"] + platforms = ["linux/amd64", "linux/arm64", "linux/arm/v7", "linux/s390x", "linux/ppc64le"] args = {"BASETAG" = "12-alpine"} tags = [ "prodrigestivill/postgres-backup-local:12-alpine", @@ -79,6 +80,7 @@ target "alpine-12" { target "debian-11" { inherits = ["debian"] + platforms = ["linux/amd64", "linux/arm64", "linux/arm/v7"] args = {"BASETAG" = "11"} tags = [ "prodrigestivill/postgres-backup-local:11", @@ -88,6 +90,7 @@ target "debian-11" { target "alpine-11" { inherits = ["alpine"] + platforms = ["linux/amd64", "linux/arm64", "linux/arm/v7", "linux/s390x", "linux/ppc64le"] args = {"BASETAG" = "11-alpine"} tags = [ "prodrigestivill/postgres-backup-local:11-alpine", @@ -97,6 +100,7 @@ target "alpine-11" { target "debian-10" { inherits = ["debian"] + platforms = ["linux/amd64", "linux/arm64", "linux/arm/v7"] args = {"BASETAG" = "10"} tags = [ "prodrigestivill/postgres-backup-local:10", @@ -106,6 +110,7 @@ target "debian-10" { target "alpine-10" { inherits = ["alpine"] + platforms = ["linux/amd64", "linux/arm64", "linux/arm/v7", "linux/s390x", "linux/ppc64le"] args = {"BASETAG" = "10-alpine"} tags = [ "prodrigestivill/postgres-backup-local:10-alpine", diff --git a/generate.sh b/generate.sh index 7d70e13..03e75d1 100755 --- a/generate.sh +++ b/generate.sh @@ -3,18 +3,22 @@ set -e DOCKER_BAKE_FILE=${1:-"docker-bake.hcl"} -TAGS=${TAGS:-"14 13 12 11 10"} -GOCRONVER=${GOCRONVER:-"v0.0.10"} -PLATFORMS=${PLATFORMS:-"linux/amd64 linux/arm64 linux/arm/v7 linux/s390x linux/ppc64le"} IMAGE_NAME=${IMAGE_NAME:-"prodrigestivill/postgres-backup-local"} +GOCRONVER="v0.0.10" +MAIN_TAG="14" +TAGS_EXTRA="13 12" +PLATFORMS="linux/amd64 linux/arm64 linux/arm/v7 linux/s390x linux/ppc64le" +TAGS_EXTRA_2="11 10" +PLATFORMS_DEBIAN_2="linux/amd64 linux/arm64 linux/arm/v7" + + cd "$(dirname "$0")" -MAIN_TAG=${TAGS%%" "*} # First tag -TAGS_EXTRA=${TAGS#*" "} # Rest of tags P="\"$(echo $PLATFORMS | sed 's/ /", "/g')\"" +P2="\"$(echo $PLATFORMS_DEBIAN_2 | sed 's/ /", "/g')\"" -T="\"debian-latest\", \"alpine-latest\", \"$(echo debian-$TAGS_EXTRA | sed 's/ /", "debian-/g')\", \"$(echo alpine-$TAGS_EXTRA | sed 's/ /", "alpine-/g')\"" +T="\"debian-latest\", \"alpine-latest\", \"$(echo debian-$TAGS_EXTRA $TAGS_EXTRA_2 | sed 's/ /", "debian-/g')\", \"$(echo alpine-$TAGS_EXTRA $TAGS_EXTRA_2 | sed 's/ /", "alpine-/g')\"" cat > "$DOCKER_BAKE_FILE" << EOF group "default" { @@ -25,23 +29,19 @@ variable "BUILDREV" { default = "" } -target "common" { - platforms = [$P] - args = {"GOCRONVER" = "$GOCRONVER"} -} - target "debian" { - inherits = ["common"] + args = {"GOCRONVER" = "$GOCRONVER"} dockerfile = "debian.Dockerfile" } target "alpine" { - inherits = ["common"] + args = {"GOCRONVER" = "$GOCRONVER"} dockerfile = "alpine.Dockerfile" } target "debian-latest" { inherits = ["debian"] + platforms = [$P] args = {"BASETAG" = "$MAIN_TAG"} tags = [ "$IMAGE_NAME:latest", @@ -52,6 +52,7 @@ target "debian-latest" { target "alpine-latest" { inherits = ["alpine"] + platforms = [$P] args = {"BASETAG" = "$MAIN_TAG-alpine"} tags = [ "$IMAGE_NAME:alpine", @@ -65,6 +66,7 @@ for TAG in $TAGS_EXTRA; do cat >> "$DOCKER_BAKE_FILE" << EOF target "debian-$TAG" { inherits = ["debian"] + platforms = [$P] args = {"BASETAG" = "$TAG"} tags = [ "$IMAGE_NAME:$TAG", @@ -74,6 +76,31 @@ target "debian-$TAG" { target "alpine-$TAG" { inherits = ["alpine"] + platforms = [$P] + args = {"BASETAG" = "$TAG-alpine"} + tags = [ + "$IMAGE_NAME:$TAG-alpine", + notequal("", BUILDREV) ? "$IMAGE_NAME:$TAG-alpine-\${BUILDREV}" : "" + ] +} +EOF +done + +for TAG in $TAGS_EXTRA_2; do cat >> "$DOCKER_BAKE_FILE" << EOF + +target "debian-$TAG" { + inherits = ["debian"] + platforms = [$P2] + args = {"BASETAG" = "$TAG"} + tags = [ + "$IMAGE_NAME:$TAG", + notequal("", BUILDREV) ? "$IMAGE_NAME:$TAG-debian-\${BUILDREV}" : "" + ] +} + +target "alpine-$TAG" { + inherits = ["alpine"] + platforms = [$P] args = {"BASETAG" = "$TAG-alpine"} tags = [ "$IMAGE_NAME:$TAG-alpine",