Closed viraptor closed 7 months ago
@viraptor You are correct, thanks for pointing out! It was my fault as it was one of the first changes I did in this repository without completely understanding the code's and compose nuances.
While I want to correct the option, I am really interested in your expectations on how it should work and what kind of configurations you want off it. Also, I am not 100% sure how specifying a target would work when you are building multiple services. Do you have any thoughts on that?
I am really interested in your expectations on how it should work and what kind of configurations you want off it.
My original use case was to have a service app
pointing at a Dockerfile with multiple stages. Then the test steps would use an override to use target: ci
which includes the test tools, while other steps would use the default which builds just the deployable image.
Turns out I had more differences to implement, so ended up just duplicating the service as ...-prod
and ...-test
in the docker-compose itself and assigning different targets there.
I think the option could still be useful in a simpler setup.
Also, I am not 100% sure how specifying a target would work when you are building multiple services. Do you have any thoughts on that?
Nope, I suspect it would have to be a hack for a single service only.
I just ran into this issue and assumed that specifying the target
option would override the compose file to add a target build directive to the overridden service definition, thus allowing me to target a stage in a multi stage build.
Sadly this just slaps an incorrect --target
onto the docker compose cmd which results in
$ docker-compose -f docker-compose.yml -p buildkite018c900423954192bc6a0b21321ae8ae -f docker-compose.buildkite-10-override.yml build --pull --target base app
unknown flag: --target
🚨 Error: The command exited with status 16
FWIW - My use case is similar to @viraptor in that i want to target a multi stage build.
https://github.com/buildkite-plugins/docker-compose-buildkite-plugin/issues/231#issuecomment-550067960 provides a similar use case I have where i'd like to prebuild multi stage cache images to avoid extra work in subsequent builds.
I think there was a mistake where the
target
option was added to the plugin. Specifically in https://github.com/buildkite-plugins/docker-compose-buildkite-plugin/issues/231 the referenced documentation is https://docs.docker.com/build/building/multi-stage/#stop-at-a-specific-build-stageThat option is specific to
docker build
though, notdocker-compose build
. If I understand the original request correctly, the way to do this in the plugin would be to add the option to the override yml instead.Currently the plugin tries to add
--target ...
to thedocker-compose build
command and fails because it's not implemented https://docs.docker.com/engine/reference/commandline/compose_build/(Unless this is some version specific behaviour that was added/removed in the meantime)