Skip to content

Commit 20c14ed

Browse files
committed
Improve caching
1 parent 178899e commit 20c14ed

File tree

1 file changed

+56
-16
lines changed

1 file changed

+56
-16
lines changed

Makefile

Lines changed: 56 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -38,67 +38,102 @@ release:
3838
make -C services/app release
3939

4040
build-local:
41-
docker build --target assets-image \
41+
DOCKER_BUILDKIT=1 docker build --target assets-image \
4242
--file services/app/Containerfile.codebattle \
4343
--build-arg GIT_HASH=$(GIT_HASH) \
44+
--cache-from ghcr.io/hexlet-codebattle/codebattle:assets-image \
4445
--tag ghcr.io/hexlet-codebattle/codebattle:assets-image services/app
45-
docker build --target compile-image \
46+
DOCKER_BUILDKIT=1 docker build --target compile-image \
4647
--file services/app/Containerfile.codebattle \
4748
--build-arg GIT_HASH=$(GIT_HASH) \
49+
--cache-from ghcr.io/hexlet-codebattle/codebattle:assets-image \
50+
--cache-from ghcr.io/hexlet-codebattle/codebattle:compile-image \
4851
--tag ghcr.io/hexlet-codebattle/codebattle:compile-image services/app
49-
docker build --target nginx-assets \
52+
DOCKER_BUILDKIT=1 docker build --target nginx-assets \
5053
--file services/app/Containerfile.codebattle \
54+
--cache-from ghcr.io/hexlet-codebattle/codebattle:assets-image \
55+
--cache-from ghcr.io/hexlet-codebattle/codebattle:compile-image \
56+
--cache-from ghcr.io/hexlet-codebattle/nginx-assets:latest \
5157
--tag ghcr.io/hexlet-codebattle/nginx-assets:latest services/app
52-
docker build --target runtime-image \
58+
DOCKER_BUILDKIT=1 docker build --target runtime-image \
5359
--file services/app/Containerfile.codebattle \
5460
--build-arg GIT_HASH=$(GIT_HASH) \
61+
--cache-from ghcr.io/hexlet-codebattle/codebattle:compile-image \
62+
--cache-from ghcr.io/hexlet-codebattle/codebattle:latest \
5563
--tag ghcr.io/hexlet-codebattle/codebattle:latest services/app
56-
docker build --target compile-image \
64+
DOCKER_BUILDKIT=1 docker build --target compile-image \
5765
--file services/app/Containerfile.runner \
66+
--cache-from ghcr.io/hexlet-codebattle/runner:compile-image \
5867
--tag ghcr.io/hexlet-codebattle/runner:compile-image services/app
59-
docker build --target runtime-image \
68+
DOCKER_BUILDKIT=1 docker build --target runtime-image \
6069
--file services/app/Containerfile.runner \
70+
--cache-from ghcr.io/hexlet-codebattle/runner:compile-image \
71+
--cache-from ghcr.io/hexlet-codebattle/runner:latest \
6172
--tag ghcr.io/hexlet-codebattle/runner:latest services/app
6273

6374
build-codebattle:
6475
docker pull ghcr.io/hexlet-codebattle/codebattle:assets-image || true
6576
docker pull ghcr.io/hexlet-codebattle/codebattle:compile-image || true
6677
docker pull ghcr.io/hexlet-codebattle/codebattle:latest || true
67-
docker build --target assets-image \
78+
DOCKER_BUILDKIT=1 docker build --target assets-image \
6879
--file services/app/Containerfile.codebattle \
6980
--build-arg GIT_HASH=$(GIT_HASH) \
81+
--cache-from ghcr.io/hexlet-codebattle/codebattle:assets-image \
82+
--build-arg BUILDKIT_INLINE_CACHE=1 \
7083
--tag ghcr.io/hexlet-codebattle/codebattle:assets-image services/app
71-
docker build --target compile-image \
84+
DOCKER_BUILDKIT=1 docker build --target compile-image \
7285
--file services/app/Containerfile.codebattle \
7386
--build-arg GIT_HASH=$(GIT_HASH) \
87+
--cache-from ghcr.io/hexlet-codebattle/codebattle:assets-image \
88+
--cache-from ghcr.io/hexlet-codebattle/codebattle:compile-image \
89+
--build-arg BUILDKIT_INLINE_CACHE=1 \
7490
--tag ghcr.io/hexlet-codebattle/codebattle:compile-image services/app
75-
docker build --target nginx-assets \
91+
DOCKER_BUILDKIT=1 docker build --target nginx-assets \
7692
--file services/app/Containerfile.codebattle \
93+
--cache-from ghcr.io/hexlet-codebattle/codebattle:assets-image \
94+
--cache-from ghcr.io/hexlet-codebattle/codebattle:compile-image \
95+
--cache-from ghcr.io/hexlet-codebattle/nginx-assets:latest \
96+
--build-arg BUILDKIT_INLINE_CACHE=1 \
7797
--tag ghcr.io/hexlet-codebattle/nginx-assets:latest services/app
78-
docker build --target runtime-image \
98+
DOCKER_BUILDKIT=1 docker build --target runtime-image \
7999
--file services/app/Containerfile.codebattle \
80100
--build-arg GIT_HASH=$(GIT_HASH) \
101+
--cache-from ghcr.io/hexlet-codebattle/codebattle:compile-image \
102+
--cache-from ghcr.io/hexlet-codebattle/codebattle:latest \
103+
--build-arg BUILDKIT_INLINE_CACHE=1 \
81104
--tag ghcr.io/hexlet-codebattle/codebattle:latest services/app
82105

83106
build-arm:
84-
docker build --platform linux/arm64 \
107+
DOCKER_BUILDKIT=1 docker build --platform linux/arm64 \
85108
--target assets-image \
86109
--file services/app/Containerfile.codebattle \
87110
--build-arg GIT_HASH=$(GIT_HASH) \
111+
--cache-from ghcr.io/hexlet-codebattle/codebattle:assets-image-arm \
112+
--build-arg BUILDKIT_INLINE_CACHE=1 \
88113
--tag ghcr.io/hexlet-codebattle/codebattle:assets-image-arm services/app
89-
docker build --platform linux/arm64 \
114+
DOCKER_BUILDKIT=1 docker build --platform linux/arm64 \
90115
--target compile-image \
91116
--file services/app/Containerfile.codebattle \
92117
--build-arg GIT_HASH=$(GIT_HASH) \
118+
--cache-from ghcr.io/hexlet-codebattle/codebattle:assets-image-arm \
119+
--cache-from ghcr.io/hexlet-codebattle/codebattle:compile-image-arm \
120+
--build-arg BUILDKIT_INLINE_CACHE=1 \
93121
--tag ghcr.io/hexlet-codebattle/codebattle:compile-image-arm services/app
94-
docker build --platform linux/arm64 \
122+
DOCKER_BUILDKIT=1 docker build --platform linux/arm64 \
95123
--target nginx-assets \
96124
--file services/app/Containerfile.codebattle \
125+
--cache-from ghcr.io/hexlet-codebattle/codebattle:assets-image-arm \
126+
--cache-from ghcr.io/hexlet-codebattle/codebattle:compile-image-arm \
127+
--cache-from ghcr.io/hexlet-codebattle/nginx-assets:arm \
128+
--build-arg BUILDKIT_INLINE_CACHE=1 \
97129
--tag ghcr.io/hexlet-codebattle/nginx-assets:arm services/app
98-
docker build --platform linux/arm64 \
130+
DOCKER_BUILDKIT=1 docker build --platform linux/arm64 \
99131
--target runtime-image \
100132
--file services/app/Containerfile.codebattle \
101133
--build-arg GIT_HASH=$(GIT_HASH) \
134+
--cache-from ghcr.io/hexlet-codebattle/codebattle:compile-image-arm \
135+
--cache-from ghcr.io/hexlet-codebattle/codebattle:arm \
136+
--build-arg BUILDKIT_INLINE_CACHE=1 \
102137
--tag ghcr.io/hexlet-codebattle/codebattle:arm services/app
103138

104139
push-codeabttle-arm:
@@ -116,11 +151,16 @@ push-codebattle:
116151
build-runner:
117152
docker pull ghcr.io/hexlet-codebattle/runner:compile-image || true
118153
docker pull ghcr.io/hexlet-codebattle/runner:latest || true
119-
docker build --target compile-image \
154+
DOCKER_BUILDKIT=1 docker build --target compile-image \
120155
--file services/app/Containerfile.runner \
156+
--cache-from ghcr.io/hexlet-codebattle/runner:compile-image \
157+
--build-arg BUILDKIT_INLINE_CACHE=1 \
121158
--tag ghcr.io/hexlet-codebattle/runner:compile-image services/app
122-
docker build --target runtime-image \
159+
DOCKER_BUILDKIT=1 docker build --target runtime-image \
123160
--file services/app/Containerfile.runner \
161+
--cache-from ghcr.io/hexlet-codebattle/runner:compile-image \
162+
--cache-from ghcr.io/hexlet-codebattle/runner:latest \
163+
--build-arg BUILDKIT_INLINE_CACHE=1 \
124164
--tag ghcr.io/hexlet-codebattle/runner:latest services/app
125165

126166
push-runner:

0 commit comments

Comments
 (0)