Skip to content

Lint and harden the Dockerfile - #2492

Merged
Flo0807 merged 1 commit into
developfrom
lint-and-harden-dockerfile
Nov 8, 2026
Merged

Flo0807 merged 1 commit into
developfrom
lint-and-harden-dockerfile

Conversation

@Flo0807

@Flo0807 Flo0807 commented Nov 8, 2026

Copy link
Copy Markdown
Collaborator

Lint

A new CI job Lint Dockerfile runs hadolint (via hadolint/hadolint-action v3.5.0, hadolint 2.15.1). The config is in .hadolint.yaml, and CONTRIBUTING.md › Dockerfile shows how to run it locally.

Fixed findings:

  • SHELL with pipefail in the base stage (DL4006)
  • --no-install-recommends and rm -rf /var/lib/apt/lists/* in the runtime stage (DL3015, DL3009)
  • RUN mkdir demo removed, WORKDIR creates the directory; mix compile and mix assets.deploy in one RUN (DL3059)
  • Numeric runtime user 65534:65534 (nobody:nogroup), so a runtime can check that the user is not root (DL3066)

Ignored:

  • DL3008 (pin apt package versions) globally: pinned versions break the build whenever Ubuntu replaces them in its archive. The base images are pinned and updated by Renovate.
  • DL3015 in the base stage: it is also the development container (compose.yml), so it keeps recommended packages such as openssh-client and less for git.
  • SC1010 on mix do …: ShellCheck mistakes the mix task for the shell keyword.
  • DL3003 on the download step, which cds into a temporary directory that the same RUN removes.

Hardening

  • Node.js and bun downloads are verified. Node.js came from the NodeSource setup script (curl … | bash), bun from bun.sh/install, neither checked. Both now download the release and verify it against its GPG-signed SHASUMS256.txt, like the official node and oven/bun images: Node.js only accepts the release keys listed in the Dockerfile, bun only its signing key. On amd64 bun uses the x64-baseline build, so it also runs on CPUs without AVX2.
  • Node.js is pinned (NODE_VERSION=26.13.0, same major as CI) and updated by Renovate instead of following the current LTS.
  • env-secrets-expand.sh is vendored into .docker/opt/scripts/ (same commit ed67c79 as before, source noted in the header) instead of being downloaded with ADD on every build.
  • Only /opt/app belongs to nobody in the runtime image. Before, chown -R nobody /opt let the release process overwrite the entrypoint scripts in /opt/scripts.

Checked

  • hadolint passes locally with the config, and without it reports only DL3008.
  • Local docker build --target runtime (arm64): the Node.js signature and checksum verify (Good signature, node-v26.13.0-linux-arm64.tar.xz: OK).
  • Not checked locally: the bun download and everything after it. GitHub release downloads returned 503/504 during the build. The Build and push image (Demo) job of this PR builds the image on amd64.

Follow-up

Once this is merged, Lint Dockerfile becomes a required check on develop.

Lint the Dockerfile with hadolint in a new CI job and fix its findings:
pipefail in the base stage, --no-install-recommends in the runtime stage,
fewer RUN layers and a numeric runtime user.

Harden the image:
- Verify the Node.js and bun downloads against the GPG-signed SHASUMS256.txt
  of each release, like the official node and oven/bun images. Node.js was
  installed by the NodeSource setup script and bun by bun.sh/install, both
  unverified. Node.js is now pinned and updated by Renovate.
- Vendor env-secrets-expand.sh instead of downloading it on every build.
- Only /opt/app belongs to nobody, so the release cannot modify the
  entrypoint scripts.
@Flo0807 Flo0807 added docker Pull requests that update Docker code ignore-for-release Should not appear in releas notes ci labels Nov 8, 2026
@Flo0807
Flo0807 added this pull request to the merge queue Nov 8, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Nov 8, 2026
@Flo0807
Flo0807 added this pull request to the merge queue Nov 8, 2026
Merged via the queue into develop with commit b2a6aa7 Nov 8, 2026
19 of 20 checks passed
@Flo0807
Flo0807 deleted the lint-and-harden-dockerfile branch November 8, 2026 11:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci docker Pull requests that update Docker code ignore-for-release Should not appear in releas notes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant