compose icon indicating copy to clipboard operation
compose copied to clipboard

Support multiple build contexts

Open ciaranmcnulty opened this issue 2 years ago • 4 comments

Dockerfile 1.4 supports multiple build contexts - a way to specify them when building in compose would be great

I'd suggest something like:

services:
   myapp:
    build:
        contexts:
            additional: ../foo
            deps: https://github.com/myvendor/deps
            dist: https://somedistro.info/download/latest.tar.gz

Being able to drive this from environment / .env could be very powerful

ciaranmcnulty avatar May 13 '22 09:05 ciaranmcnulty

Is there a roadmap or any updates on this? Thanks!

nrontsis avatar Jul 13 '22 23:07 nrontsis

I suppose the ability to link targets/services to create build pipelines as in buildx bake should also be accounted. :)

felipecrs avatar Jul 20 '22 03:07 felipecrs

Are there any concrete plans on this issue yet?

lmoesch avatar Sep 17 '22 11:09 lmoesch

Alternately, perhaps the ability to pass additional args to the build command? That way you could pass --build-context manually while waiting for the compose specification to support it natively.

alexania avatar Sep 19 '22 09:09 alexania

This would solve the long-standing issue of having shared code between multiple containers in a docker compose project. Would the team be open to a pull request to implement this?

knpwrs avatar Oct 31 '22 20:10 knpwrs

With buildx bake I can build image from a compose file (see https://docs.docker.com/build/customize/bake/compose-file) :

# docker-compose.yml
services:
  service_name:
    build:
      context: .
      x-bake:
        contexts:
          context1: path
          context2: path

And build with docker buildx bake -f docker-compose.yml service_name

But I don't know if we can up a service using buildx / bake.

kdubuc avatar Nov 22 '22 10:11 kdubuc

@kdubuc we can't; you can have a hybrid setup where you use bake for build and compose for running, but it'd be nice to have it all in compose

ciaranmcnulty avatar Nov 22 '22 10:11 ciaranmcnulty

This would be a much appreciated feature, are there any updates/plans to implement it?

mbielanczuk avatar Feb 21 '23 09:02 mbielanczuk

There is a PR on the Compose spec for supporting additional contexts during build. It seems to be ready to be merge soon

glours avatar Feb 21 '23 10:02 glours

Yup. Follow up PR on compose-go here, and I have the rest of the implementation ready to go for when that gets merged. Should be quick after the spec PR gets merged.

laurazard avatar Feb 21 '23 12:02 laurazard