Run the Gradle build as a non-root user - #400
Open
kerfern wants to merge 1 commit into
Open
Conversation
kerfern
requested review from
a team,
gibson9583,
jonbartels,
kayyagari,
kpalang,
mgaffigan,
ssrowe and
tonygermano
August 5, 2026 11:57
Contributor
|
@kerfern thanks for the PR. Can you update with DCO? Looks good to me otherwise |
The builder stage ran Gradle as root, so Log4jMigrationsTest's read-only file assertion failed - root ignores POSIX permission bits. Building the Dockerfile from scratch therefore either failed on that test or had to skip the test suite entirely. Drop to the ubuntu user (uid 1000) that the base image already ships - the same account the runner stages rename to engine. Signed-off-by: Ker Fern Tan <kerfern@hotmail.com>
kerfern
force-pushed
the
fix/nonroot-gradle-builder
branch
from
August 6, 2026 02:14
be5add9 to
998eb93
Compare
Author
|
Signed off and force-pushed: The tree hash is identical ( @mgaffigan re-review when you get a chance, and thanks for the quick look. |
mgaffigan
approved these changes
Aug 6, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The
builderstage in the rootDockerfilehas noUSERdirective, so Gradle runs as root. Root ignores POSIX permission bits, which breaksLog4jMigrationsTest.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 buildof 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
ubuntuuser (uid 1000) thatubuntu:noblealready ships, rather than creating a new one — it's the same account the runner stages already rename toengine.Notes on the details:
chown ubuntu:ubuntu /apphappens afterapt-get, which still needs root.$HOME/.sdkman; Docker setsHOME=/home/ubuntuonceUSER ubuntuis active, so no sdkman path changes were needed./root/.gradle/...to/home/ubuntu/.gradle/...withuid=1000,gid=1000.libnative-platform.sointo~/.gradle/native, outside both mounts. A plainmkdir -p /home/ubuntu/.gradlelayer before the build covers that. Without it the build fails withCould not initialize native services > Failed to load native library 'libnative-platform.so' for Linux aarch64.Verified on
linux/arm64with tests enabled (no skip flags): 636 tests, 0 failures, 0 errors, including all fourLog4jMigrationsTestcases. The runner stage is untouched and the final image size is unchanged.