Skip to content

unpin docker version in pre-commit hook#814

Merged
lorenzo merged 1 commit intohadolint:masterfrom
electriquo:patch-1
Apr 26, 2022
Merged

unpin docker version in pre-commit hook#814
lorenzo merged 1 commit intohadolint:masterfrom
electriquo:patch-1

Conversation

@electriquo
Copy link
Copy Markdown
Contributor

@electriquo electriquo commented Apr 6, 2022

What I did

eliminating inconsistency. e.g. for version 2.10.0, pre-commit hooks points to outdated version

entry: ghcr.io/hadolint/hadolint:v2.9.3 hadolint

How I did it

unpinning the version from the docker hook, behaves in the same manner as the native hook.
this is not the best approach, since each version will pull the latest docker image but will also run on the latest version that is installed on the operating system. the best way to handle the issue is to pin the exact version with each release.

How to verify it

set .pre-commit-config.yaml as follows

  - repo: https://github.com/hadolint/hadolint
    rev: 23b2b76fe7b757658019ca4e080efa208784621b
    hooks:
      - id: hadolint-docker

then execute pre-commit and see whether the latest docker images has been pulled

$ pre-commit run -a hadolint-docker
$ docker run --rm ghcr.io/hadolint/hadolint /bin/hadolint --version
Haskell Dockerfile Linter 2.10.0

@electriquo electriquo marked this pull request as ready for review April 6, 2022 17:35
@lorenzo
Copy link
Copy Markdown
Member

lorenzo commented Apr 6, 2022

maybe better to commit the file after each release in a github action?

@electriquo
Copy link
Copy Markdown
Contributor Author

electriquo commented Apr 6, 2022

@lorenzo i think it will not solve the issue. pre-commit checkouts the repository at the rev and then reads the pre-commit-hooks.yaml, which is where the version of the docker image is specified.

@electriquo
Copy link
Copy Markdown
Contributor Author

@lorenzo any other thoughts?

@lorenzo
Copy link
Copy Markdown
Member

lorenzo commented Apr 14, 2022

I’m not familiar with pre-commit hooks. What do you mean by “it checkouts the commit at the rev”? Do you have to keep updating the version locally?

@electriquo
Copy link
Copy Markdown
Contributor Author

What do you mean by “it checkouts the commit at the rev”?

from pre-commit docs

rev: the revision or tag to clone at.

A sample repository:

repos:
-   repo: https://github.com/pre-commit/pre-commit-hooks
    rev: v1.2.3
    hooks:
    -   ...

@electriquo
Copy link
Copy Markdown
Contributor Author

@lorenzo did i answer your question?

@lorenzo
Copy link
Copy Markdown
Member

lorenzo commented Apr 23, 2022

@foolioo Thanks, I understand what you mean. If this is merged, how do you usually tell docker to update to the latest tag when it is released? Once an image is downloaded to the cache, it will not change anymore

@electriquo
Copy link
Copy Markdown
Contributor Author

@lorenzo there are 3 ways:

  1. you pin and bump the version in the hook with each release (of curse, this can be automated)
  2. use pre-commit with the docker image directly, watch for changes, and update accordingly
  3. expect the dependency in hadolint to be met

alternatives are enumerated by order of best practice.

@lorenzo
Copy link
Copy Markdown
Member

lorenzo commented Apr 26, 2022

Ok, I understand. I think it makes sense to change this. Thanks for your patience

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants