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

withBinaryFile: does not exist (No such file or directory) #80

Open
pantelis-karamolegkos opened this issue May 6, 2023 · 3 comments · May be fixed by #84
Open

withBinaryFile: does not exist (No such file or directory) #80

pantelis-karamolegkos opened this issue May 6, 2023 · 3 comments · May be fixed by #84

Comments

@pantelis-karamolegkos
Copy link

I have the following Dockerfile

FROM golang:1.19 AS builder

ARG WDIR=myapp
ARG VERSION

COPY . ${WDIR}

WORKDIR ${WDIR}

RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 \
    go build -a \
    --ldflags="-X main.buildVersion=${VERSION} -s -w" \
    -o /myapp

FROM gcr.io/myregistry/base/golang/alpine/1.19:stable

COPY --from=builder /myapp /bin/myapp

CMD ["/bin/myapp"]

This fails the lint with:

hadolint: ./myapp/Dockerfile: withBinaryFile: does not exist (No such file or directory)

The Dockerfile works as expected though

@szepeviktor
Copy link

Could it be the reason that there is no Dockerfile in the root of the project?

@gnzsnz
Copy link

gnzsnz commented Nov 28, 2023

Same issue here

my .pre-commit.yaml file

repos:
  - repo: https://github.com/hadolint/hadolint
    rev: v2.12.0
    hooks:
      - id: hadolint-docker

output

Lint Dockerfiles.........................................................Failed
- hook id: hadolint-docker
- exit code: 1

hadolint: Dockerfile.template: withBinaryFile: does not exist (No such file or directory)
hadolint: latest/Dockerfile.tws: withBinaryFile: does not exist (No such file or directory)

The files stated on the output are there, and the linter can find them. however it fails.

If I change my pre-commit config file to

repos:
  - repo: https://github.com/hadolint/hadolint
    rev: v2.12.0
    hooks:
      - id: hadolint

it works fine

@nvtkaszpir
Copy link

nvtkaszpir commented Jan 11, 2024

I've seen this when there is no Dockerfile in the repo in any directory or subdirectory.
This usually happens when the repo is fresh (no Dockerfile yet) or if the Dockerfiles were deleted in the commit.
The first one is quite obvious, but the second one means that github action is executed when the files were deleted and actually step should be skipped.

So this Github Action should be patched to support this, I do not have solution for it.

Yet if anyone is interested I can provide custom GitHub workflow that handles the case (skip action if no Dockerfiles are changed or are deleted). If someone is interested I can get it next week.
With proper github action workflow in the script it would probably take a bit more time, but is also doable.

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 a pull request may close this issue.

4 participants