← Back to Pull requests

Run the Gradle build as a non-root user #400

Closed
unknown closed this pull request without merging on Aug 06, 2026 18:21 UTC
View on GitHub
unknown unknown commented on Aug 05, 2026 11:57 UTC
Author

The builder stage in the root Dockerfile has no USER directive, so Gradle runs as root. Root ignores POSIX permission bits, which breaks Log4jMigrationsTest.testMigrateLog4jFailsGracefullyWithReadOnlyFile — that test chmods a file read-only and asserts a write fails, but as root the write succeeds.

The practical effect is that a from-scratch docker build of the published Dockerfile either fails on that test, or has to be run with tests skipped — so the image build loses its test signal.

This drops to the ubuntu user (uid 1000) that ubuntu:noble already ships, rather than creating a new one — it's the same account the runner stages already rename to engine.

Notes on the details:

  • chown ubuntu:ubuntu /app happens after apt-get, which still needs root.

  • sdkman installs into $HOME/.sdkman; Docker sets HOME=/home/ubuntu once USER ubuntu is active, so no sdkman path changes were needed.

  • The Gradle cache mounts move from /root/.gradle/... to /home/ubuntu/.gradle/... with uid=1000,gid=1000.

  • One subtlety worth flagging for reviewers: the cache mounts own only the mounted subdirectories, not their parent, and Gradle extracts libnative-platform.so into ~/.gradle/native, outside both mounts. A plain mkdir -p /home/ubuntu/.gradle layer before the build covers that. Without it the build fails with Could not initialize native services > Failed to load native library 'libnative-platform.so' for Linux aarch64.
  • Verified on linux/arm64 with tests enabled (no skip flags): 636 tests, 0 failures, 0 errors, including all four Log4jMigrationsTest cases. The runner stage is untouched and the final image size is unchanged.

    Diff: 209 lines (+156 / -53) across 2 files Reviewer: pacmano1 Review duration: 1823m
    All Vouch review confidence checks passed
    Residual risk 0.14 = Change Risk (0.36) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.36 · 209 lines diff across 2 files
    0.36
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    60%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.320
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #400"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 60.5% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 36.4% (MEDIUM) · Higher = larger blast radius
    36.4%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 60.5% · Lower = rushed or shallow review
    60.5%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 14.4% · Safe to merge
    14.4%