-
Notifications
You must be signed in to change notification settings - Fork 28
Expand file tree
/
Copy pathdocker-bake.hcl
More file actions
132 lines (116 loc) · 4.94 KB
/
docker-bake.hcl
File metadata and controls
132 lines (116 loc) · 4.94 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
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 = ""
}
variable "distributions" {
default = [
"bookworm",
"trixie"
]
}
variable "pgVersions" {
default = [
"18"
]
}
fullname = ( environment == "testing") ? "${registry}/${metadata.image_name}-testing" : "${registry}/${metadata.image_name}"
now = timestamp()
authors = "The CloudNativePG Contributors"
url = "https://github.com/cloudnative-pg/postgres-extensions-containers"
target "default" {
matrix = {
pgVersion = pgVersions
distro = distributions
}
platforms = [
"linux/amd64",
"linux/arm64"
]
dockerfile = "Dockerfile"
context = "${metadata.name}/"
name = "${metadata.name}-${sanitize(getExtensionVersion(distro, pgVersion))}-${pgVersion}-${distro}"
tags = [
"${getImageName(fullname)}:${getExtensionVersion(distro, pgVersion)}-${pgVersion}-${distro}",
"${getImageName(fullname)}:${getExtensionVersion(distro, pgVersion)}-${formatdate("YYYYMMDDhhmm", now)}-${pgVersion}-${distro}",
]
args = {
PG_MAJOR = "${pgVersion}"
EXT_VERSION = "${getExtensionPackage(distro, pgVersion)}"
BASE = "${getBaseImage(distro, pgVersion)}"
}
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=${getExtensionVersion(distro, pgVersion)}",
"index,manifest:org.opencontainers.image.revision=${revision}",
"index,manifest:org.opencontainers.image.vendor=${authors}",
"index,manifest:org.opencontainers.image.title=${metadata.name} ${getExtensionVersion(distro, pgVersion)} ${pgVersion} ${distro}",
"index,manifest:org.opencontainers.image.description=A ${metadata.name} ${getExtensionVersion(distro, pgVersion)} container image for PostgreSQL ${pgVersion} on ${distro}",
"index,manifest:org.opencontainers.image.documentation=${url}",
"index,manifest:org.opencontainers.image.authors=${authors}",
"index,manifest:org.opencontainers.image.licenses=${join(" AND ", metadata.licenses)}",
"index,manifest:org.opencontainers.image.base.name=scratch",
"index,manifest:io.cloudnativepg.image.base.name=${getBaseImage(distro, pgVersion)}",
"index,manifest:io.cloudnativepg.image.base.pgmajor=${pgVersion}",
"index,manifest:io.cloudnativepg.image.base.os=${distro}",
"index,manifest:io.cloudnativepg.image.sql.version=${getExtensionSqlVersion(distro, pgVersion)}",
]
labels = {
"org.opencontainers.image.created" = "${now}",
"org.opencontainers.image.url" = "${url}",
"org.opencontainers.image.source" = "${url}",
"org.opencontainers.image.version" = "${getExtensionVersion(distro, pgVersion)}",
"org.opencontainers.image.revision" = "${revision}",
"org.opencontainers.image.vendor" = "${authors}",
"org.opencontainers.image.title" = "${metadata.name} ${getExtensionVersion(distro, pgVersion)} ${pgVersion} ${distro}",
"org.opencontainers.image.description" = "A ${metadata.name} ${getExtensionVersion(distro, pgVersion)} container image for PostgreSQL ${pgVersion} on ${distro}",
"org.opencontainers.image.documentation" = "${url}",
"org.opencontainers.image.authors" = "${authors}",
"org.opencontainers.image.licenses" = "${join(" AND ", metadata.licenses)}",
"org.opencontainers.image.base.name" = "scratch",
"io.cloudnativepg.image.base.name" = "${getBaseImage(distro, pgVersion)}",
"io.cloudnativepg.image.base.pgmajor" = "${pgVersion}",
"io.cloudnativepg.image.base.os" = "${distro}",
"io.cloudnativepg.image.sql.version" = "${getExtensionSqlVersion(distro, pgVersion)}",
}
}
function getImageName {
params = [ name ]
result = lower(name)
}
function getExtensionPackage {
params = [ distro, pgVersion ]
result = metadata.versions[distro][pgVersion]["package"]
}
function getExtensionSqlVersion {
params = [ distro, pgVersion ]
result = lookup(metadata.versions[distro][pgVersion], "sql", "")
}
// Parse the packageVersion to extract the MM.mm.pp extension version.
// We capture the first digit, and then zero or more sequences of ".digits". (e.g 0.8.1-2.pgdg13+1 -> 0.8.1)
// If the package starts with an epoch, we use it and replace the ":" with a "-" (e.g 1:6.1.0-2.pgdg130+1 -> 1-6.1.0)
function getExtensionVersion {
params = [ distro, pgVersion ]
result = replace(
regex("^(?:[0-9]+:)?[0-9]+(?:\\.[0-9]+)*", getExtensionPackage(distro, pgVersion)),
":", "-")
}
function getBaseImage {
params = [ distro, pgVersion ]
result = format("ghcr.io/cloudnative-pg/postgresql:%s-minimal-%s", pgVersion, distro)
}