Repository navigation
Commit d7f6a6a
committed
fix(docker): adopt hadolint 2.15.1 and fix the four findings it reports
Follow-up to the digest pin in the previous commit, which restored the gate by
freezing the linter at 2.14.0. Freezing is not the end state: 2.14.0 reports
nothing only because it predates the rules, so staying there would have greened
CI by un-seeing findings rather than by addressing them.
Move the pin forward to 2.15.1, the version that surfaced them, and fix all four
in the Dockerfiles. No `.hadolint.yaml` ignore entries and no inline
`# hadolint ignore=` directives are used.
DL3066, non-numeric user id (Dockerfile:149, Dockerfile.test:21,
Dockerfile.dev:62). A name-form USER cannot be verified by Kubernetes
`runAsNonRoot` and similar admission checks, which see only the numeric id.
Dockerfile and Dockerfile.test already pinned their uids explicitly (1000 and
10001), so those are substitutions with no behaviour change. Dockerfile.dev
created its user with `adduser -S`, which takes the first free system id and so
varies with the base image; its uid/gid are now pinned to 1001 so the numeric
USER has a value fixed at build time rather than discovered. Nothing outside
Dockerfile.dev refers to `devuser`, so the changed id is contained.
DL3025, JSON notation for CMD/ENTRYPOINT (Dockerfile:165). The flagged line is
the HEALTHCHECK CMD, not the container ENTRYPOINT/CMD, which were already exec
form. It reads `curl -f http://localhost:8080/health || exit 1`, where `||` is a
shell operator: a naive exec-form list would pass `||` and `exit` to curl as
literal arguments and the healthcheck would stop reporting unhealthy correctly.
Written instead as `["/bin/sh", "-c", "..."]`, which is JSON notation and the
same process tree the shell form produced, with the dependency on a shell
declared rather than implied.
Verified, with Docker available locally:
- hadolint 2.15.1 against the three Dockerfiles: exit 0.
- All three images build: Dockerfile, Dockerfile.dev, Dockerfile.test, exit 0.
- Runtime identity is unchanged where it was already pinned:
uid=1000(cudly) in the main image, uid=10001(e2e) in the test image, and
uid=1001(devuser) in the dev image.
- The healthcheck is recorded as
["CMD","/bin/sh","-c","curl -f http://localhost:8080/health || exit 1"] and
exercised both directions: exit 1 with no server listening (so `||` is
evaluated by the shell rather than handed to curl) and exit 0 on the
short-circuit path.
Closes #16951 parent 218f385 commit d7f6a6a
4 files changed
Lines changed: 37 additions & 16 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
67 | 67 | | |
68 | 68 | | |
69 | 69 | | |
70 | | - | |
71 | | - | |
72 | | - | |
73 | | - | |
74 | | - | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
75 | 75 | | |
76 | | - | |
77 | | - | |
78 | | - | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
79 | 84 | | |
80 | 85 | | |
81 | 86 | | |
82 | 87 | | |
83 | 88 | | |
84 | | - | |
| 89 | + | |
85 | 90 | | |
86 | 91 | | |
87 | 92 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
145 | 145 | | |
146 | 146 | | |
147 | 147 | | |
148 | | - | |
149 | | - | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
150 | 153 | | |
151 | 154 | | |
152 | 155 | | |
| |||
162 | 165 | | |
163 | 166 | | |
164 | 167 | | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
165 | 174 | | |
166 | | - | |
| 175 | + | |
167 | 176 | | |
168 | 177 | | |
169 | 178 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
55 | 55 | | |
56 | 56 | | |
57 | 57 | | |
58 | | - | |
59 | | - | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
60 | 64 | | |
61 | 65 | | |
62 | | - | |
| 66 | + | |
| 67 | + | |
63 | 68 | | |
64 | 69 | | |
65 | 70 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
21 | | - | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
22 | 24 | | |
23 | 25 | | |
24 | 26 | | |
| |||
0 commit comments