docker-compose-buildkite-plugin icon indicating copy to clipboard operation
docker-compose-buildkite-plugin copied to clipboard

Add support for overriding `target`

Open sagebind opened this issue 4 years ago • 4 comments

Target being: https://docs.docker.com/compose/compose-file/#target

Allowing you to override this using the plugin would make it possible for you to build multiple targets of a service, push each target to a repository, and then pull them down in a cache-from in order to use caching for multi-stage builds. This is still doable today, but you have to have multiple docker-compose.yml files for each target. Adding target to the plugin would make it much easier.

sagebind avatar Aug 08 '19 22:08 sagebind

:+1: for this feature. We needed to target our "base" step in the multi-stage Dockerfile in order to get the cache-from actually working in a single-service build.

Using the 'final' target resulted in intermediate layers we needed (to get the caching working) being removed before the push. That caused extra work to be (re)done in later stages of the pipeline.

Please support configuring a target in a pipeline step.

PS: as a workaround we added a second config to the pipeline:

version: '3.7'
services:
  our-service:
    build:
      target: base

and then in the pipeline step:

          config:
            - docker-compose.yml
            - docker-compose-target-base.yml

lucas-nelson avatar Nov 05 '19 23:11 lucas-nelson

Currently using multi-stage builds and have developers sad that Buildkite's re-doing work, upvoting.

ecv avatar Nov 15 '19 21:11 ecv

:+1: for this too. I currently have two separate Dockerfiles to help keep my Buildkite pipeline fast by not using multi-stage builds so it can cache as much as possible, and a final "production" Dockerfile that gets built after.

Having the option to specify different targets would help control this all from a single Dockerfile and ensure cache is used as much as possible.

evandam avatar Jan 09 '20 18:01 evandam

+1

puyo avatar Feb 25 '22 02:02 puyo

This looks like a valid request to add a way to customize the docker build --target option. Or are there more nuance to this?

toote avatar Sep 21 '22 22:09 toote