Skip to content

Commit c254621

Browse files
authored
Adds more global hadolint ignores with reasoning (#782)
* Adds more global hadolint ignores with reasoning * Move all hadolint ignores to a config file * Soothe yamllint * Test if hadolint still works * Anoter test * More testing * More testing * Revert test
1 parent e56dfe2 commit c254621

File tree

25 files changed

+31
-175
lines changed

25 files changed

+31
-175
lines changed

.hadolint.yaml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
---
2+
ignored:
3+
# Warning: Use WORKDIR to switch to a directory.
4+
# https://github.com/hadolint/hadolint/wiki/DL3003
5+
# Reason: We use WORKDIR where appropriate and `cd` otherwise to condense RUN blocks, this warning is annoying
6+
- DL3003
7+
8+
# Warning: Always tag the version of an image explicitly.
9+
# https://github.com/hadolint/hadolint/wiki/DL3006
10+
# Reason: We use buildx which handles the build graph, no explicit image tags necessary
11+
- DL3006
12+
13+
# Warning: Use the -y switch to avoid manual input dnf install -y <package>
14+
# https://github.com/hadolint/hadolint/wiki/DL3038
15+
# Reason: We set `assumeyes=True` in dnf.conf in our base image
16+
- DL3038
17+
18+
# Warning: Specify version with dnf install -y <package>-<version>
19+
# https://github.com/hadolint/hadolint/wiki/DL3041
20+
# Reason: It's good advice, but we're not set up to pin versions just yet
21+
- DL3041
22+
23+
# Warning: Set the SHELL option -o pipefail before RUN with a pipe in it
24+
# https://github.com/hadolint/hadolint/wiki/DL4006
25+
# Reason: We inherit the SHELL from our base image and that sets it
26+
- DL4006
27+
28+
# Use cd ... || exit in case cd fails.
29+
# https://github.com/koalaman/shellcheck/wiki/SC2164
30+
# Reason: Ignoring because we inherit SHELL from the base image which contains "-e" for bash
31+
- SC2164

airflow/Dockerfile

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,11 @@
11
# syntax=docker/dockerfile:1.8.1@sha256:e87caa74dcb7d46cd820352bfea12591f3dba3ddc4285e19c7dcd13359f7cefd
22

3-
# Ignoring DL3038 globally because set `assumeyes=True` in dnf.conf in our base image
4-
# Ignoring DL4006 globally because we inherit the SHELL from our base image
5-
# hadolint global ignore=DL3038,DL4006
6-
73
ARG GIT_SYNC
84

95
# For updated versions check https://github.com/kubernetes/git-sync/releases
106
# which should contain a image location (e.g. registry.k8s.io/git-sync/git-sync:v3.6.8)
117
FROM oci.stackable.tech/sdp/git-sync:${GIT_SYNC} as gitsync-image
128

13-
# Not tagging base image because it is built as part of the same process
14-
# hadolint ignore=DL3006
159
FROM stackable/image/statsd_exporter AS statsd_exporter-builder
1610

1711
FROM stackable/image/vector AS airflow-build-image

druid/Dockerfile

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,5 @@
11
# syntax=docker/dockerfile:1.8.1@sha256:e87caa74dcb7d46cd820352bfea12591f3dba3ddc4285e19c7dcd13359f7cefd
22

3-
# Ignoring DL3038 globally because set `assumeyes=True` in dnf.conf in our base image
4-
# Ignoring DL4006 globally because we inherit the SHELL from our base image
5-
# Ignoring SC2164 globally because we inherit SHELL from the base image which contains "-e" for bash
6-
# hadolint global ignore=DL3038,DL4006,SC2164
7-
8-
# hadolint ignore=DL3006
93
FROM stackable/image/java-devel AS druid-builder
104

115
ARG PRODUCT
@@ -50,9 +44,6 @@ COPY --chown=stackable:stackable druid/stackable/patches/${PRODUCT} /stackable/a
5044
# with a "directory not empty" error on the first builder to finish, as other builders
5145
# are still working in the cache directory.
5246

53-
# Ignoring this lint because we need to use `cd` in order to keep everything in one command
54-
# (and therefore layer)
55-
# hadolint ignore=DL3003
5647
RUN --mount=type=cache,id=maven-${PRODUCT},uid=1000,target=/stackable/.m2/repository \
5748
--mount=type=cache,id=npm-${PRODUCT},uid=1000,target=/stackable/.npm \
5849
--mount=type=cache,id=cache-${PRODUCT},uid=1000,target=/stackable/.cache \
@@ -82,7 +73,6 @@ fi
8273
curl --fail -L "https://repo.stackable.tech/repository/packages/druid/druid-opa-authorizer-${AUTHORIZER}.tar.gz" | tar -xzC /stackable/apache-druid-${PRODUCT}/extensions
8374
EOF
8475

85-
# hadolint ignore=DL3006
8676
FROM stackable/image/java-base AS final
8777

8878
ARG PRODUCT

hadoop/Dockerfile

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,5 @@
11
# syntax=docker/dockerfile:1.8.1@sha256:e87caa74dcb7d46cd820352bfea12591f3dba3ddc4285e19c7dcd13359f7cefd
22

3-
# Ignoring DL3038 globally because set `assumeyes=True` in dnf.conf in our base image
4-
# Ignoring DL4006 globally because we inherit the SHELL from our base image
5-
# hadolint global ignore=DL3038,DL4006
6-
7-
# hadolint ignore=DL3006
83
FROM stackable/image/java-devel AS builder
94

105
ARG PRODUCT

hbase/Dockerfile

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,7 @@
11
# syntax=docker/dockerfile:1.8.1@sha256:e87caa74dcb7d46cd820352bfea12591f3dba3ddc4285e19c7dcd13359f7cefd
22

3-
# Ignoring DL3038 globally because set `assumeyes=True` in dnf.conf in our base image
4-
# Ignoring DL4006 globally because we inherit the SHELL from our base image
5-
# Ignoring SC2164 globally because we inherit SHELL from the base image which contains "-e" for bash
6-
# hadolint global ignore=DL3038,DL4006,SC2164
7-
83
FROM stackable/image/hadoop AS hadoop-builder
94

10-
# hadolint ignore=DL3006
115
FROM stackable/image/java-devel AS hbase-builder
126

137
ARG PRODUCT
@@ -44,11 +38,6 @@ COPY --chown=stackable:stackable hbase/stackable/jmx/config${JMX_EXPORTER} /stac
4438
# builder containers will share the same cache and the `rm -rf` commands will fail
4539
# with a "directory not empty" error on the first builder to finish, as other builders
4640
# are still working in the cache directory.
47-
48-
# Ignoring this because we set the shell to bash in our base image and hadolint/shellcheck doesn't know about it
49-
# DL3003 Ignoring the lint about using workdir instead of cd because we need to use `cd` in order
50-
# to keep everything in one command (and therefore layer)
51-
# hadolint ignore=SC3060,SC3010,DL3003
5241
RUN --mount=type=cache,id=maven-hbase-${PRODUCT},uid=1000,target=/stackable/.m2/repository <<EOF
5342
###
5443
### HBase
@@ -97,7 +86,6 @@ if [ "${DELETE_CACHES}" = "true" ] ; then
9786
fi
9887
EOF
9988

100-
# hadolint ignore=DL3006
10189
FROM stackable/image/java-devel AS opa-authorizer-builder
10290

10391
ARG OPA_AUTHORIZER
@@ -106,8 +94,6 @@ ARG DELETE_CACHES
10694
USER stackable
10795
WORKDIR /stackable
10896

109-
# Ignoring this because we set the shell to bash in our base image and hadolint/shellcheck doesn't know about it
110-
# hadolint ignore=SC3060,SC3010
11197
RUN --mount=type=cache,id=maven-opa,uid=1000,target=/stackable/.m2/repository <<EOF
11298

11399
###
@@ -133,7 +119,6 @@ if [ "${DELETE_CACHES}" = "true" ] ; then
133119
fi
134120
EOF
135121

136-
# hadolint ignore=DL3006
137122
FROM stackable/image/java-devel AS hbase-operator-tools-builder
138123

139124
ARG HBASE_OPERATOR_TOOLS
@@ -195,7 +180,6 @@ EOF
195180

196181
# Splitting this out into its own builder so that Hadoop & HBase can be built in parallel
197182
# envsubst is only available in java-devel which is why we don't just do this in the final image
198-
# hadolint ignore=DL3006
199183
FROM stackable/image/java-devel AS hadoop-s3-builder
200184

201185
ARG PRODUCT
@@ -223,8 +207,6 @@ chmod +x /stackable/bin/export-snapshot-to-s3
223207
rm /stackable/bin/export-snapshot-to-s3.env
224208
EOF
225209

226-
227-
# hadolint ignore=DL3006
228210
FROM stackable/image/java-devel AS phoenix-builder
229211

230212
ARG PRODUCT

hello-world/Dockerfile

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
11
# syntax=docker/dockerfile:1.8.1@sha256:e87caa74dcb7d46cd820352bfea12591f3dba3ddc4285e19c7dcd13359f7cefd
22

3-
# Ignoring DL3038 globally because set `assumeyes=True` in dnf.conf in our base image
4-
# Ignoring DL4006 globally because we inherit the SHELL from our base image
5-
# hadolint global ignore=DL3038,DL4006
6-
73
FROM stackable/image/java-base
84

95
ARG PRODUCT

hive/Dockerfile

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,7 @@
11
# syntax=docker/dockerfile:1.8.1@sha256:e87caa74dcb7d46cd820352bfea12591f3dba3ddc4285e19c7dcd13359f7cefd
22

3-
# Ignoring DL3038 globally because set `assumeyes=True` in dnf.conf in our base image
4-
# Ignoring DL4006 globally because we inherit the SHELL from our base image
5-
# hadolint global ignore=DL3038,DL4006
6-
73
FROM stackable/image/hadoop AS hadoop-builder
84

9-
# This layer has Java 8 installed.
10-
# hadolint ignore=DL3006
115
FROM stackable/image/java-devel AS builder
126

137
# Apache Hive up t0 4.x(!) officially requires Java 8 (there is no distincion between building and running). As of

java-base/Dockerfile

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,6 @@
22
#
33
# Provides the common Java Runtime for SDP products
44
#
5-
# Ignoring DL3038 globally because set `assumeyes=True` in dnf.conf in our base image
6-
# Ignoring DL4006 globally because we inherit the SHELL from our base image
7-
# hadolint global ignore=DL3038,DL4006
8-
95
FROM stackable/image/vector
106

117
ARG PRODUCT

java-devel/Dockerfile

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,13 @@
44
# Base imaege for builder stages
55
#
66

7-
# hadolint ignore=DL3006
87
FROM stackable/image/stackable-base
98

109
ARG PRODUCT
1110

1211
# We need to use EPEL, as openjdk 22 is not shipped with UBI9
1312
RUN rpm --install --replacepkgs https://dl.fedoraproject.org/pub/epel/epel-release-latest-9.noarch.rpm
1413

15-
# hadolint ignore=DL3041
1614
RUN microdnf update && \
1715
microdnf install -y \
1816
cmake \

kafka-testing-tools/Dockerfile

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,7 @@
11
# syntax=docker/dockerfile:1.8.1@sha256:e87caa74dcb7d46cd820352bfea12591f3dba3ddc4285e19c7dcd13359f7cefd
22

3-
# Ignoring DL3038 globally because set `assumeyes=True` in dnf.conf in our base image
4-
# Ignoring DL4006 globally because we inherit the SHELL from our base image
5-
# hadolint global ignore=DL3038,DL4006
6-
7-
# Not tagging base image because it is built as part of the same process
8-
# hadolint ignore=DL3006
93
FROM stackable/image/kcat AS kcat
104

11-
# Not tagging base image because it is built as part of the same process
12-
# hadolint ignore=DL3006
135
FROM stackable/image/stackable-base AS final
146

157
ARG PRODUCT

0 commit comments

Comments
 (0)