-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdocker-bake.hcl
More file actions
118 lines (97 loc) · 3.35 KB
/
docker-bake.hcl
File metadata and controls
118 lines (97 loc) · 3.35 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
group "default" {
targets = ["prd","dev"]
}
variable "EMS_VERSION" {
default = "7.x-dev"
}
variable "DOCKER_IMAGE_NAME" {
default = "elasticms/cli"
}
variable "DOCKER_IMAGE_TAG" {
default = "snapshot"
}
variable "TIKA_VERSION" {
default = "2.9.2"
}
variable "PHP_EXT_SQLSRV_VERSION" {
default = "5.12.0"
}
variable "DOCKER_IMAGE_LATEST" {
default = true
}
variable "GIT_HASH" {}
function "tag" {
params = [version, tgt, githash]
result = [
version == "" ? "" : "${DOCKER_IMAGE_NAME}:${version}${tgt == "dev" ? "-dev" : ""}${githash == "" ? "" : "-${githash}"}",
]
}
# cleanTag ensures that the tag is a valid Docker tag
# see https://github.com/distribution/distribution/blob/v2.8.2/reference/regexp.go#L37
function "clean_tag" {
params = [tag]
result = substr(regex_replace(regex_replace(tag, "[^\\w.-]", "-"), "^([^\\w])", "r$0"), 0, 127)
}
# semver adds semver-compliant tag if a semver version number is passed, or returns the revision itself
# see https://semver.org/#is-there-a-suggested-regular-expression-regex-to-check-a-semver-string
function "semver" {
params = [rev]
result = __semver(_semver(regexall("^v?(?P<major>0|[1-9]\\d*)\\.(?P<minor>0|[1-9]\\d*)\\.(?P<patch>0|[1-9]\\d*)(?:-(?P<prerelease>(?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\\.(?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\\+(?P<buildmetadata>[0-9a-zA-Z-]+(?:\\.[0-9a-zA-Z-]+)*))?$", rev)))
}
function "_semver" {
params = [matches]
result = length(matches) == 0 ? {} : matches[0]
}
function "__semver" {
params = [v]
result = v == {} ? [clean_tag(DOCKER_IMAGE_TAG)] : v.prerelease == null ? [v.major, "${v.major}.${v.minor}", "${v.major}.${v.minor}.${v.patch}"] : ["${v.major}.${v.minor}.${v.patch}-${v.prerelease}"]
}
target "default" {
name = "${tgt}"
matrix = {
tgt = ["prd","dev"]
}
context = "."
dockerfile = "Dockerfile"
target = "${tgt}"
platforms = [
"linux/amd64",
"linux/arm64"
]
args = {
TIKA_VERSION_ARG = "${TIKA_VERSION}"
PHP_EXT_SQLSRV_VERSION_ARG = "${PHP_EXT_SQLSRV_VERSION}"
}
labels = {
"org.opencontainers.image.created" = "${timestamp()}"
"org.opencontainers.image.title" = "elasticMS CLI"
"org.opencontainers.image.description" = "CLI of the elasticMS suite."
"org.opencontainers.image.url" = "https://www.elasticms.fgov.be"
"org.opencontainers.image.source" = "https://github.com/ems-project/elasticms-cli"
"org.opencontainers.image.version" = EMS_VERSION
"org.opencontainers.image.revision" = GIT_HASH
"org.opencontainers.image.vendor" = "elasticMS"
"org.opencontainers.image.licenses" = "LGPL-3.0"
"be.fgov.elasticms.product" = "elasticms"
"be.fgov.elasticms.component" = "cli"
"be.fgov.elasticms.environment" = tgt
"be.fgov.elasticms.schema-version" = "1.0"
}
tags = distinct(flatten([
DOCKER_IMAGE_LATEST ? tag("latest", tgt, "") : [],
GIT_HASH != "" && DOCKER_IMAGE_TAG != "snapshot" ? tag(clean_tag(DOCKER_IMAGE_TAG), tgt, "${substr(GIT_HASH, 0, 7)}") : [],
DOCKER_IMAGE_TAG == "snapshot"
? [tag("snapshot", tgt, "")]
: [for v in semver(DOCKER_IMAGE_TAG) : tag(v, tgt, "")]
])
)
attest = [
{
type = "provenance"
mode = "max"
},
{
type = "sbom"
}
]
}