-
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
RFC: dockerfile: support Dockerfile.sum
for pinning sources
#2794
Comments
@tonistiigi @crazy-max @ktock PTAL 🙏 |
Looks like a nice way to provide/show the buildinfo feature to the end user, thanks @AkihiroSuda! Using the Atm metadata resolution is not cached in the frontend (I think it uses the containerimage metaresolver which lacks of cache support). I recall about #706 and wonder if we should not look first at improving the cache experience on this side and maybe align it with your proposal. I will think a bit more about your proposal but sgtm! |
This looks awesome. I'd just note that it more closely resembles a lock file rather than a go.sum file to me. They're very close so it's mostly just a nitpick. go.sum serves a few additional purposes beyond just pinning, related to the transparency log and version resolution. |
Wonder if we could also think about a |
Some things to consider here:
BuildInfo in v0.10 also contains Is this meant to be a LLB level or frontend level(Dockerfile) concept? Given it is loaded from Dockerfile, I guess frontend, but the pinning concept could be generalized in LLB as well. We already added I didn't quite get the |
The current POC does not increase the numbers of HTTP request AFAICS, and I don't see increased possibility of hitting the rate limit.
👍
Is it better to change
Maybe we should have a version field or
Frontend, because the image meta resolver has to be called before generating LLB.
Should this be moved to exporter metadata? |
Sounds very cool 👍 AkihiroSuda@99071c3#diff-50c7e2f4bb8c30ace7a5a6d2858ade67023db56d633f887b26768afae38ece7dR76
Shouldn't we produce an error if there is a missing entry in Dockerfile.sum? (go.mod seems to do so) And +1 to @crazy-max 's |
Would something like this help? |
Cosign has also explored adding a CLI to resolve image references in a Dockerfile so they're more reproducible/verifiable: see sigstore/cosign#707 and PR sigstore/cosign#1120 If there was one reliable, canonical way to do this, that would be a huge improvement. |
Also considering something like a Dockerfile.mod where such locks could be added (as they are in go.mod), however a separate .lock file may be good here just because many times you don't want to actually pin resources (e.g. images like ubuntu:18.04 you probably want the most up to date version). |
Just a thought: how much do you want to pin? Pinning the FROM image should be straightforward, but pinning the state of software at the time of build is much harder. In order to do |
No, not all entries have to be / can be pinned. @nishakm @imjasonh The goal of this PR is to cover |
I don't understand the purpose of this proposal. If you really want to pin the base image, you can already do this by referencing the image digest instead of the tag. Also, the image tag could come from a build arg, so I don't see how you could have one authoritative pin/lock/sum file in that kind of circumstance. I think instead of this, there should just be a way to specify the digest as part of the |
There's a couple of reasons:
|
@cpuguy83 I'm assuming by "source" here you mean the Dockerfile.
If you use build args for the pins then you don't need to change the Dockerfile per se, just whatever is supplying the args. Also, if you are downloading files within
Build args already handle this too. For example: ARG IMAGE_DIGEST=sha256:...
FROM ubuntu@${IMAGE_DIGEST} AS install
...
FROM ubuntu@${IMAGE_DIGEST} AS final
...
I don't know what this means. |
Build args do not handle this. |
Multiple dockerfiles or build targets in one repo. |
@cpuguy83 One thing that is unclear to me from this proposal is what specifically happens when a tag gets changed. For example, suppose I do |
If you have it pinned, it doesn't matter what digest the tag points to in DockerHub, you've pinned it to what you want it to be. |
Latter for regular tags, former for immutable tags |
Slightly related; |
Yes, this proposal covers #975, but provides a generic way for multiple LLB source ops |
Yes, to some extend this can cover that feature request (but likely would require one to manually create the Dockerfile.sum (which also feels a bit awkward). I haven't looked in-depth, but wondering how this proposal works with build-args (which can influence the build-steps, and thus what "checksum" to look for?), but I guess in that case it's an exercise to the user to create entries for every variant 🤔 |
How would this work when working with a multi-arch base image? I haven't really worked with them, but my understanding is you would have multiple images with the same tag but different digests (one per os/arch). |
For multi arch it can refer to the manifest index (which is the "wrapper" tying together the image variants) |
We have {
"rules": [
{
"action": "CONVERT",
"selector": {
"identifier": "docker-image://docker.io/library/alpine:latest"
},
"updates": {
"identifier": "docker-image://docker.io/library/alpine:latest@sha256:4edbd2beb5f78b1014028f4fbb99f3237d9561100b6881aabbf5acce2c4f9454"
}
},
{
"action": "CONVERT",
"selector": {
"identifier": "https://raw.githubusercontent.com/moby/buildkit/v0.10.1/README.md"
},
"updates": {
"attrs": {"http.checksum": "sha256:6e4b94fc270e708e1068be28bd3551dc6917a4fc5a61293d51bb36e6b75c4b53"}
}
}
]
} |
EDIT: the current PR:
Dockerfile.sum
is an equivalent ofgo.sum
buts/go/Dockerfile/
.The content is a subset of
BuildInfo
:When
Dockerfile.sum
exists in the context, theDockerfile
builder does:docker-image
sources (FROM ...
)http
sources (ADD https://...
)["containerimage.buildinfo"].consumedPin
)In the future, Dockerfile should also support
ADD <gitref>.
and pinning its commit hash.ADD <git ref>
#2799POC
https://github.com/AkihiroSuda/buildkit_poc/commits/pin-poc.20220411-0
When a
docker-image
pin is wrong:When an
http
pin is wrong:The text was updated successfully, but these errors were encountered: