-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Feature proposal: A way to specify in Dockerfile frontend that a given stage is a target stage, not an intermediate stage #4834
Comments
Dumb idea for how this could (maybe) work - there are probably better ways than a whole new keyword:
Essentially, the new Edit to clarify: Edit 2: NON-GOAL: deprecation/removal of the target flag or any other flag currently used. The target flag should be respected. I leave it to the community to decide whether Edit 3: Some different variations I thought of:
TO as a stage keyword rather than a global keyword:
Extend
Or more concisely, the last 4 stages could be condensed to 2 as:
|
But that's what the |
If you're linting a dockerfile, how does the linter know which stages are going to be specified in the If Colin reached out to me about build time policies after my comments on Slack, so it seems like that may be a coming feature and something I'd use to accomplish the same goal. |
Linting is atm exposed with |
Sounds great. Based on the discussion with Colin, I understand it's being integrated in the front end so that addresses all of my points. Thanks! |
Hello! I was drawn originally to #4823 and as I was writing a comment, a thought occurred to me that probably should be a separate issue, so here we go!
One of my colleagues prefers to build all of the images for a given project from a single dockerfile by specifying target stages to the buildkit command and tagging images using the targets, rather than having each image in its own Dockerfile. Other than that, we generally follow best practices; using scratch images for the target stages, discarding intermediate build stages and the files that aren't required to run the app in the container, not using root except for where absolutely required, etc.
In #4823 is being discussed some linting ideas and one of the ideas I had was to encourage the use of scratch images.
Given my colleague's preference, I quickly realized that it would be difficult to encourage the use of scratch images if there is no way to specify in the dockerfile that a given stage will be used as a target in buildkit. This also was an issue for us when we used conftest to lint Dockerfiles; because Dockerfile has no syntax to say "this stage is going to be tagged as an image" that is universally recognized, we had to come up with an internal solution of requiring dockerfiles to have a specific name for stages that would be specified in the target flag.
So in order to be able to accomplish a goal of encouraging the use of scratch images, we would require some sort of dockerfile frontend change to allow for a stage to be designated as a target. Thinking about it a bit more, I realized that this could also allow us simplify the build process a little by dropping the requirement to specify the target flag to buildkit for this way of building images, and potentially allow the tag flag to buildkit to not be required on the command line, since the tag would then be codified in the Dockerfile.
Please let me know your thoughts on this. I'm happy to have further discussions and open to suggestions for improvement of this idea.
The text was updated successfully, but these errors were encountered: