Skip to content

Commit 8d5db9f

Browse files
authored
Merge pull request #428 from jquick/jq/add_inline_cache_env
Add buildkite inline cache env
2 parents 3987929 + bac6762 commit 8d5db9f

4 files changed

Lines changed: 30 additions & 1 deletion

File tree

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,12 @@ If set to `true` it will mount onto `/workdir`, unless `workdir` is set, in whic
146146

147147
Default: `false`
148148

149+
### `buildkit-inline-cache` (optional, build-only, boolean)
150+
151+
Whether to pass the `BUILDKIT_INLINE_CACHE=1` build arg when building an image. Can be safely used in combination with `args`.
152+
153+
Default: `false`
154+
149155
#### `pull-retries` (run only, integer)
150156

151157
A number of times to retry failed docker pull. Defaults to 0.

commands/build.sh

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,10 @@ if [[ "$(plugin_read_config BUILD_PARALLEL "false")" == "true" ]] ; then
8989
build_params+=(--parallel)
9090
fi
9191

92+
if [[ "$(plugin_read_config BUILDKIT_INLINE_CACHE "false")" == "true" ]] ; then
93+
build_params+=("--build-arg" "BUILDKIT_INLINE_CACHE=1")
94+
fi
95+
9296
# Parse the list of secrets to pass on to build command
9397
while read -r line ; do
9498
[[ -n "$line" ]] && build_params+=("--secret" "$line")
@@ -113,4 +117,4 @@ while read -r arg ; do
113117
done <<< "$(plugin_read_list ARGS)"
114118

115119
echo "${group_type} :docker: Building services ${services[*]}"
116-
run_docker_compose "${build_params[@]}" "${services[@]}"
120+
run_docker_compose "${build_params[@]}" "${services[@]}"

plugin.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ configuration:
2727
type: boolean
2828
buildkit:
2929
type: boolean
30+
buildkit-inline-cache:
31+
type: boolean
3032
cache-from:
3133
type: [ string, array ]
3234
minimum: 1
@@ -138,6 +140,7 @@ configuration:
138140
build-alias: [ push ]
139141
build-parallel: [ build ]
140142
buildkit: [ build ]
143+
buildkit-inline-cache: [ build ]
141144
cache-from: [ build ]
142145
command: [ run ]
143146
dependencies: [ run ]

tests/build.bats

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -327,3 +327,19 @@ setup_file() {
327327

328328
unstub docker
329329
}
330+
331+
@test "Build with buildkit-inline-cache" {
332+
export BUILDKITE_PLUGIN_DOCKER_COMPOSE_BUILD=myservice
333+
export BUILDKITE_PLUGIN_DOCKER_COMPOSE_ARGS_0=MYARG=0
334+
export BUILDKITE_PLUGIN_DOCKER_COMPOSE_ARGS_1=MYARG=1
335+
export BUILDKITE_PLUGIN_DOCKER_COMPOSE_BUILDKIT_INLINE_CACHE=true
336+
337+
stub docker \
338+
"compose -f docker-compose.yml -p buildkite1111 build --pull --build-arg BUILDKIT_INLINE_CACHE=1 --build-arg MYARG=0 --build-arg MYARG=1 myservice : echo built myservice"
339+
340+
run $PWD/hooks/command
341+
342+
assert_success
343+
assert_output --partial "built myservice"
344+
unstub docker
345+
}

0 commit comments

Comments
 (0)