3

Let's say I have a Dockerfile like this:

FROM <some image> as base
COPY src /src
RUN <build command>

FROM base as test
RUN <test command>

FROM base as lint
RUN <lint command>

FROM base as <you get the idea>
RUN <test command>

FROM <slim-image> as production
COPY --from=base

I would like one command that runs all these targets, with BuildKit.

Is there an easy way, or would I have to script that?

Christian Neverdal
  • 5,655
  • 6
  • 38
  • 93
  • @rbashish: your comment is wildly wrong. Also, if it were correct, it should have been posted as an answer with an explanation instead of a comment with only a command. – Christian Neverdal Jul 29 '19 at 07:46
  • @rbashish: there is no docker-compose setup here. – Christian Neverdal Jul 29 '19 at 07:50
  • @rbashish: note that BuiltKit is mentioned as a requirement, which docker-compose does not support yet (see https://github.com/docker/compose/issues/6440). Also: there is no reason why using BuildKit with docker-compose would build *all* targets in *each* `Dockerfile`. One would assume that the behavior would be similar to only invoking `docker build`. – Christian Neverdal Jul 29 '19 at 07:51
  • @rbashish: also, would it not be `docker-compose --build`? Neither `up` nor `-d` is relevant to what is being asked. – Christian Neverdal Jul 29 '19 at 08:08
  • @rbashish: If it were acceptable to not use BuildKit then I would still not create a `docker-compose.yml` just for this. instead I would do `DOCKER_BUILDKIT=0 docker build .`, which is basically what would currently happen "behind the scenes" when doing `docker-compose --build`. – Christian Neverdal Jul 29 '19 at 08:10

0 Answers0