Skip to content

Docker: exclude build artifacts from dependency image (main) - #1683

Open
vidiecan wants to merge 1 commit into
mainfrom
fix/main-slim-dependency-image
Open

vidiecan wants to merge 1 commit into
mainfrom
fix/main-slim-dependency-image

Conversation

@vidiecan

@vidiecan vidiecan commented Nov 17, 2026 •

Copy link
Copy Markdown

Change set

Deleting /app in a later Docker layer hides build artifacts but leaves them in the published dependency image.

Separate the clean build-tool base from dependency resolution, then copy only /home/dspace/.m2 into the final stage. Use the Maven 3.9/Temurin base in place of the older OpenJDK slim Maven base, retaining Java 11 and bundled Git. Source compilation continues in the disposable build stage. Keep the Maven 3.9 family to avoid introducing Maven 3.10 validation changes into older customer POMs. Preserve this branch's Java 11, Maven invocation, flags, cache ownership and final user.

Related integration fix: #1677. This PR targets main directly.

Test evidence

  • git diff --check passed.
  • docker build -f Dockerfile.dependencies -t dq-audit/dependencies:main . passed with the branch's unchanged Maven command.
  • Built --target base and compared RootFS layer digests: the final image contains exactly the 12 clean base layers plus one Maven-cache layer; dependency build layers are absent.
  • Network-disabled, read-only smoke checks as dspace passed: /app is empty, cached JARs exist, cache and workdir ownership are correct, exactly one JVM is installed, and Java 11, Maven and Git execute.

Application code is unchanged. No application runtime/UI behavior changes; no separate manual UI scenario is needed. Repository CI runs its existing checks.

Risk & rollback

The dependency-cache image remains a build input, not an application runtime image. The source-build variants now use the Maven version bundled with the official Maven image; their full dependency build passed locally. Revert this Dockerfile change and rebuild to restore the previous image layout. No deployment or merge is included.

Existing CI blocker

The local dependency image build and layer/smoke checks passed. GitHub's unit/integration jobs fail during setup because this branch still uses actions/cache@v2 and actions/upload-artifact@v2. Those workflow files are unchanged by this PR. Failure log.

The Docker workflow also reaches the unchanged application Dockerfile and fails resolving openjdk:11-slim (run). Fixing the application runtime base is separate from this dependency-image change.

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.

🟢 Approval recommended

No active issues were identified, and the restructuring keeps source files and build artifacts out of the published dependency image.

No open issues 🎉

What changed in this PR

This PR restructures the Docker dependency image so source files and build artifacts remain in a disposable Maven stage, while the published image retains only the clean Maven/Temurin base and dependency cache.

Changes:

  • Updates the base image to Maven 3.9 with Eclipse Temurin while preserving Java 11, Maven, and Git support.
  • Separates dependency resolution into a disposable build stage.
  • Copies only /home/dspace/.m2 into the published image.
  • The layer comparison evidence should be rerun against the default build or final target to verify the published image.
File Description
Dockerfile.dependencies Separates the clean base, disposable dependency-build, and cache-only final stages while updating the Maven/Temurin base image.

Review effort: Lite

This branch has not been deployed

No deployments
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.

2 participants