Skip to content

Commit

Permalink
Merge pull request #449 from mtollie/oliver/with-dependencies
Browse files Browse the repository at this point in the history
Add option to build with `--with-dependencies`
  • Loading branch information
pzeballos authored Jul 11, 2024
2 parents ffd596e + 1224b43 commit 514b701
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 0 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,12 @@ It will add the `--ssh` option to the build command with the passed value (if `t

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.

#### `with-dependencies` (build only, boolean)

If set to true, docker compose will build with the `--with-dependencies` option which will also build dependencies transitively.

The default is `false`.

## Developing

To run the tests:
Expand Down
4 changes: 4 additions & 0 deletions commands/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,10 @@ if [[ "$(plugin_read_config BUILDKIT_INLINE_CACHE "false")" == "true" ]] ; then
build_params+=("--build-arg" "BUILDKIT_INLINE_CACHE=1")
fi

if [[ "$(plugin_read_config WITH_DEPENDENCIES "false")" == "true" ]] ; then
build_params+=(--with-dependencies)
fi

# Parse the list of secrets to pass on to build command
while read -r line ; do
[[ -n "$line" ]] && build_params+=("--secret" "$line")
Expand Down
3 changes: 3 additions & 0 deletions plugin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,8 @@ configuration:
minimum: 1
wait:
type: boolean
with-dependencies:
type: boolean
workdir:
type: string
anyOf:
Expand Down Expand Up @@ -183,4 +185,5 @@ configuration:
user: [ run ]
volumes: [ run ]
wait: [ run ]
with-dependencies: [ build ]
workdir: [ run ]
15 changes: 15 additions & 0 deletions tests/build.bats
Original file line number Diff line number Diff line change
Expand Up @@ -343,3 +343,18 @@ setup_file() {
assert_output --partial "built myservice"
unstub docker
}

@test "Build with with-dependencies" {
export BUILDKITE_PLUGIN_DOCKER_COMPOSE_BUILD=myservice
export BUILDKITE_PLUGIN_DOCKER_COMPOSE_WITH_DEPENDENCIES=true

stub docker \
"compose -f docker-compose.yml -p buildkite1111 build --pull --with-dependencies myservice : echo built myservice"

run "$PWD"/hooks/command

assert_success
assert_output --partial "built myservice"

unstub docker
}

0 comments on commit 514b701

Please sign in to comment.