From d7b4c41675f69552a75324c554f9fdac331f9e47 Mon Sep 17 00:00:00 2001 From: Oliver Chang Date: Wed, 10 Jul 2024 19:07:55 -0700 Subject: [PATCH 1/2] add with-dependencies option --- README.md | 6 ++++++ commands/build.sh | 4 ++++ plugin.yml | 3 +++ tests/build.bats | 15 +++++++++++++++ 4 files changed, 28 insertions(+) diff --git a/README.md b/README.md index a01059df..6d87fcc3 100644 --- a/README.md +++ b/README.md @@ -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 build will be run with the `--with-dependencies` option which will also build dependencies transitively. + +The default is `false`. + ## Developing To run the tests: diff --git a/commands/build.sh b/commands/build.sh index 26a51105..16cb3663 100755 --- a/commands/build.sh +++ b/commands/build.sh @@ -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") diff --git a/plugin.yml b/plugin.yml index a0aaba46..45f0d3b0 100644 --- a/plugin.yml +++ b/plugin.yml @@ -129,6 +129,8 @@ configuration: minimum: 1 wait: type: boolean + with-dependencies: + type: boolean workdir: type: string anyOf: @@ -183,4 +185,5 @@ configuration: user: [ run ] volumes: [ run ] wait: [ run ] + with-dependencies: [ build ] workdir: [ run ] diff --git a/tests/build.bats b/tests/build.bats index af9174f9..3e6a5487 100644 --- a/tests/build.bats +++ b/tests/build.bats @@ -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 +} From 1224b43a57b701acb00b7f2c831448cfcdfdc674 Mon Sep 17 00:00:00 2001 From: Oliver Chang Date: Wed, 10 Jul 2024 19:12:47 -0700 Subject: [PATCH 2/2] remove confusing doc --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 6d87fcc3..c2430956 100644 --- a/README.md +++ b/README.md @@ -330,7 +330,7 @@ All elements in this array will be passed literally to the `build` command as pa #### `with-dependencies` (build only, boolean) -If set to true, docker compose build will be run with the `--with-dependencies` option which will also build dependencies transitively. +If set to true, docker compose will build with the `--with-dependencies` option which will also build dependencies transitively. The default is `false`.