Sign inSign up

jfxs/pre-commit

By jfxs

•Updated 2 months ago

An up-to-date multi-arch image to easily lint git repository

Image
Developer tools
0

10K+

jfxs/pre-commit repository overview

⁠pre-commit

Software License Pipeline Status

A Python⁠ Docker image with pre-commit⁠:

  • lightweight image based on a debian-slim,
  • multiarch with support of amd64 and arm64,
  • automatically updated by comparing software bill of materials (SBOM) changes,
  • image signed with Cosign⁠,
  • a software bill of materials (SBOM) attestation added using Syft⁠,
  • available on Docker Hub and Quay.io.

GitLab The main repository.

Docker Hub The Docker Hub registry.

Quay.io The Quay.io registry.

⁠Running pre-commit in local

docker run -t --rm -v $(pwd):/workdir jfxs/pre-commit /bin/bash -c "pre-commit run --all-files"

The first time pre-commit runs, it will automatically download, install, and run the necessary hooks (pre-commit autoupdate) and save them in the .cache/pre-commit directory. Don't forget to add the .cache directory to the .gitignore file.

⁠Running pre-commit in local with task⁠

docker run -t --rm -v $(pwd):/workdir {{.TAG}} /bin/bash -c "task --taskfile /lint.yml pre-commit DIR=/workdir"

or with task installed locally and the lint task template⁠:

task lint:pre-commit

If the .pre-commit-config.yaml doesn't exist the following default file is created:

---
repos:
  - repo: https://github.com/pre-commit/pre-commit-hooks
    rev: v4.5.0
    hooks:
      - id: trailing-whitespace
      - id: end-of-file-fixer
      - id: check-yaml
      - id: check-added-large-files
      # Hooks added from sample-config
      - id: check-executables-have-shebangs
      - id: check-json
      - id: check-merge-conflict
      - id: check-shebang-scripts-are-executable
      - id: check-symlinks
      - id: check-toml
      - id: check-xml
      - id: detect-private-key
      - id: end-of-file-fixer
      - id: fix-byte-order-marker
      - id: mixed-line-ending
      - id: trailing-whitespace
        args: [--markdown-linebreak-ext=md]

⁠Running pre-commit in Gitlab-CI

Example of usage with Gitlab-CI:

 ...
gitlab-release:
  image: jfxs/pre-commit
  stage: lint
  script:
    - task --taskfile /lint.yml pre-commit DIR=$(pwd)

⁠Built with

Docker latest tag is 4.6.1-001, 4.6, 4⁠ and has:

NameVersionType
git1:2.39.5-0+deb12u3deb
github.com/go-task/task/v3v3.52.0go-module
pre-commit4.6.1python
python3.14.6UnknownPackage

Dockerhub Overview page⁠ has the details of the last published image.

⁠Versioning

Docker tag definition:

  • the pre-commit version used,
  • a dash
  • an increment to differentiate build with the same version starting at 001
<pre-commit_version>-<increment>

Example: 3.6.1-001

⁠Signature and attestation

Cosign⁠ public key:

-----BEGIN PUBLIC KEY-----
MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEa3yV6+yd/l4zh/tfT6Tx+zn0dhy3
BhFqSad1norLeKSCN2MILv4fZ9GA6ODOlJOw+7vzUvzZVr9IXnxEdjoWJw==
-----END PUBLIC KEY-----

The public key is also available online: https://gitlab.com/op_so/docker/cosign-public-key/-/raw/main/cosign.pub⁠.

To verify an image:

cosign verify --key cosign.pub $IMAGE_URI

To verify and get the software bill of materials (SBOM) attestation:

cosign verify-attestation --key cosign.pub --type spdxjson $IMAGE_URI | jq '.payload | @base64d | fromjson | .predicate'

⁠Authors

⁠License

This program is free software: you can redistribute it and/or modify it under the terms of the MIT License (MIT). See the LICENSE⁠ for details.

Tag summary

Content type

Image

Digest

sha256:af3c4972d…

Size

98.7 MB

Last updated

2 months ago

docker pull jfxs/pre-commit