forked from cloudnative-pg/cloudnative-pg
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdocker-bake.hcl
149 lines (129 loc) · 4.37 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
#
# Copyright The CloudNativePG Contributors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
variable "environment" {
default = "testing"
validation {
condition = contains(["testing", "production"], environment)
error_message = "environment must be either testing or production"
}
}
variable "registry" {
default = "localhost:5000"
}
variable "insecure" {
default = "false"
}
variable "latest" {
default = "false"
}
variable "tag" {
default = "dev"
}
variable "buildVersion" {
default = "dev"
}
variable "revision" {
default = ""
}
suffix = (environment == "testing") ? "-testing" : ""
title = "CloudNativePG Operator"
description = "This Docker image contains CloudNativePG Operator."
authors = "The CloudNativePG Contributors"
url = "https://github.com/cloudnative-pg/cloudnative-pg"
documentation = "https://cloudnative-pg.io/documentation/current/"
license = "Apache-2.0"
now = timestamp()
distros = {
distroless = {
baseImage = "gcr.io/distroless/static-debian12:nonroot@sha256:6ec5aa99dc335666e79dc64e4a6c8b89c33a543a1967f20d360922a80dd21f02",
tag = ""
}
ubi = {
baseImage = "registry.access.redhat.com/ubi9/ubi-micro:latest@sha256:7e85855f6925e03f91b5c51f07886ff1c18c6ec69b5fc65491428a899da914a2",
tag = "-ubi9"
}
}
target "default" {
matrix = {
distro = [
"distroless",
"ubi"
]
}
name = "${distro}"
platforms = ["linux/amd64", "linux/arm64"]
tags = [
"${registry}/cloudnative-pg${suffix}:${tag}${distros[distro].tag}",
latest("${registry}/cloudnative-pg${suffix}", "${latest}"),
]
dockerfile = "Dockerfile"
context = "."
args = {
BASE = "${distros[distro].baseImage}"
}
output = [
"type=image,registry.insecure=${insecure}",
]
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=${buildVersion}",
"index,manifest:org.opencontainers.image.revision=${revision}",
"index,manifest:org.opencontainers.image.vendor=${authors}",
"index,manifest:org.opencontainers.image.title=${title}",
"index,manifest:org.opencontainers.image.description=${description}",
"index,manifest:org.opencontainers.image.documentation=${documentation}",
"index,manifest:org.opencontainers.image.authors=${authors}",
"index,manifest:org.opencontainers.image.licenses=${license}",
"index,manifest:org.opencontainers.image.base.name=${distros[distro].baseImage}",
"index,manifest:org.opencontainers.image.base.digest=${digest(distros[distro].baseImage)}",
]
labels = {
"org.opencontainers.image.created" = "${now}",
"org.opencontainers.image.url" = "${url}",
"org.opencontainers.image.source" = "${url}",
"org.opencontainers.image.version" = "${buildVersion}",
"org.opencontainers.image.revision" = "${revision}",
"org.opencontainers.image.vendor" = "${authors}",
"org.opencontainers.image.title" = "${title}",
"org.opencontainers.image.description" = "${description}",
"org.opencontainers.image.documentation" = "${documentation}",
"org.opencontainers.image.authors" = "${authors}",
"org.opencontainers.image.licenses" = "${license}",
"org.opencontainers.image.base.name" = "${distros[distro].baseImage}",
"org.opencontainers.image.base.digest" = "${digest(distros[distro].baseImage)}",
"name" = "${title}",
"maintainer" = "${authors}",
"vendor" = "${authors}",
"version" = "${buildVersion}",
"release" = "1",
"description" = "${description}",
"summary" = "${description}",
}
}
function digest {
params = [ imageNameWithSha ]
result = index(split("@", imageNameWithSha), 1)
}
function latest {
params = [ image, latest ]
result = (latest == "true") ? "${image}:latest" : ""
}