-
Notifications
You must be signed in to change notification settings - Fork 56
Expand file tree
/
Copy pathdocker-bake.hcl
More file actions
192 lines (173 loc) · 6.6 KB
/
docker-bake.hcl
File metadata and controls
192 lines (173 loc) · 6.6 KB
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
189
190
191
192
variable "environment" {
default = "testing"
validation {
condition = contains(["testing", "production"], environment)
error_message = "environment must be either testing or production"
}
}
variable "registry" {
default = "localhost:5000"
}
// Use the revision variable to identify the commit that generated the image
variable "revision" {
default = ""
}
fullname = ( environment == "testing") ? "${registry}/postgresql-testing" : "${registry}/postgresql"
now = timestamp()
authors = "The CloudNativePG Contributors"
url = "https://github.com/cloudnative-pg/postgres-containers"
// PostgreSQL versions to build
postgreSQLVersions = [
"14.22",
"15.17",
"16.13",
"17.9",
"18.3"
]
// PostgreSQL preview versions to build, such as "18~beta1" or "18~rc1"
// Preview versions are automatically filtered out if present in the stable list
// MANUALLY EDIT THE CONTENT - AND UPDATE THE README.md FILE TOO
postgreSQLPreviewVersions = [
]
// Barman version to build
// renovate: datasource=pypi versioning=loose depName=barman
barmanVersion = "3.17.0"
// Extensions to be included in the `standard` image
extensions = [
"pgaudit",
"pgvector",
"pg-failover-slots"
]
target "default" {
matrix = {
tgt = [
"minimal",
"standard",
"system"
]
// Get the list of PostgreSQL versions, filtering preview versions if already stable
pgVersion = getPgVersions(postgreSQLVersions, postgreSQLPreviewVersions)
base = [
// renovate: datasource=docker versioning=loose
"debian:trixie-slim@sha256:1d3c811171a08a5adaa4a163fbafd96b61b87aa871bbc7aa15431ac275d3d430",
// renovate: datasource=docker versioning=loose
"debian:bookworm-slim@sha256:74d56e3931e0d5a1dd51f8c8a2466d21de84a271cd3b5a733b803aa91abf4421",
// renovate: datasource=docker versioning=loose
"debian:bullseye-slim@sha256:4333240150a6924f878e05ec2c998aec95238010e0e4d2fec6161c90128c4652"
]
}
platforms = [
"linux/amd64",
"linux/arm64"
]
dockerfile = "Dockerfile"
name = "postgresql-${index(split(".",cleanVersion(pgVersion)),0)}-${tgt}-${distroVersion(base)}"
tags = concat([
"${fullname}:${index(split(".",cleanVersion(pgVersion)),0)}-${tgt}-${distroVersion(base)}",
"${fullname}:${cleanVersion(pgVersion)}-${tgt}-${distroVersion(base)}",
"${fullname}:${cleanVersion(pgVersion)}-${formatdate("YYYYMMDDhhmm", now)}-${tgt}-${distroVersion(base)}",
], (tgt == "system" && distroVersion(base) == "bullseye" && isPreview(pgVersion) == false) ? getRollingTags("${fullname}", pgVersion) : [])
context = "."
target = "${tgt}"
args = {
PG_VERSION = "${pgVersion}"
PG_MAJOR = "${getMajor(pgVersion)}"
BASE = "${base}"
EXTENSIONS = "${getExtensionsString(pgVersion, extensions)}"
STANDARD_ADDITIONAL_POSTGRES_PACKAGES = "${getStandardAdditionalPostgresPackagesPerMajorVersion(getMajor(pgVersion))}"
BARMAN_VERSION = "${barmanVersion}"
}
attest = [
"type=provenance,mode=max",
"type=sbom"
]
annotations = [
"index,manifest:org.opencontainers.image.created=${now}",
"index,manifest:org.opencontainers.image.url=${url}",
"index,manifest:org.opencontainers.image.source=${url}",
"index,manifest:org.opencontainers.image.version=${pgVersion}",
"index,manifest:org.opencontainers.image.revision=${revision}",
"index,manifest:org.opencontainers.image.vendor=${authors}",
"index,manifest:org.opencontainers.image.title=CloudNativePG PostgreSQL ${pgVersion} ${tgt}",
"index,manifest:org.opencontainers.image.description=A ${tgt} PostgreSQL ${pgVersion} container image",
"index,manifest:org.opencontainers.image.documentation=${url}",
"index,manifest:org.opencontainers.image.authors=${authors}",
"index,manifest:org.opencontainers.image.licenses=Apache-2.0",
"index,manifest:org.opencontainers.image.base.name=docker.io/library/debian:${tag(base)}",
"index,manifest:org.opencontainers.image.base.digest=${digest(base)}"
]
labels = {
"org.opencontainers.image.created" = "${now}",
"org.opencontainers.image.url" = "${url}",
"org.opencontainers.image.source" = "${url}",
"org.opencontainers.image.version" = "${pgVersion}",
"org.opencontainers.image.revision" = "${revision}",
"org.opencontainers.image.vendor" = "${authors}",
"org.opencontainers.image.title" = "CloudNativePG PostgreSQL ${pgVersion} ${tgt}",
"org.opencontainers.image.description" = "A ${tgt} PostgreSQL ${pgVersion} container image",
"org.opencontainers.image.documentation" = "${url}",
"org.opencontainers.image.authors" = "${authors}",
"org.opencontainers.image.licenses" = "Apache-2.0"
"org.opencontainers.image.base.name" = "docker.io/library/debian:${tag(base)}"
"org.opencontainers.image.base.digest" = "${digest(base)}"
}
}
function tag {
params = [ imageNameWithSha ]
result = index(split("@", index(split(":", imageNameWithSha), 1)), 0)
}
function distroVersion {
params = [ imageNameWithSha ]
result = index(split("-", tag(imageNameWithSha)), 0)
}
function digest {
params = [ imageNameWithSha ]
result = index(split("@", imageNameWithSha), 1)
}
function cleanVersion {
params = [ version ]
result = replace(version, "~", "")
}
function isPreview {
params = [ version ]
result = length(regexall("[0-9]+~(alpha|beta|rc).*", version)) > 0
}
function getMajor {
params = [ version ]
result = (isPreview(version) == true) ? index(split("~", version),0) : index(split(".", version),0)
}
function getExtensionsString {
params = [ version, extensions ]
result = (isPreview(version) == true) ? "" : join(" ", formatlist("postgresql-%s-%s", getMajor(version), extensions))
}
// This function conditionally adds recommended PostgreSQL packages based on
// the version. For example, starting with version 18, PGDG moved `jit` out of
// the main package and into a separate one.
function getStandardAdditionalPostgresPackagesPerMajorVersion {
params = [ majorVersion ]
// Add PostgreSQL jit package from version 18
result = join(" ", [
majorVersion < 18 ? "" : format("postgresql-%s-jit", majorVersion)
])
}
function isMajorPresent {
params = [major, pgVersions]
result = contains([for v in pgVersions : getMajor(v)], major)
}
function getPgVersions {
params = [stableVersions, previewVersions]
// Remove any preview version if already present as stable
result = concat(stableVersions,
[
for v in previewVersions : v
if !isMajorPresent(getMajor(v), stableVersions)
]
)
}
function getRollingTags {
params = [ imageName, pgVersion ]
result = [
format("%s:%s", imageName, pgVersion),
format("%s:%s", imageName, getMajor(pgVersion))
]
}