Skip to content

Commit 514b701

Browse files
authored
Merge pull request #449 from mtollie/oliver/with-dependencies
Add option to build with `--with-dependencies`
2 parents ffd596e + 1224b43 commit 514b701

File tree

4 files changed

+28
-0
lines changed

4 files changed

+28
-0
lines changed

README.md

+6
Original file line numberDiff line numberDiff line change
@@ -328,6 +328,12 @@ It will add the `--ssh` option to the build command with the passed value (if `t
328328

329329
All elements in this array will be passed literally to the `build` command as parameters of the [`--secrets` option](https://docs.docker.com/engine/reference/commandline/buildx_build/#secret). Note that you must have BuildKit enabled for this option to have any effect and special `RUN` stanzas in your Dockerfile to actually make use of them.
330330

331+
#### `with-dependencies` (build only, boolean)
332+
333+
If set to true, docker compose will build with the `--with-dependencies` option which will also build dependencies transitively.
334+
335+
The default is `false`.
336+
331337
## Developing
332338

333339
To run the tests:

commands/build.sh

+4
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,10 @@ if [[ "$(plugin_read_config BUILDKIT_INLINE_CACHE "false")" == "true" ]] ; then
101101
build_params+=("--build-arg" "BUILDKIT_INLINE_CACHE=1")
102102
fi
103103

104+
if [[ "$(plugin_read_config WITH_DEPENDENCIES "false")" == "true" ]] ; then
105+
build_params+=(--with-dependencies)
106+
fi
107+
104108
# Parse the list of secrets to pass on to build command
105109
while read -r line ; do
106110
[[ -n "$line" ]] && build_params+=("--secret" "$line")

plugin.yml

+3
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,8 @@ configuration:
129129
minimum: 1
130130
wait:
131131
type: boolean
132+
with-dependencies:
133+
type: boolean
132134
workdir:
133135
type: string
134136
anyOf:
@@ -183,4 +185,5 @@ configuration:
183185
user: [ run ]
184186
volumes: [ run ]
185187
wait: [ run ]
188+
with-dependencies: [ build ]
186189
workdir: [ run ]

tests/build.bats

+15
Original file line numberDiff line numberDiff line change
@@ -343,3 +343,18 @@ setup_file() {
343343
assert_output --partial "built myservice"
344344
unstub docker
345345
}
346+
347+
@test "Build with with-dependencies" {
348+
export BUILDKITE_PLUGIN_DOCKER_COMPOSE_BUILD=myservice
349+
export BUILDKITE_PLUGIN_DOCKER_COMPOSE_WITH_DEPENDENCIES=true
350+
351+
stub docker \
352+
"compose -f docker-compose.yml -p buildkite1111 build --pull --with-dependencies myservice : echo built myservice"
353+
354+
run "$PWD"/hooks/command
355+
356+
assert_success
357+
assert_output --partial "built myservice"
358+
359+
unstub docker
360+
}

0 commit comments

Comments
 (0)