-
Notifications
You must be signed in to change notification settings - Fork 0
/
devcontainer-bake.hcl
57 lines (51 loc) · 1.54 KB
/
devcontainer-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
// This file prepares only basic target configurations, handling the default base_contexts and output.
// All other config for a target must be overridden by accompanying bake files.
// It also configures a default group with each target listed.
variable "DEVCONTAINER_CACHE_FROMS" {
default = ""
}
variable "DEVCONTAINER_CACHE_TOS" {
default = ""
}
variable "DEVCONTAINER_OUTPUTS" {
default = ""
}
target "layer" {
name = "${layer.name}"
matrix = {
layer = [
for index, input_layer in devcontainer_layers: {
name = input_layer,
index = index
}
]
}
// Apply the contexts from options and context
contexts = { // Establish default base_context from layer order
base_context = (
// A default base_context can be inferred only for the second layer and later
layer.index >= 1
? "target:${element(devcontainer_layers, layer.index - 1)}"
: "no_base_context_provided"
)
}
// Apply cache args from the devcontainer context
cache-from = [
for cache_from in split(" ", trimspace("${DEVCONTAINER_CACHE_FROMS}")):
"${cache_from}-${layer.name}"
]
cache-to = [
for cache_to in split(" ", trimspace("${DEVCONTAINER_CACHE_TOS}")):
"${cache_to}-${layer.name}"
]
// Apply the default output to the final layer
output = (
layer.index == length(devcontainer_layers) - 1
? split(" ", trimspace("${DEVCONTAINER_OUTPUTS}"))
: null
)
}
group "default" {
// Target the last layer as default
targets = [devcontainer_layers[length(devcontainer_layers) - 1]]
}