-
Notifications
You must be signed in to change notification settings - Fork 2
/
docker-bake.hcl
118 lines (101 loc) · 3.14 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 = [
"imagemagick",
]
}
group "amd64" {
targets = [
"imagemagick-amd64",
]
}
group "arm64" {
targets = [
"imagemagick-arm64",
]
}
# CI should build both and push to the remote cache.
group "ci" {
targets = [
"imagemagick-amd64-ci",
"imagemagick-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 "imagemagick-common" {
inherits = ["common"]
context = "imagemagick"
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 "imagemagick-amd64" {
inherits = ["imagemagick-common"]
tags = tags("imagemagick", "amd64")
cache-from = cacheFrom("imagemagick", "amd64")
platforms = ["linux/amd64"]
}
target "imagemagick-amd64-ci" {
inherits = ["imagemagick-amd64"]
cache-to = cacheTo("imagemagick", "amd64")
}
target "imagemagick-arm64" {
inherits = ["imagemagick-common"]
tags = tags("imagemagick", "arm64")
cache-from = cacheFrom("imagemagick", "arm64")
platforms = ["linux/arm64"]
}
target "imagemagick-arm64-ci" {
inherits = ["imagemagick-arm64"]
cache-to = cacheTo("imagemagick", "arm64")
}
target "imagemagick" {
inherits = ["imagemagick-common"]
cache-from = cacheFrom("imagemagick", hostArch())
tags = tags("imagemagick", "")
}