-
Notifications
You must be signed in to change notification settings - Fork 63
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
Make oras push
/ oras attach
deterministic
#366
Comments
I'd like to add to the above the case where we create a manifest from dir with multiple files and dirs. What would be the recommended solution there? |
@cunningr Currently there is a workaround via specifying the > ls dir
a b c
> time=$(date -u +"%Y-%m-%dT%H:%M:%SZ")
> oras push localhost:5000/test:pushed dir --annotation org.opencontainers.image.created=$time
✓ Uploaded dir 146/146 B 100.00% 63ms
└─ sha256:f20484fafe471d3d0542f2643c087064fd0b16ab44b174ca844cb3a352260900
✓ Uploaded application/vnd.oci.empty.v1+json 2/2 B 100.00% 59ms
└─ sha256:44136fa355b3678a1146ad16f7e8649e94fb4fc21fe77e8310c060f61caaff8a
✓ Uploaded application/vnd.oci.image.manifest.v1+json 729/729 B 100.00% 44ms
└─ sha256:bc7d73dcb17084e35d17c1fb4c17cce0ffcca6c19e805676b95014dc23172e12
Pushed [registry] localhost:5000/test:pushed
Digest: sha256:bc7d73dcb17084e35d17c1fb4c17cce0ffcca6c19e805676b95014dc23172e12
> oras push localhost:5000/test:pushed dir --annotation org.opencontainers.image.created=$time
✓ Uploaded application/vnd.oci.image.manifest.v1+json 729/729 B 100.00% 29ms
└─ sha256:bc7d73dcb17084e35d17c1fb4c17cce0ffcca6c19e805676b95014dc23172e12
Pushed [registry] localhost:5000/test:pushed
Digest: sha256:bc7d73dcb17084e35d17c1fb4c17cce0ffcca6c19e805676b95014dc23172e12 You can see that both pushing generates the same manifest. |
I encountered a different issue related to this. Maybe it is expected (and desirable) but for us it was not desirable so thought it was worth calling out. We generate a bunch of manifests using templating and input vars. The resulting manifests are packed and pushed using ORAS. I was able to get deterministic builds using the above and the same instance (generation output run of manifests). However, if we make two different generation runs of our manifests with exactly the same inputs ORAS will detect changes, presumably due to the file attributes (e.g. create/access timestamp). The contents of the input files are exactly the same but we still get a different resulting hash. |
If file contents are identical, the generated manifest should be the same. Can you double check the |
So here is my test: generate the files and do;
I get returned a digest "abc123" Now i delete my files and regenerate them and do exactly the same Now I pull the manifest data using
vs
The annotations are the same in each manifest:
but my |
I think the mtime(Last Modified Time) of the files are different in different pipelines and causes the digest difference. |
@cunningr I have added an enhancement issue oras-project/oras#1464 |
What is the version of your ORAS CLI
v1.2.0-beta.1
What would you like to be added?
Deterministically generate manifests for
oras push
andoras attach
if the same content (e.g. blobs, annotations) are packed.Related issue: oras-project/oras-go#748
The request is to document how to do deterministic build. It would be better if we can introduce a flag to make
--annotation org.opencontainers.image.created=$(date -d @$(stat -c %Y <artifact_path>) -u +"%Y-%m-%dT%H:%M:%SZ")
simpler.Why is this needed for ORAS?
With deterministic builds (a.k.a. reproducible builds), the
oras push
command will not push two different manifests. Deterministic builds also play an important role in CSSC (see blog).Current behavior:
With deterministic builds:
Are you willing to submit PRs to contribute to this feature?
The text was updated successfully, but these errors were encountered: