Skip to content

Commit aaab094

Browse files
add cache images
1 parent 06fb4ac commit aaab094

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

k8/Makefile

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,13 @@ version = $(shell cat images/$(1)/version)
1414

1515
BASE_IMAGE := ${IMAGE}/base:${PYTHON_PACKAGE_VERSION}-$(call version,base)
1616

17+
BASE_CACHE_IMAGE := ${IMAGE}/base:cache
18+
1719
$(info Base image = ${BASE_IMAGE})
1820

1921
sub_tag = $(1):${PYTHON_PACKAGE_VERSION}-$(call version,base)-$(call version,$(1))
2022
sub_image = ${IMAGE}/$(call sub_tag,$(1))
23+
sub_cache_image = ${IMAGE}/$(1):cache
2124

2225
WORKFLOW_VERSION := $(shell cat argo/version)
2326
$(info Workflow version = ${WORKFLOW_VERSION})
@@ -120,11 +123,12 @@ define JQ_DOCKER_BAKE
120123
{
121124
"base-base": {
122125
dockerfile: "Dockerfile",
123-
"cache-to": ["type=local,dest=./cache"]
124126
},
125127
base: {
126128
context: "images/base",
127129
inherits: ["base-base"],
130+
"cache-to": ["type=registry,ref=${BASE_CACHE_IMAGE},mode=max"],
131+
"cache-from": ["type=registry,ref=${BASE_CACHE_IMAGE}"],
128132
args: {
129133
PYTHON_PACKAGE_VERSION: "${PYTHON_PACKAGE_VERSION}"
130134
},
@@ -143,6 +147,8 @@ define JQ_DOCKER_BAKE
143147
args: {
144148
FROM: "${BASE_IMAGE}"
145149
},
150+
"cache-to": ["type=registry,ref=" + ($$ARGS.named[(. + "-cache")]) + ",mode=max"],
151+
"cache-from": ["type=registry,ref=" + ($$ARGS.named[(. + "-cache")])],
146152
tags: [
147153
($$ARGS.named[(.)])
148154
]
@@ -161,6 +167,7 @@ docker-bake.json: Makefile
161167
jq "$$JQ_DOCKER_BAKE" \
162168
--null-input \
163169
$(foreach name,$(IMAGES),--arg $(name) $(call sub_image,$(name))) \
170+
$(foreach name,$(IMAGES),--arg $(name)-cache $(call sub_cache_image,$(name))) \
164171
--args $(IMAGES) \
165172
> $@
166173

0 commit comments

Comments
 (0)