-
Notifications
You must be signed in to change notification settings - Fork 18.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Proposal: INCLUDE syntax for specifying multiple images per context #7277
Comments
Why wouldn't you just make a shell script to run the different builds? This seems to be a very specific use-case (and is filled with strange functionality, because the context of each Using shared libraries is a bit of a pain, and the builder-runner pattern can help with this (you have a build of the builders of the shared libraries, then a build of the builders each app and then a build of the runners for each app). Also, the whole recipe thing can be done with a |
I agree that there is a context confusion when looking at individual Dockerfiles. To alleviate that I propose adding another command - CONTEXT: |
Updated the proposal. Also as a comment - builder/runner pattern is very painful to use. And it also breaks the pattern of "docker build ." doing the right thing. This #7115 has a quite heavy syntax in the file. I would prefer the combination of this with #6906 (comment) this to solve such issues. It does miss a few nice things from #7115 , namely the ability to build in one environment (such as full Debian) and then run in something completely different (like busybox) or to combine multiple outputs, but the syntax is much simpler. And it could actually be merged with #7115 in a way to allow the use of separate images and separate Dockerfiles to define the sub-images. So the example from #7115 could be reformulated as: |
closed as duplicate of #7115, trying to consolidate so we can get cool stuff like this in |
Multiple use cases call for an ability to build several Docker images from a single context. An example would be a set of microservices that reside in a shared repository, because they also share common libraries. The common folder layout looks like this:
An ideal solution would:
This proposal is to introduce a new verb in the Dockerfile that would look like this:
INCLUDE /bar-service/Dockerfile.foo AS bar-service
and a CONTEXT verb to be used in the included Dockerfiles.The INCLUDE verb can be used multiple times. If there is an INCLUDE in a Dockerfile, it must come before the FROM verb in that file and FROM verb becomes optional.
If such line is included in the root Dockerfile and a user runs
docker build -t aigarius/xyz .
then this verb would have the following effects:CONTEXT ..
, then the ADD/COPY commands will work in the context of the parent folder. If such verb is not used, then the context of the included build is the folder containing the included file;FROM bar-service:included
would use the newly built bar-service image as a base.In addition it should be possible for a user to run
docker build -t aigarius/xyz --images=bar-service,foo-service .
to only build images of those two services.Tag ":included" should be considered to be equivalent to ":latest" (possibly with a warning) if there is no build with such name in the current build set.
CONTEXT verb shifts the context for a Docker build relative to the Dockerfile. This can be used to only have a subfolder of the original context be uploaded to the daemon. It can also be used to shift the context folder up, but only if the Dockerfile is included in another Dockerfile higher in the path and only up to the folder of the top level Dockerfile.
The text was updated successfully, but these errors were encountered: