diff --git a/README.md b/README.md index 9697a4f4..b01eabbb 100644 --- a/README.md +++ b/README.md @@ -319,7 +319,7 @@ The name to use when tagging pre-built images. If multiple images are built in t Other docker-compose services that should be aliased to the main service that was built. This is for when different docker-compose services share the same prebuilt image. -### `args` (optional) +### `args` (optional, build only) A list of KEY=VALUE that are passed through as build arguments when image is being built. @@ -387,7 +387,7 @@ Prevent the removal of volumes after the command has been run. The default is `false`. -### `no-cache` (optional) +### `no-cache` (optional, build only) Sets the build step to run with `--no-cache`, causing Docker Compose to not use any caches when building the image. diff --git a/commands/run.sh b/commands/run.sh index 59f0f6d1..65fe5828 100755 --- a/commands/run.sh +++ b/commands/run.sh @@ -161,20 +161,10 @@ elif [[ ! -f "$override_file" ]]; then echo "~~~ :docker: Building Docker Compose Service: $run_service" >&2 echo "⚠️ No pre-built image found from a previous 'build' step for this service and config file. Building image..." - build_params=() - - if [[ "$(plugin_read_config NO_CACHE "false")" == "true" ]] ; then - build_params+=(--no-cache) - fi - - while read -r arg ; do - [[ -n "${arg:-}" ]] && build_params+=("--build-arg" "${arg}") - done <<< "$(plugin_read_list ARGS)" - # Ideally we'd do a pull with a retry first here, but we need the conditional pull behaviour here # for when an image and a build is defined in the docker-compose.ymk file, otherwise we try and # pull an image that doesn't exist - run_docker_compose build --pull "${build_params[@]}" "$run_service" + run_docker_compose build --pull "$run_service" # Sometimes docker-compose pull leaves unfinished ansi codes echo diff --git a/plugin.yml b/plugin.yml index 06d1debf..d0803bca 100644 --- a/plugin.yml +++ b/plugin.yml @@ -91,12 +91,11 @@ configuration: cache-from: [ build ] volumes: [ run ] leave-volumes: [ run ] - no-cache: [ build, run ] + no-cache: [ build ] use-aliases: [ run ] dependencies: [ run ] ansi: [ run ] tty: [ run ] workdir: [ run ] user: [ run ] - args: [ build, run ] propagate-uid-gid: [ run ] diff --git a/tests/run.bats b/tests/run.bats index e3539628..594099f6 100644 --- a/tests/run.bats +++ b/tests/run.bats @@ -199,61 +199,6 @@ cmd3" unstub buildkite-agent } -@test "Run without a prebuilt image with no-cache" { - export BUILDKITE_JOB_ID=1111 - export BUILDKITE_PLUGIN_DOCKER_COMPOSE_RUN=myservice - export BUILDKITE_PLUGIN_DOCKER_COMPOSE_NO_CACHE=true - export BUILDKITE_PIPELINE_SLUG=test - export BUILDKITE_BUILD_NUMBER=1 - export BUILDKITE_COMMAND="echo hello world" - export BUILDKITE_PLUGIN_DOCKER_COMPOSE_CHECK_LINKED_CONTAINERS=false - export BUILDKITE_PLUGIN_DOCKER_COMPOSE_CLEANUP=false - - stub docker-compose \ - "-f docker-compose.yml -p buildkite1111 build --pull --no-cache myservice : echo built myservice" \ - "-f docker-compose.yml -p buildkite1111 up -d --scale myservice=0 : echo ran myservice dependencies" \ - "-f docker-compose.yml -p buildkite1111 run --name buildkite1111_myservice_build_1 --rm myservice /bin/sh -e -c 'echo hello world' : echo ran myservice" - - stub buildkite-agent \ - "meta-data exists docker-compose-plugin-built-image-tag-myservice : exit 1" - - run $PWD/hooks/command - - assert_success - assert_output --partial "built myservice" - assert_output --partial "ran myservice" - unstub docker-compose - unstub buildkite-agent -} - -@test "Run without a prebuilt image with build args" { - export BUILDKITE_JOB_ID=1111 - export BUILDKITE_PLUGIN_DOCKER_COMPOSE_RUN=myservice - export BUILDKITE_PLUGIN_DOCKER_COMPOSE_ARGS_0=MYARG=0 - export BUILDKITE_PLUGIN_DOCKER_COMPOSE_ARGS_1=MYARG=1 - export BUILDKITE_PIPELINE_SLUG=test - export BUILDKITE_BUILD_NUMBER=1 - export BUILDKITE_COMMAND="echo hello world" - export BUILDKITE_PLUGIN_DOCKER_COMPOSE_CHECK_LINKED_CONTAINERS=false - export BUILDKITE_PLUGIN_DOCKER_COMPOSE_CLEANUP=false - - stub docker-compose \ - "-f docker-compose.yml -p buildkite1111 build --pull --build-arg MYARG=0 --build-arg MYARG=1 myservice : echo built myservice" \ - "-f docker-compose.yml -p buildkite1111 up -d --scale myservice=0 : echo ran myservice dependencies" \ - "-f docker-compose.yml -p buildkite1111 run --name buildkite1111_myservice_build_1 --rm myservice /bin/sh -e -c 'echo hello world' : echo ran myservice" - - stub buildkite-agent \ - "meta-data exists docker-compose-plugin-built-image-tag-myservice : exit 1" - - run $PWD/hooks/command - - assert_success - assert_output --partial "built myservice" - assert_output --partial "ran myservice" - unstub docker-compose - unstub buildkite-agent -} - @test "Run with a prebuilt image" { export BUILDKITE_JOB_ID=1111 export BUILDKITE_PLUGIN_DOCKER_COMPOSE_RUN=myservice