Skip to content

add hadolint dockerfile linter to pre-commit checks #693

Open
@kbroch-rivosinc

Description

@kbroch-rivosinc

hadolint could help us lint dockerfile for best practices.

implementation details:

We'd want to use the non-docker hook: https://github.com/hadolint/hadolint/blob/master/.pre-commit-hooks.yaml
and therefore need make sure the hadolint binary was added to the UDB dockerfile and container.def

Running hadolint on existing dockerfile:

kbroch@kbroch-mac.local:~/rvi/non-repo-repos/riscv-unified-db on  main via  v22.14.0 via 🐍 v3.13.3 via 💎 v3.2.3 took 35s
❯ hadolint .devcontainer/Dockerfile
.devcontainer/Dockerfile:8 DL3009 info: Delete the apt-get lists after installing something
.devcontainer/Dockerfile:8 DL3059 info: Multiple consecutive `RUN` instructions. Consider consolidation.
.devcontainer/Dockerfile:11 DL3008 warning: Pin versions in apt get install. Instead of `apt-get install <package>` use `apt-get install <package>=<version>`
.devcontainer/Dockerfile:11 DL3059 info: Multiple consecutive `RUN` instructions. Consider consolidation.
.devcontainer/Dockerfile:38 DL3059 info: Multiple consecutive `RUN` instructions. Consider consolidation.
.devcontainer/Dockerfile:39 DL3059 info: Multiple consecutive `RUN` instructions. Consider consolidation.
.devcontainer/Dockerfile:40 SC3009 warning: In POSIX sh, brace expansion is undefined.
.devcontainer/Dockerfile:40 DL3059 info: Multiple consecutive `RUN` instructions. Consider consolidation.
kbroch@kbroch-mac.local:~/rvi/non-repo-repos/riscv-unified-db on  main via  v22.14.0 via 🐍 v3.13.3 via 💎 v3.2.3
❯ echo $?
1

Metadata

Metadata

Labels

enhancementNew feature or request

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions