compose icon indicating copy to clipboard operation
compose copied to clipboard

Add support for build additional_contexts to reference other service targets

Open andytson opened this issue 2 years ago • 1 comments

Description

I'd like to be able to reference other services stages in a service's build contexts.

This is possible using buildx bake's contexts support for another bake target, but doesn't appear to be implemented yet in compose yet, but build.additional_contexts exists for other context types.

example:

service:
  console:
     build:
       context: ./docker/console
  app:
    build:
      context: ./docker/app
      additional_contexts:
        src: service:console

should provide the console build's target to app as src context.

To make this clear, service:console isn't supported currently by additional_contexts, it's what I'm asking for.

andytson avatar Jul 20 '23 13:07 andytson

ah sorry I also misread buildx's config as to reference a stage of the referenced target but target:base the target is just a prefix.

I'll update the example for consistency

andytson avatar Jul 20 '23 14:07 andytson

seems to be fixed in https://github.com/docker/compose/pull/12485

andytson avatar Feb 12 '25 10:02 andytson