diff --git a/Dockerfile b/Dockerfile index 791df4c..0570c0d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,8 @@ FROM ghcr.io/hadolint/hadolint:v2.10.0-debian +# Set default WORKDIR in Dockerfile for easier trace and consistency +WORKDIR /github/workspace + COPY LICENSE README.md problem-matcher.json / COPY hadolint.sh /usr/local/bin/hadolint.sh diff --git a/README.md b/README.md index e2e6b74..95d8e8b 100644 --- a/README.md +++ b/README.md @@ -26,7 +26,7 @@ steps: |----------------------|-----------------------------------------------------------------------------------------------------------------------------------------|--------------------| | `dockerfile` | The path to the Dockerfile to be tested | `./Dockerfile` | | `recursive` | Search for specified dockerfile
recursively, from the project root | `false` | -| `config` | Custom path to a Hadolint config file | `./.hadolint.yaml` | +| `config` | Custom path to a Hadolint config file | | | `output-file` | A sub-path where to save the
output as a file to | | | `no-color` | Don't create colored output (`true`/`false`) | | | `no-fail` | Never fail the action (`true`/`false`) | | diff --git a/hadolint.sh b/hadolint.sh index cb8503a..f223c06 100755 --- a/hadolint.sh +++ b/hadolint.sh @@ -1,5 +1,8 @@ #!/bin/bash +# Set essential environment variables in the container +export {PWD,HOME}=$(pwd) + # The problem-matcher definition must be present in the repository # checkout (outside the Docker container running hadolint). We copy # problem-matcher.json to the home folder. @@ -16,7 +19,7 @@ trap cleanup EXIT echo "::add-matcher::$HOME/problem-matcher.json" if [ -n "$HADOLINT_CONFIG" ]; then - HADOLINT_CONFIG="-c ${HADOLINT_CONFIG}" + HADOLINT_CONFIG="-c ${PWD}/${HADOLINT_CONFIG}" fi if [ -z "$HADOLINT_TRUSTED_REGISTRIES" ]; then