Deterministic Zip (Reproducible Checksum) #135
beanaroo
started this conversation in
Show and tell
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Use Case
I would like to produce deterministic zip archives of source code to prevent unnecessary redeploys of AWS Lambda Functions and Layers. This can be done in Terraform by specifying
source_code_hash
of the upload.Alternatives
I have achieved this in the past using shell scripts or Python
Looking for a native Node.js method, I came across deterministic-zip and had success after applying @troyready's patch (and converting to Typescript).
Trying fflate
I was able to achieve the desired effect with the following:
Verified using
zipcmp
andsha256
Performance
I have not yet attempted to optimize the above by trying things like async
zip
and/or streaming. The above performs well enough for my needs (archivingnode_modules
), compressing 18k files to 85MB in ~25 seconds.Observation
Passing in
fileBuf: Buffer
resulted in different CRCs on each invocation. Switching tofileBuf.valueOf(): UInt8Array
did the trick.💡 Sharing in case somebody finds this useful or would like to critique.
Beta Was this translation helpful? Give feedback.
All reactions