Skip to content

Commit

Permalink
Add docker lint pre-commit using hadolint
Browse files Browse the repository at this point in the history
  • Loading branch information
samiwelthomasHO committed Oct 7, 2022
1 parent 7de9e3d commit f7c54b7
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
6 changes: 6 additions & 0 deletions .githooks/pre-commit
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,17 @@
set -e

JSONNET_FILES_CHANGED=$(git --no-pager diff --cached --name-only --diff-filter=ACM | grep "sonnet" | wc -l)
DOCKERFILE_CHANGED=$(git --no-pager diff --cached --name-only --diff-filter=ACM | grep "Dockerfile" | wc -l)
echo $DOCKERFILE_CHANGED

REPO_ROOT_DIR=$(git rev-parse --show-toplevel)

if [ "$JSONNET_FILES_CHANGED" -gt "0" ]; then
$REPO_ROOT_DIR/monitoring-as-code/fmt.sh
$REPO_ROOT_DIR/monitoring-as-code/lint.sh
git add $REPO_ROOT_DIR
fi

if [ "$DOCKERFILE_CHANGED" -gt "0" ]; then
find $REPO_ROOT_DIR -name Dockerfile -exec sh -c "echo {} && docker run --rm -i ghcr.io/hadolint/hadolint < {}" \;
fi
2 changes: 2 additions & 0 deletions monitoring-as-code/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,6 @@ COPY mixin-defs /mixin-defs
COPY run-mixin.sh /
RUN chmod a+x /usr/local/bin/jb /usr/local/bin/jsonnet /run-mixin.sh

EXPOSE 80003

ENTRYPOINT ["/run-mixin.sh"]

0 comments on commit f7c54b7

Please sign in to comment.