Skip to content

Commit 55177d3

Browse files
committed
Add check for Dockerfiles
1 parent d676290 commit 55177d3

File tree

2 files changed

+46
-0
lines changed

2 files changed

+46
-0
lines changed

.github/workflows/code-quality.yaml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,3 +40,13 @@ jobs:
4040
echo "There were errors in some of the checked files. Please run `json_verify` on such files and fix issues there."
4141
fi
4242
exit "${ret_code}"
43+
44+
- name: Validate Dockerfiles
45+
id: validate-dockerfiles
46+
run: |
47+
type hadolint || sudo apt-get -y install wget \
48+
&& wget --output-document=hadolint https://github.com/hadolint/hadolint/releases/download/v2.12.0/hadolint-Linux-x86_64 \
49+
&& chmod a+x hadolint
50+
echo "Starting Hadolint"
51+
find . -name "Dockerfile" | xargs ./hadolint --config ./ci/hadolint-config.yaml
52+
echo "Hadolint done"

ci/hadolint-config.yaml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
---
2+
3+
# Reference https://github.com/hadolint/hadolint
4+
# hadolint --config ./ci/hadolint-config.yaml <Dockerfile>
5+
6+
# We should revisit this ignore list and reduce it regularly
7+
8+
ignored:
9+
# DL3006 warning: Always tag the version of an image explicitly
10+
- DL3006
11+
# DL3033 warning: Specify version with `yum install -y <package>-<version>`.
12+
- DL3033
13+
# DL3045 warning: `COPY` to a relative destination without `WORKDIR` set.
14+
- DL3045
15+
# DL3041 warning: Specify version with `dnf install -y <package>-<version>`.
16+
- DL3041
17+
# DL3059 info: Multiple consecutive `RUN` instructions. Consider consolidation.
18+
- DL3059
19+
# DL3013 warning: Pin versions in pip. Instead of `pip install <package>` use
20+
# `pip install <package>==<version>` or `pip install --requirement <requirements file>`
21+
- DL3013
22+
# DL4006 warning: Set the SHELL option -o pipefail before RUN with a pipe in it.
23+
# If you are using /bin/sh in an alpine image or if your shell is symlinked to busybox
24+
# then consider explicitly setting your SHELL to /bin/ash, or disable this check
25+
- DL4006
26+
# DL3007 warning: Using latest is prone to errors if the image will ever update.
27+
# Pin the version explicitly to a release tag
28+
- DL3007
29+
# SC3060 warning: In POSIX sh, string replacement is undefined.
30+
- SC3060
31+
# SC2086 info: Double quote to prevent globbing and word splitting.
32+
- SC2086
33+
# SC2046 warning: Quote this to prevent word splitting.
34+
- SC2046
35+
# SC2140 warning: Word is of the form "A"B"C" (B indicated). Did you mean "ABC" or "A\"B\"C"?
36+
- SC2140

0 commit comments

Comments
 (0)