Skip to content

Commit

Permalink
chore: factorise jdk in docker-bake.hcl (#804)
Browse files Browse the repository at this point in the history
* chore: factorise jdk in docker-bake.hcl
  • Loading branch information
lemeurherve authored May 23, 2024
1 parent bbaa75b commit d0dc008
Showing 1 changed file with 85 additions and 141 deletions.
226 changes: 85 additions & 141 deletions docker-bake.hcl
Original file line number Diff line number Diff line change
@@ -1,22 +1,18 @@
group "linux" {
targets = [
"alpine_jdk11",
"alpine_jdk17",
"alpine_jdk21",
"agent_archlinux_jdk11",
"debian_jdk11",
"debian_jdk17",
"debian_jdk21",
"alpine",
"debian",
"debian_jdk21_preview"
]
}

group "linux-agent-only" {
targets = [
"agent_archlinux_jdk11",
"agent_alpine_jdk11",
"agent_alpine_jdk17",
"agent_alpine_jdk21",
"agent_archlinux_jdk11",
"agent_debian_jdk11",
"agent_debian_jdk17",
"agent_debian_jdk21",
Expand All @@ -38,9 +34,7 @@ group "linux-inbound-agent-only" {

group "linux-arm64" {
targets = [
"debian_jdk11",
"debian_jdk17",
"debian_jdk21",
"debian",
"alpine_jdk21",
]
}
Expand All @@ -62,9 +56,7 @@ group "linux-s390x" {

group "linux-ppc64le" {
targets = [
"debian_jdk11",
"debian_jdk17",
"debian_jdk21"
"debian"
]
}

Expand Down Expand Up @@ -129,173 +121,125 @@ function "orgrepo" {
result = equal("agent", agentType) ? "${REGISTRY_ORG}/${REGISTRY_REPO_AGENT}" : "${REGISTRY_ORG}/${REGISTRY_REPO_INBOUND_AGENT}"
}

target "agent_archlinux_jdk11" {
dockerfile = "archlinux/Dockerfile"
context = "."
args = {
JAVA_VERSION = JAVA11_VERSION
VERSION = REMOTING_VERSION
}
tags = [
equal(ON_TAG, "true") ? "${REGISTRY}/${orgrepo("agent")}:${REMOTING_VERSION}-${BUILD_NUMBER}-archlinux" : "",
equal(ON_TAG, "true") ? "${REGISTRY}/${orgrepo("agent")}:${REMOTING_VERSION}-${BUILD_NUMBER}-archlinux-jdk11" : "",
"${REGISTRY}/${orgrepo("agent")}:archlinux",
"${REGISTRY}/${orgrepo("agent")}:latest-archlinux",
"${REGISTRY}/${orgrepo("agent")}:archlinux-jdk11",
"${REGISTRY}/${orgrepo("agent")}:latest-archlinux-jdk11",
]
platforms = ["linux/amd64"]
variable "default_jdk" {
default = 17
}

target "alpine_jdk11" {
matrix = {
type = ["agent", "inbound-agent"]
}
name = "${type}_alpine_jdk11"
target = type
dockerfile = "alpine/Dockerfile"
context = "."
args = {
ALPINE_TAG = ALPINE_FULL_TAG
JAVA_VERSION = JAVA11_VERSION
VERSION = REMOTING_VERSION
}
tags = [
equal(ON_TAG, "true") ? "${REGISTRY}/${orgrepo(type)}:${REMOTING_VERSION}-${BUILD_NUMBER}-alpine-jdk11" : "",
equal(ON_TAG, "true") ? "${REGISTRY}/${orgrepo(type)}:${REMOTING_VERSION}-${BUILD_NUMBER}-alpine${ALPINE_SHORT_TAG}-jdk11" : "",
"${REGISTRY}/${orgrepo(type)}:alpine-jdk11",
"${REGISTRY}/${orgrepo(type)}:alpine${ALPINE_SHORT_TAG}-jdk11",
"${REGISTRY}/${orgrepo(type)}:latest-alpine-jdk11",
"${REGISTRY}/${orgrepo(type)}:latest-alpine${ALPINE_SHORT_TAG}-jdk11",
]
platforms = ["linux/amd64"]
# Return "true" if the jdk passed as parameter is the same as the default jdk, "false" otherwise
function "is_default_jdk" {
params = [jdk]
result = equal(default_jdk, jdk) ? true : false
}

target "alpine_jdk17" {
matrix = {
type = ["agent", "inbound-agent"]
}
name = "${type}_alpine_jdk17"
target = type
dockerfile = "alpine/Dockerfile"
context = "."
args = {
ALPINE_TAG = ALPINE_FULL_TAG
JAVA_VERSION = JAVA17_VERSION
VERSION = REMOTING_VERSION
}
tags = [
equal(ON_TAG, "true") ? "${REGISTRY}/${orgrepo(type)}:${REMOTING_VERSION}-${BUILD_NUMBER}-alpine" : "",
equal(ON_TAG, "true") ? "${REGISTRY}/${orgrepo(type)}:${REMOTING_VERSION}-${BUILD_NUMBER}-alpine${ALPINE_SHORT_TAG}" : "",
equal(ON_TAG, "true") ? "${REGISTRY}/${orgrepo(type)}:${REMOTING_VERSION}-${BUILD_NUMBER}-alpine-jdk17" : "",
equal(ON_TAG, "true") ? "${REGISTRY}/${orgrepo(type)}:${REMOTING_VERSION}-${BUILD_NUMBER}-alpine${ALPINE_SHORT_TAG}-jdk17" : "",
"${REGISTRY}/${orgrepo(type)}:alpine",
"${REGISTRY}/${orgrepo(type)}:alpine${ALPINE_SHORT_TAG}",
"${REGISTRY}/${orgrepo(type)}:alpine-jdk17",
"${REGISTRY}/${orgrepo(type)}:alpine${ALPINE_SHORT_TAG}-jdk17",
"${REGISTRY}/${orgrepo(type)}:latest-alpine",
"${REGISTRY}/${orgrepo(type)}:latest-alpine${ALPINE_SHORT_TAG}",
"${REGISTRY}/${orgrepo(type)}:latest-alpine-jdk17",
"${REGISTRY}/${orgrepo(type)}:latest-alpine${ALPINE_SHORT_TAG}-jdk17",
]
platforms = ["linux/amd64"]
# Return the complete Java version corresponding to the jdk passed as parameter
function "javaversion" {
params = [jdk]
result = (equal(11, jdk)
? "${JAVA11_VERSION}"
: (equal(17, jdk)
? "${JAVA17_VERSION}"
: "${JAVA21_VERSION}"))
}

# Return an array of Alpine platforms to use depending on the jdk passed as parameter
function "alpine_platforms" {
params = [jdk]
result = (equal(21, jdk)
? ["linux/amd64", "linux/arm64"]
: ["linux/amd64"])
}

# Return an array of Debian platforms to use depending on the jdk passed as parameter
function "debian_platforms" {
params = [jdk]
result = (equal(11, jdk)
? ["linux/amd64", "linux/arm64", "linux/ppc64le", "linux/arm/v7", "linux/s390x"]
: (equal(17, jdk)
? ["linux/amd64", "linux/arm64", "linux/ppc64le", "linux/arm/v7"]
: ["linux/amd64", "linux/arm64", "linux/ppc64le", "linux/s390x"]))
}

target "alpine_jdk21" {
target "alpine" {
matrix = {
type = ["agent", "inbound-agent"]
jdk = [11, 17, 21]
}
name = "${type}_alpine_jdk21"
name = "${type}_alpine_jdk${jdk}"
target = type
dockerfile = "alpine/Dockerfile"
context = "."
args = {
ALPINE_TAG = ALPINE_FULL_TAG
JAVA_VERSION = JAVA21_VERSION
VERSION = REMOTING_VERSION
JAVA_VERSION = "${javaversion(jdk)}"
}
tags = [
equal(ON_TAG, "true") ? "${REGISTRY}/${orgrepo(type)}:${REMOTING_VERSION}-${BUILD_NUMBER}-alpine-jdk21" : "",
equal(ON_TAG, "true") ? "${REGISTRY}/${orgrepo(type)}:${REMOTING_VERSION}-${BUILD_NUMBER}-alpine${ALPINE_SHORT_TAG}-jdk21" : "",
"${REGISTRY}/${orgrepo(type)}:alpine-jdk21",
"${REGISTRY}/${orgrepo(type)}:alpine${ALPINE_SHORT_TAG}-jdk21",
"${REGISTRY}/${orgrepo(type)}:latest-alpine-jdk21",
"${REGISTRY}/${orgrepo(type)}:latest-alpine${ALPINE_SHORT_TAG}-jdk21",
]
platforms = ["linux/amd64", "linux/arm64"]
}

target "debian_jdk11" {
matrix = {
type = ["agent", "inbound-agent"]
}
name = "${type}_debian_jdk11"
target = type
dockerfile = "debian/Dockerfile"
context = "."
args = {
JAVA_VERSION = JAVA11_VERSION
VERSION = REMOTING_VERSION
DEBIAN_RELEASE = DEBIAN_RELEASE
}
tags = [
equal(ON_TAG, "true") ? "${REGISTRY}/${orgrepo(type)}:${REMOTING_VERSION}-${BUILD_NUMBER}-jdk11" : "",
"${REGISTRY}/${orgrepo(type)}:bookworm-jdk11",
"${REGISTRY}/${orgrepo(type)}:jdk11",
"${REGISTRY}/${orgrepo(type)}:latest-bookworm-jdk11",
"${REGISTRY}/${orgrepo(type)}:latest-jdk11",
# If there is a tag, add versioned tags suffixed by the jdk
equal(ON_TAG, "true") ? "${REGISTRY}/${orgrepo(type)}:${REMOTING_VERSION}-${BUILD_NUMBER}-alpine-jdk${jdk}" : "",
equal(ON_TAG, "true") ? "${REGISTRY}/${orgrepo(type)}:${REMOTING_VERSION}-${BUILD_NUMBER}-alpine${ALPINE_SHORT_TAG}-jdk${jdk}" : "",
# If there is a tag and if the jdk is the default one, add Alpine short tags
equal(ON_TAG, "true") ? (is_default_jdk(jdk) ? "${REGISTRY}/${orgrepo(type)}:${REMOTING_VERSION}-${BUILD_NUMBER}-alpine" : "") : "",
equal(ON_TAG, "true") ? (is_default_jdk(jdk) ? "${REGISTRY}/${orgrepo(type)}:${REMOTING_VERSION}-${BUILD_NUMBER}-alpine${ALPINE_SHORT_TAG}" : "") : "",
# If the jdk is the default one, add Alpine short tags
is_default_jdk(jdk) ? "${REGISTRY}/${orgrepo(type)}:alpine" : "",
is_default_jdk(jdk) ? "${REGISTRY}/${orgrepo(type)}:alpine${ALPINE_SHORT_TAG}" : "",
is_default_jdk(jdk) ? "${REGISTRY}/${orgrepo(type)}:latest-alpine" : "",
is_default_jdk(jdk) ? "${REGISTRY}/${orgrepo(type)}:latest-alpine${ALPINE_SHORT_TAG}" : "",
"${REGISTRY}/${orgrepo(type)}:alpine-jdk${jdk}",
"${REGISTRY}/${orgrepo(type)}:alpine${ALPINE_SHORT_TAG}-jdk${jdk}",
"${REGISTRY}/${orgrepo(type)}:latest-alpine-jdk${jdk}",
"${REGISTRY}/${orgrepo(type)}:latest-alpine${ALPINE_SHORT_TAG}-jdk${jdk}",
]
platforms = ["linux/amd64", "linux/arm64", "linux/arm/v7", "linux/s390x", "linux/ppc64le"]
platforms = alpine_platforms(jdk)
}

target "debian_jdk17" {
target "debian" {
matrix = {
type = ["agent", "inbound-agent"]
jdk = [11, 17, 21]
}
name = "${type}_debian_jdk17"
name = "${type}_debian_${jdk}"
target = type
dockerfile = "debian/Dockerfile"
context = "."
args = {
JAVA_VERSION = JAVA17_VERSION
VERSION = REMOTING_VERSION
DEBIAN_RELEASE = DEBIAN_RELEASE
JAVA_VERSION = "${javaversion(jdk)}"
}
tags = [
equal(ON_TAG, "true") ? "${REGISTRY}/${orgrepo(type)}:${REMOTING_VERSION}-${BUILD_NUMBER}" : "",
equal(ON_TAG, "true") ? "${REGISTRY}/${orgrepo(type)}:${REMOTING_VERSION}-${BUILD_NUMBER}-jdk17" : "",
"${REGISTRY}/${orgrepo(type)}:bookworm",
"${REGISTRY}/${orgrepo(type)}:bookworm-jdk17",
"${REGISTRY}/${orgrepo(type)}:jdk17",
"${REGISTRY}/${orgrepo(type)}:latest",
"${REGISTRY}/${orgrepo(type)}:latest-bookworm",
"${REGISTRY}/${orgrepo(type)}:latest-bookworm-jdk17",
"${REGISTRY}/${orgrepo(type)}:latest-jdk17",
# If there is a tag, add versioned tag suffixed by the jdk
equal(ON_TAG, "true") ? "${REGISTRY}/${orgrepo(type)}:${REMOTING_VERSION}-${BUILD_NUMBER}-jdk${jdk}" : "",
# If there is a tag and if the jdk is the default one, add versioned short tag
equal(ON_TAG, "true") ? (is_default_jdk(jdk) ? "${REGISTRY}/${orgrepo(type)}:${REMOTING_VERSION}-${BUILD_NUMBER}" : "") : "",
# If the jdk is the default one, add Debian and latest short tags
is_default_jdk(jdk) ? "${REGISTRY}/${orgrepo(type)}:bookworm" : "",
is_default_jdk(jdk) ? "${REGISTRY}/${orgrepo(type)}:latest" : "",
is_default_jdk(jdk) ? "${REGISTRY}/${orgrepo(type)}:latest-bookworm" : "",
"${REGISTRY}/${orgrepo(type)}:bookworm-jdk${jdk}",
"${REGISTRY}/${orgrepo(type)}:jdk${jdk}",
"${REGISTRY}/${orgrepo(type)}:latest-bookworm-jdk${jdk}",
"${REGISTRY}/${orgrepo(type)}:latest-jdk${jdk}",
]
platforms = ["linux/amd64", "linux/arm64", "linux/arm/v7", "linux/ppc64le"]
platforms = debian_platforms(jdk)
}

target "debian_jdk21" {
matrix = {
type = ["agent", "inbound-agent"]
}
name = "${type}_debian_jdk21"
target = type
dockerfile = "debian/Dockerfile"
target "agent_archlinux_jdk11" {
dockerfile = "archlinux/Dockerfile"
context = "."
args = {
JAVA_VERSION = JAVA21_VERSION
VERSION = REMOTING_VERSION
DEBIAN_RELEASE = DEBIAN_RELEASE
JAVA_VERSION = JAVA11_VERSION
VERSION = REMOTING_VERSION
}
tags = [
equal(ON_TAG, "true") ? "${REGISTRY}/${orgrepo(type)}:${REMOTING_VERSION}-${BUILD_NUMBER}-jdk21" : "",
"${REGISTRY}/${orgrepo(type)}:bookworm-jdk21",
"${REGISTRY}/${orgrepo(type)}:jdk21",
"${REGISTRY}/${orgrepo(type)}:latest-bookworm-jdk21",
"${REGISTRY}/${orgrepo(type)}:latest-jdk21",
equal(ON_TAG, "true") ? "${REGISTRY}/${orgrepo("agent")}:${REMOTING_VERSION}-${BUILD_NUMBER}-archlinux" : "",
equal(ON_TAG, "true") ? "${REGISTRY}/${orgrepo("agent")}:${REMOTING_VERSION}-${BUILD_NUMBER}-archlinux-jdk11" : "",
"${REGISTRY}/${orgrepo("agent")}:archlinux",
"${REGISTRY}/${orgrepo("agent")}:latest-archlinux",
"${REGISTRY}/${orgrepo("agent")}:archlinux-jdk11",
"${REGISTRY}/${orgrepo("agent")}:latest-archlinux-jdk11",
]
platforms = ["linux/amd64", "linux/arm64", "linux/ppc64le", "linux/s390x"]
platforms = ["linux/amd64"]
}

target "debian_jdk21_preview" {
Expand Down

0 comments on commit d0dc008

Please sign in to comment.