Skip to content

Float the base images and update packages at build time - #1

Merged
aaaaaaaalex merged 4 commits into
mainfrom
cve/image-build-hardening
Sep 30, 2026
Merged

aaaaaaaalex merged 4 commits into
mainfrom
cve/image-build-hardening

Conversation

@aaaaaaaalex

@aaaaaaaalex aaaaaaaalex commented Sep 28, 2026 •

Copy link
Copy Markdown
Collaborator

📝 Links

📝 Description

Brings the image up to date and keeps it there.

  • Bases float. Both stages were pinned by digest, so they never picked up rebuilt bases. The builder now uses ubi9/nodejs-22:latest; the web server moves from nginx-122 to ubi9/nginx-126:latest, because the 1.22 image has not been rebuilt since January and floating it would gain nothing.
  • Runtime packages are updated at build time, picking up errata released since the base was last rebuilt. Updating nginx resets /var/log/nginx to the package's root:root 0711, discarding the base image's ownership for uid 1001 — without restoring it, the container crash-loops on startup — so the ownership is re-applied before dropping back to uid 1001.
  • The update re-runs on every build. Otherwise it is served from the build cache whenever the base is unchanged, shipping updates as old as the cached layer. BUILD_DATE is declared ahead of the update; builds pass a new value each time.
  • Non-breaking dependency security fixes (npm audit fix). Shipped dependencies go from 3 high to 2; the remaining two (react-router, via the console SDK) are only fixed in an SDK 4.23 prerelease.

Only build/Containerfile and package-lock.json change; build/Containerfile-downstream is untouched.

🎥 Demo

Built and run locally:

  • Runs as uid 1001 with no restarts; /var/log/nginx owned by 1001:0; RHEL 9.8, nginx 1.26.3; plugin-manifest.json served (HTTP 200).
  • Entry script still uses the 4.22 loader: __load_plugin_entry__("forklift-console-plugin", …).
  • No package updates pending in the built image.
  • Same BUILD_DATE twice leaves the update cached; a new value makes it re-run.

📝 CC://

🤖 Generated with Claude Code

aaaaaaaalex and others added 4 commits September 28, 2026 11:09
Both stages were pinned by digest, so they never picked up rebuilt bases.
The web server moves from nginx 1.22 to 1.26: the 1.22 image is no longer
rebuilt, so floating it would gain nothing.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Alex O'Regan <alex.oregan@tigera.io>
A floating base only helps once the registry rebuilds it; updating at
build time also picks up errata released since. The update reverts
/var/log/nginx to the nginx package's root:root ownership, so the base
image's chown is re-applied before dropping back to uid 1001.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Alex O'Regan <alex.oregan@tigera.io>
The update layer was served from the build cache whenever the base image
was unchanged, so the image could ship updates days old. Declaring
BUILD_DATE ahead of the update makes it re-run when the build passes a
new value.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Alex O'Regan <alex.oregan@tigera.io>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Alex O'Regan <alex.oregan@tigera.io>
Copilot AI lite review requested due to automatic review settings September 28, 2026 11:52

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

Image build workflows must pass a changing BUILD_DATE to ensure package updates rerun.

Review effort: Lite
Findings: 1 Medium severity

Open (1)
What changed in this PR

Updates container base images, applies runtime package updates, and refreshes dependency resolutions.

Changes:

  • Floats UBI Node.js and nginx base images.
  • Adds runtime package updates and restores nginx log permissions.
  • Updates dependency lockfile entries.
File Summary
package-lock.json Refreshes dependency resolutions and metadata.
build/​Containerfile Floats images and adds runtime package updates; build paths do not pass BUILD_DATE, so updates may remain cached.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread build/Containerfile
Comment on lines +25 to +28
# BUILD_DATE differs on every build, so declaring it here re-runs the package
# update rather than reusing a cached layer from an earlier build.
ARG BUILD_DATE=unknown
RUN dnf -y update && \
@aaaaaaaalex
aaaaaaaalex merged commit 364147e into main Sep 30, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants