Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to lint multiple dockerfiles, without specifying the action for each? #54

Closed
mfn opened this issue Mar 25, 2022 · 2 comments
Closed

Comments

@mfn
Copy link

mfn commented Mar 25, 2022

With the version on the terminal, I can run it like so and get multiple files linted:

+ $ hadolint Dockerfile*
Dockerfile-test1:9 DL3003 warning: Use WORKDIR to switch to a directory
Dockerfile-test2:21 DL3003 warning: Use WORKDIR to switch to a directory

But with the action, I can't get it working:

      - uses: hadolint/hadolint-action@v2.0.0
        with:
          dockerfile: Dockerfile*

produces

hadolint: Dockerfile*: openBinaryFile: does not exist (No such file or directory)

It acts like I would use single quotes in bash to prevent wildcard expansion:

+ $ hadolint 'Dockerfile*'
hadolint: Dockerfile*: openBinaryFile: does not exist (No such file or directory)
@kgrv-me
Copy link

kgrv-me commented May 18, 2022

Hope I'm not too late to help out.

ISSUE #3 contains a lot of conversation regarding this topic. You have several options:

  1. Using 3rd-party GitHub Action (How do I run multiple files #3 (comment))
  2. Apparently, setting HADOLINT_RECURSIVE environment variable to true seems to work somewhat (How do I run multiple files #3 (comment))
  3. If you don't mind using Docker container, I built one (so it's CI platform agnostic) kgrv/hadolint
    It can scan entire directories (including nested) with simple docker run command
docker run --rm -v PATH:/workspace kgrv/hadolint

Integrate this into GitHub workflow with:

- name: Haskell Dockerfile Linter
  run: docker run --rm -v ${PWD}:/workspace kgrv/hadolint

I hope this helps, cheers!

@mfn
Copy link
Author

mfn commented May 18, 2022

Ah,thanks! Totally forgot about this one.

I made a super-weird workaround:

name: Lint Docker files
on:
  push:
    paths:
      - .github/workflows/docker_lint.yaml
      - .hadolint.yaml
      - Dockerfile*
  workflow_dispatch:

concurrency:
  group: ${{ github.workflow }}-${{ github.ref }}
  cancel-in-progress: true

jobs:
  lint:
    runs-on: ubuntu-latest
    timeout-minutes: 5
    steps:
      - name: Checkout code
        uses: actions/checkout@v3

      - name: Install hadolint
        run: |
          docker pull hadolint/hadolint:latest
          container_id=$(docker create hadolint/hadolint)
          docker cp $container_id:/bin/hadolint .

      - run: ./hadolint --version

      - run: ./hadolint Dockerfile*

Given what you wrote, it feels most natural to just go with https://github.com/jbergstroem/hadolint-gh-action to me, will check it out.

Since I could work it around already and more options are on the table and no one seems to work on the issues reporting here anyway -> closing!

Thanks 🙏🏼

@mfn mfn closed this as completed May 18, 2022
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

No branches or pull requests

2 participants