-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdocker-bake.hcl
130 lines (122 loc) · 2.78 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
# Global variables
variable "CI_REGISTRY_IMAGE" {
default = "registry.gitlab.syncad.com/hive/haf_block_explorer"
}
variable "CI_COMMIT_TAG" {
default = ""
}
variable "CI_COMMIT_BRANCH" {
default = "develop"
}
variable "CI_DEFAULT_BRANCH" {
default = "develop"
}
variable "TAG" {
default = "latest"
}
variable "TAG_CI" {
default = "docker-24.0.1-4"
}
variable "PSQL_CLIENT_VERSION" {
default = "14-1"
}
variable "BUILD_TIME" {
default = "${timestamp()}"
}
variable "GIT_COMMIT_SHA" {
default = "[unknown]"
}
variable "GIT_CURRENT_BRANCH" {
default = "[unknown]"
}
variable "GIT_LAST_LOG_MESSAGE" {
default = "[unknown]"
}
variable "GIT_LAST_COMMITTER" {
default = "[unknown]"
}
variable "GIT_LAST_COMMIT_DATE" {
default = "[unknown]"
}
# Functions
function "notempty" {
params = [variable]
result = notequal("", variable)
}
function "registry-name" {
params = [name, suffix]
result = notempty(suffix) ? "${CI_REGISTRY_IMAGE}/${name}/${suffix}" : "${CI_REGISTRY_IMAGE}/${name}"
}
# Target groups
group "default" {
targets = ["full"]
}
# Targets
## Locally tag image with "$TAG",
## which is "latest" by default
target "full" {
dockerfile = "Dockerfile"
target = "full"
tags = [
"${CI_REGISTRY_IMAGE}:${TAG}"
]
args = {
BUILD_TIME = "${BUILD_TIME}",
GIT_COMMIT_SHA = "${GIT_COMMIT_SHA}",
GIT_CURRENT_BRANCH = "${GIT_CURRENT_BRANCH}",
GIT_LAST_LOG_MESSAGE = "${GIT_LAST_LOG_MESSAGE}",
GIT_LAST_COMMITTER = "${GIT_LAST_COMMITTER}",
GIT_LAST_COMMIT_DATE = "${GIT_LAST_COMMIT_DATE}",
PSQL_CLIENT_VERSION = "${PSQL_CLIENT_VERSION}",
}
platforms = [
"linux/amd64"
]
output = [
"type=docker"
]
}
## On default branch, tag image with "latest" and commit hash,
## on any other branch tag image with just commit hash
target "full-ci" {
inherits = ["full"]
cache-from = [
"type=registry,ref=${registry-name("cache", "")}:${PSQL_CLIENT_VERSION}"
]
cache-to = [
"type=registry,mode=max,ref=${registry-name("cache", "")}:${PSQL_CLIENT_VERSION}"
]
tags = [
"${CI_REGISTRY_IMAGE}:${TAG}",
equal(CI_COMMIT_BRANCH, CI_DEFAULT_BRANCH) ? "${CI_REGISTRY_IMAGE}:latest": "",
notempty(CI_COMMIT_TAG) ? "${CI_REGISTRY_IMAGE}:${CI_COMMIT_TAG}": ""
]
output = [
"type=registry"
]
}
target "ci-runner" {
dockerfile = "Dockerfile"
context = "docker/ci"
tags = [
"${registry-name("ci-runner", "")}:${TAG_CI}"
]
output = [
"type=docker"
]
}
target "ci-runner-ci" {
inherits = ["ci-runner"]
cache-from = [
"type=registry,ref=${registry-name("ci-runner", "cache")}:${TAG_CI}"
]
cache-to = [
"type=registry,mode=max,image-manifest=true,ref=${registry-name("ci-runner", "cache")}:${TAG_CI}"
]
tags = [
"${registry-name("ci-runner", "")}:${TAG_CI}"
]
output = [
"type=registry"
]
}