forked from jenkinsci/docker-ssh-agent
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdocker-bake.hcl
188 lines (165 loc) · 4.84 KB
/
docker-bake.hcl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
group "linux" {
targets = [
"alpine",
"debian",
"debian_jdk21-preview",
]
}
group "linux-arm64" {
targets = [
"debian",
"alpine_jdk21",
]
}
group "linux-arm32" {
targets = [
"debian_jdk21-preview",
]
}
group "linux-s390x" {
targets = [
"debian_jdk11",
"debian_jdk21"
]
}
group "linux-ppc64le" {
targets = [
"debian"
]
}
variable "REGISTRY" {
default = "docker.io"
}
variable "JENKINS_REPO" {
default = "jenkins/ssh-agent"
}
variable "ON_TAG" {
default = "false"
}
variable "VERSION" {
default = ""
}
variable "ALPINE_FULL_TAG" {
default = "3.19.1"
}
variable "ALPINE_SHORT_TAG" {
default = regex_replace(ALPINE_FULL_TAG, "\\.\\d+$", "")
}
variable "JAVA11_VERSION" {
default = "11.0.23_9"
}
variable "JAVA17_VERSION" {
default = "17.0.11_9"
}
variable "JAVA21_VERSION" {
default = "21.0.3_9"
}
variable "JAVA21_PREVIEW_VERSION" {
default = "21.0.1+12"
}
variable "DEBIAN_RELEASE" {
default = "bookworm-20240513"
}
variable "default_jdk" {
default = 17
}
# 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"
}
# 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(17, jdk)
? ["linux/amd64", "linux/arm64", "linux/ppc64le"]
: ["linux/amd64", "linux/arm64", "linux/ppc64le", "linux/s390x"])
}
target "alpine" {
matrix = {
jdk = [11, 17, 21]
}
name = "alpine_${jdk}"
dockerfile = "alpine/Dockerfile"
context = "."
args = {
ALPINE_TAG = ALPINE_FULL_TAG
JAVA_VERSION = "${javaversion(jdk)}"
}
tags = [
# If there is a tag, add versioned tags suffixed by the jdk
equal(ON_TAG, "true") ? "${REGISTRY}/${JENKINS_REPO}:${VERSION}-alpine-jdk${jdk}" : "",
equal(ON_TAG, "true") ? "${REGISTRY}/${JENKINS_REPO}:${VERSION}-alpine${ALPINE_SHORT_TAG}-jdk${jdk}" : "",
# If the jdk is the default one, add Alpine short tags
is_default_jdk(jdk) ? "${REGISTRY}/${JENKINS_REPO}:alpine" : "",
is_default_jdk(jdk) ? "${REGISTRY}/${JENKINS_REPO}:alpine${ALPINE_SHORT_TAG}" : "",
is_default_jdk(jdk) ? "${REGISTRY}/${JENKINS_REPO}:latest-alpine${ALPINE_SHORT_TAG}" : "",
"${REGISTRY}/${JENKINS_REPO}:alpine-jdk${jdk}",
"${REGISTRY}/${JENKINS_REPO}:latest-alpine-jdk${jdk}",
"${REGISTRY}/${JENKINS_REPO}:alpine${ALPINE_SHORT_TAG}-jdk${jdk}",
"${REGISTRY}/${JENKINS_REPO}:latest-alpine${ALPINE_SHORT_TAG}-jdk${jdk}",
]
platforms = alpine_platforms(jdk)
}
target "debian" {
matrix = {
jdk = [11, 17, 21]
}
name = "debian_${jdk}"
dockerfile = "debian/Dockerfile"
context = "."
args = {
DEBIAN_RELEASE = DEBIAN_RELEASE
JAVA_VERSION = "${javaversion(jdk)}"
}
tags = [
# If there is a tag, add versioned tag suffixed by the jdk
equal(ON_TAG, "true") ? "${REGISTRY}/${JENKINS_REPO}:${VERSION}-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}/${JENKINS_REPO}:${VERSION}" : "") : "",
# If the jdk is the default one, add latest short tag
is_default_jdk(jdk) ? "${REGISTRY}/${JENKINS_REPO}:latest" : "",
"${REGISTRY}/${JENKINS_REPO}:bookworm-jdk${jdk}",
"${REGISTRY}/${JENKINS_REPO}:debian-jdk${jdk}",
"${REGISTRY}/${JENKINS_REPO}:jdk${jdk}",
"${REGISTRY}/${JENKINS_REPO}:latest-bookworm-jdk${jdk}",
"${REGISTRY}/${JENKINS_REPO}:latest-debian-jdk${jdk}",
"${REGISTRY}/${JENKINS_REPO}:latest-jdk${jdk}",
]
platforms = debian_platforms(jdk)
}
target "debian_jdk21-preview" {
dockerfile = "debian/preview/Dockerfile"
context = "."
args = {
JAVA_VERSION = JAVA21_PREVIEW_VERSION
DEBIAN_RELEASE = DEBIAN_RELEASE
}
tags = [
# If there is a tag, add the versioned tag suffixed by the jdk
equal(ON_TAG, "true") ? "${REGISTRY}/${JENKINS_REPO}:${VERSION}-jdk21-preview" : "",
"${REGISTRY}/${JENKINS_REPO}:bookworm-jdk21-preview",
"${REGISTRY}/${JENKINS_REPO}:debian-jdk21-preview",
"${REGISTRY}/${JENKINS_REPO}:jdk21-preview",
"${REGISTRY}/${JENKINS_REPO}:latest-bookworm-jdk21-preview",
"${REGISTRY}/${JENKINS_REPO}:latest-debian-jdk21-preview",
"${REGISTRY}/${JENKINS_REPO}:latest-jdk21-preview",
]
platforms = ["linux/arm/v7"]
}