-
Notifications
You must be signed in to change notification settings - Fork 0
/
docker-bake.hcl
118 lines (101 loc) · 3.09 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
variable "SOURCE_DATE_EPOCH" {
default = "0"
}
variable "REPOSITORY" {
default = "islandora"
}
variable "TAG" {
# "local" is to distinguish remote images from those produced locally.
default = "local"
}
###############################################################################
# Functions
###############################################################################
function hostArch {
params = []
result = equal("linux/amd64", BAKE_LOCAL_PLATFORM) ? "amd64" : "arm64" # Only two platforms supported.
}
function "tags" {
params = [image, arch]
result = ["${REPOSITORY}/${image}:${TAG}-${arch}"]
}
function "cacheFrom" {
params = [image, arch]
result = ["type=registry,ref=${REPOSITORY}/cache:${image}-main-${arch}", "type=registry,ref=${REPOSITORY}/cache:${image}-${TAG}-${arch}"]
}
function "cacheTo" {
params = [image, arch]
result = ["type=registry,oci-mediatypes=true,mode=max,compression=estargz,compression-level=5,ref=${REPOSITORY}/cache:${image}-${TAG}-${arch}"]
}
###############################################################################
# Groups
###############################################################################
group "default" {
targets = [
"leptonica",
]
}
group "amd64" {
targets = [
"leptonica-amd64",
]
}
group "arm64" {
targets = [
"leptonica-arm64",
]
}
# CI should build both and push to the remote cache.
group "ci" {
targets = [
"leptonica-amd64-ci",
"leptonica-arm64-ci",
]
}
###############################################################################
# Targets
###############################################################################
target "common" {
args = {
# Required for reproduciable builds.
# Requires Buildkit 0.11+
# See: https://reproducible-builds.org/docs/source-date-epoch/
SOURCE_DATE_EPOCH = "${SOURCE_DATE_EPOCH}",
}
}
target "leptonica-common" {
inherits = ["common"]
context = "leptonica"
contexts = {
# The digest (sha256 hash) is not platform specific but the digest for the manifest of all platforms.
# It will be the digest printed when you do: docker pull alpine:3.17.1
# Not the one displayed on DockerHub.
# N.B. This should match the value used in <https://github.com/Islandora-Devops/isle-buildkit>
alpine = "docker-image://alpine:3.20.2@sha256:0a4eaa0eecf5f8c050e5bba433f58c052be7587ee8af3e8b3910ef9ab5fbe9f5"
}
}
target "leptonica-amd64" {
inherits = ["leptonica-common"]
tags = tags("leptonica", "amd64")
cache-from = cacheFrom("leptonica", "amd64")
platforms = ["linux/amd64"]
}
target "leptonica-amd64-ci" {
inherits = ["leptonica-amd64"]
cache-to = cacheTo("leptonica", "amd64")
}
target "leptonica-arm64" {
inherits = ["leptonica-common"]
tags = tags("leptonica", "arm64")
cache-from = cacheFrom("leptonica", "arm64")
platforms = ["linux/arm64"]
}
target "leptonica-arm64-ci" {
inherits = ["leptonica-arm64"]
cache-to = cacheTo("leptonica", "arm64")
}
target "leptonica" {
inherits = ["leptonica-common"]
cache-from = cacheFrom("leptonica", hostArch())
tags = tags("leptonica", "")
}