Skip to content

Add support for linting Dockerfiles

Pedro Pombeiro requested to merge dockerfile-lint into 9524-add-shellcheck-linter

Based on the 9524-add-shellcheck-linter branch

This MR has been mistakingly merged into the parent branch (non-master), so #9524 now contains this approved MR.

What does this MR do?

Adds Dockerfile linting to make lint target (including in the CI job).

Why was this MR needed?

#25412

Are there points in the code the reviewer needs to double check?

We use hadolint, but don't try to lint Windows Dockerfiles due to hadolint/shellcheck not understanding the escape directive. It looks like we could use hadolint in this way, and just accept that for now Powershell scripts embedded in the Dockerfiles won't get checked. But at least we gain all the other advantages of hadolint (e.g. running shellcheck on Dockerfile RUN commands).

Example of a failing job: https://gitlab.com/gitlab-org/gitlab-runner/-/jobs/519667674

Does this MR meet the acceptance criteria?

  • Documentation created/updated
  • Added tests for this feature/bug
  • In case of conflicts with master - branch was rebased

What are the relevant issue numbers?

#25412 https://gitlab.com/gitlab-com/legal-and-compliance/-/issues/43

Edited by Pedro Pombeiro

Merge request reports