Add Dockerfile and pre-commit hook config #132
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
User story
I'd like to run ECT automatically on images that are newly added to a git repository. pre-commit is a relatively common tool for running a configurable set of git hooks on changed files. It supports arbitrary hooks using Docker (among other ways).
Proposal
This PR adds a Dockerfile for ECT, and a
.pre-commit-hooks.yaml
file describing how pre-commit should run the hook. An example user might configure the following in their.pre-commit-config.yaml
:With this config, pre-commit would use ECT to optimize newly added or changed PNGs, JPEGs, ZIPs, and GZIPs.
Notably, this PR does not include any automation for pushing Docker images to a repository such as Docker Hub, so there's no additional infrastructure or maintenance burden (other than updating the Dockerfile if you add new compilation dependencies). On first use, pre-commit clones the repo and builds the image from source.
Assumptions
In order to use ECT as an effective pre-commit hook, I assume that once a file has been optimized, re-running ECT on that file will not change the file, and will be reasonably fast. In my testing, this appears to be the case, but it would be nice to have some theoretical backing for this claim.