Repository navigation
fix(docker): restore drop-in compatibility and stop emulating the build - #7
Merged
Merged
Conversation
Shadow 9 changed the default duplicates strategy to EXCLUDE, and under that setting mergeServiceFiles() stops merging: it keeps the first META-INF/services file it encounters and drops the rest. The fat jar therefore declared journalist's tinylog writer and none of tinylog's own, so RollingFileWriter was present as a class but never registered. The result was silent. The server started, served artifacts and logged to the console, while /var/log/reposilite stayed empty and the only hint was one line reading "Service implementation 'rolling file' not found". The container image documents that directory as part of its operational contract, so an upgrade would have taken a working log pipeline with it. Shadow 8, which produced the last upstream release, defaulted to INCLUDE.
The split-container work hardened the image in ways that quietly broke the upgrade path it is supposed to offer. Three of them, each invisible to a build and each fatal to an existing deployment. USER 977:977 cut off the entrypoint's root path, which is the only code that acts on PUID and PGID or takes over a data directory owned by somebody else. An operator pointing the image at their existing volume got "Permission denied" on reposilite.db and nothing else. Upstream starts as root and drops privileges itself, so that is what this does again; running unprivileged is now a line in the compose file, where it can be removed for one start when the ownership needs fixing. Pre-creating the service account made the entrypoint's existence guards always true, so PUID and PGID were read and then ignored. An existing account is now adjusted to the requested ids instead. The base image ships an `ubuntu` account holding uid and gid 1000, the most common value anyone puts in PUID, which made PUID=1000 fail outright on "id already in use". Nothing here uses that account. The jar is named after this project, so /app/reposilite.jar is now a symlink beside it: anything overriding entrypoint or command names the jar itself.
Scanning the assembled image instead of only the dependency trees turned up ten fixable CRITICAL and HIGH advisories in the base layer, across curl, libexpat, libssl3 and libxml2. The digest pinned here was already the last one published for the 1.29-alpine line, so there was nothing to bump within it; the patched packages ship in 1.31-alpine, which is what the plain alpine tag now resolves to. The image serves static files through a configuration this project writes, so the nginx version step carries no behaviour change for it. Verified by starting the built image read only, unprivileged and with all capabilities dropped, and confirming it still serves the dashboard and its bundle.
Both Dockerfiles compiled inside the target architecture, so publishing for linux/arm64 ran the entire Gradle build and the entire npm build under QEMU. Neither produces anything architecture specific: a jar holds no machine code and a bundle is HTML, CSS and JavaScript. Pinning the build stages to BUILDPLATFORM leaves only the run stages emulated, where the work is creating an account and copying files. That makes the second architecture cheap enough to stop rationing. It used to be a release only cost, which left every nightly amd64 only and gave anyone on arm64 nothing to test with; both are now published for both. The published images also carry an SBOM and provenance in max mode. buildx attaches minimal provenance on its own, so what this adds is the component list and the record of which workflow, commit and inputs produced the image, which is the evidence a consumer of a FOSS image needs to answer whether an advisory applies to them. Two smaller things fixed along the way. The two image builds shared one GitHub Actions cache scope and evicted each other's layers on every run. And .dockerignore excluded .gradle only at the root, so a checkout that had been built locally shipped reposilite-frontend/.gradle into the context; the node toolchain in there is a tree of symlinks into host paths, and the build died on "Couldn't follow symbolic link", which reads like a broken Dockerfile and is really the host leaking in. The repository history, 124 MB of it, is out of the context too.
Building an image proves the Dockerfile parses. Every regression this pull request fixes built cleanly, started cleanly and served artifacts, and was only visible in behaviour: privileges that could no longer be dropped, an environment variable read and ignored, a log directory that stayed empty. Three checks now run against the built images, as scripts rather than YAML so the same commands work against a local build. check-server-image.sh asserts the drop-in contract on an empty directory: the jar under its upstream name, uid 1000 free for PUID, a root start that adopts a foreign-owned volume and honours PUID, PGID and REPOSILITE_OPTS, the dashboard served by the server itself, and an unprivileged start. check-upstream-migration.sh runs the real upstream image first, has it generate a token and publish an artifact, hands that directory to this image, and then hands everything back to upstream. It is the only check that can catch a regression which needs existing data to show up. check-dashboard-image.sh starts the dashboard under the full hardening the compose file applies, so a change that quietly needs a writable filesystem or a capability fails here instead of in a cluster. Both images are also scanned as images now, not just as dependency trees, and both are built for the other published architecture.
The rule was implicit, which is how three changes broke it in one branch without anyone noticing. CLAUDE.md now states it as a rule that outranks hardening and tidying: switching from Reposilite to Ingot costs one changed line, the dependency coordinate or the image reference, and nothing else. It lists what the contract covers, how additions are still allowed to be made, and the three questions to answer before touching the image, the entrypoint or the configuration. The installation guide gains the same statement for operators, plus what the images now ship: both architectures under one manifest, an SBOM and provenance. The split-container guide said the server image runs unprivileged by default. It no longer does, and the guide now explains why that line lives in the compose file instead.
Test results 68 files 68 suites 9m 57s ⏱️ Results for commit 1fe847d. ♻️ This comment has been updated with latest results. |
The file states the rule itself: everything publicly visible is English, and this one ships with the repository. It was the only document still written in German, which makes it unreadable for exactly the contributors the fork is trying to attract. Content is unchanged apart from one clarification: the language section now says outright that it applies to this file too, so the next person does not have to infer it.
The three checks had grown their own copies of the same scaffolding, and two of the copies were wrong in ways that only showed up under load. Container cleanup never ran. Each script collected its container names in a shell array, but every helper is called from a command substitution, and a subshell's variables do not survive it. The array was always empty at exit, so containers from every local run were left behind. Containers are now found by a per-run label, which no subshell can lose. The migration check could deadlock. Starting the console container inside a command substitution meant the substitution waited for the fifo writer that holds stdin open, which by design never exits. Roles now derive their container name deterministically, so nothing has to be captured at all. Host ports were hardcoded, which made two runs on one machine collide. Docker picks the port now and the check asks it where the container landed. That also exposed a real gap: the drop-in check published 8080 while REPOSILITE_OPTS told the server to listen on 8123, so the assertion the port was supposed to make could never have failed. The rest is deduplication: one wait_for_http with the container's logs on timeout, one wait_for_log, one fail, one temporary directory that is removed even when a root-owned server wrote into it.
The pipeline no longer carries 467 lines of shell. What the three scripts did is now a Gradle suite in reposilite-backend/src/containerTest, and the workflow builds the images and runs one task. Kotlin buys more than tidiness here. The scripts had two defects that came from the language rather than from the checks: container cleanup silently never ran, because the helper that registered names was called from a command substitution and a subshell's variables do not survive it, and the migration check could deadlock for the same reason. Neither is expressible in a typed test. Testcontainers also removes the parts that were most awkward to write by hand: it picks free ports, waits for a container to answer, and tears everything down whether the test passed or not. The suite deliberately depends on nothing from the main source set. It exercises the image as an operator receives it, over HTTP and through Docker, so reaching into the server's own classes would only let it assert against the wrong thing. It is also a suite of its own rather than part of `check`, because it needs an image that already exists. This build cannot produce one for it: the image build runs Gradle, so a test that built it would be this build invoking itself. CI builds both images first and then runs the task. The upgrade rehearsal lost its last piece of improvisation on the way. It used to drive the interactive console through a fifo to create the access token it needs; it now starts upstream with a temporary bootstrap token and creates the persistent one over the API, which is both less fragile and closer to what a real deployment does.
The drop-in test asserts that the server honoured PUID and PGID by looking at who owns the configuration it wrote. It read that from the host, which works only when the id under test happens to be the one running the tests. A temporary directory is mode 700. Once it belongs to uid 1000 and the process asking is not uid 1000, the host cannot traverse into it at all, and the assertion dies with AccessDeniedException before it can compare anything. That is exactly what happens on a runner, where the account is uid 1001, and never happens on a workstation whose own uid is 1000. Ownership is now read the same way the file contents already were, by asking a container. Verified by pointing the test at an id the local user does not have, which reproduces the runner and passes.
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.
Why
Ingot only has a reason to exist if switching to it costs one changed line. The split-container work broke that in three places, and none of them were visible in a diff or a build: the image built cleanly, started cleanly and served artifacts every time.
The regressions were found by actually rehearsing the upgrade, which is now part of CI.
What was broken
The server image could no longer adopt an existing deployment.
USER 977:977cut off the entrypoint's root path, which is the only code that acts onPUIDandPGIDor takes over a data directory owned by somebody else. Pointing the image at an existing volume producedSQLException: opening db: '/app/data/reposilite.db': Permission deniedand nothing else. Upstream starts as root and drops privileges itself; the image does that again, and running unprivileged is now a line in the compose file, where it can be removed for one start when ownership needs fixing.PUIDandPGIDwere read and ignored. Pre-creating the service account made the entrypoint's existence guards always true. An existing account is now adjusted to the requested ids.PUID=1000failed outright. The base image ships anubuntuaccount holding uid and gid 1000, the most common value anyone puts in that variable. Nothing here uses that account.The fat jar registered no tinylog writers. Shadow 9 changed the default duplicates strategy to
EXCLUDE, under whichmergeServiceFiles()keeps the firstMETA-INF/servicesfile and drops the rest.RollingFileWriterwas present as a class but never registered, so the server logged one line readingService implementation 'rolling file' not foundand wrote nothing to/var/log/reposiliteat all. This affects every jar from this build, not just the image, so standalone installations and the published Maven artifacts were losing their log files too. Shadow 8, which produced the last upstream release, defaulted toINCLUDE.The dashboard base image carried ten fixable CRITICAL and HIGH advisories in curl, libexpat, libssl3 and libxml2. The pinned digest was already the last one published for the 1.29-alpine line; the patched packages ship in 1.31-alpine.
Multi-platform
Both Dockerfiles compiled inside the target architecture, so publishing for
linux/arm64ran the whole Gradle build and the whole npm build under QEMU, for output that is identical on every architecture. The build stages are pinned toBUILDPLATFORM, leaving only the run stages emulated, where the work is creating an account and copying files.Verified on a machine with no aarch64 binfmt registered: with the pin,
--platform linux/arm64 --target buildcompletes for both images; without it,npm cidies for lack of emulation.That makes the second architecture cheap enough to stop rationing it, so nightlies are published for both architectures too. Every push now also carries an SBOM and provenance in max mode.
What now guards this
A Gradle suite in
reposilite-backend/src/containerTest, run by CI after both images arebuilt. It is a suite of its own rather than part of
check, because it needs an image thatalready exists: the image build runs Gradle, so a test that produced one would be this build
invoking itself.
ServerImageContractTestasserts the drop-in contract on an empty directory: the jar underits upstream name, uid 1000 free, a root start that adopts a foreign-owned volume and
honours
PUID,PGIDandREPOSILITE_OPTS, the dashboard served by the server itself,and an unprivileged start.
UpstreamMigrationTestrunsdzikoysk/reposilite:3.5.28, has it create a persistent tokenand publish an artifact, hands that directory to this image, and then hands everything back.
Rollback is part of the contract, and this is the test that found the tinylog regression.
DashboardImageTeststarts the dashboard read only, unprivileged and with all capabilitiesdropped.
Run it against a local build with
./gradlew :reposilite-backend:containerTest -Dingot.image=<tag>.Both images are also scanned as images now, not only as dependency trees, and both are built
for the other published architecture on every pull request.
Verified
The upgrade rehearsal passes end to end: an artifact published under upstream is still served, a token generated under upstream still authenticates and can publish, not one configured value in
configuration.cdnchanges, the log files are written, and upstream reads back everything this image wrote.Both images build and pass the suite, and Trivy reports no fixable CRITICAL or HIGH findings on either.
The suite was also run against
dzikoysk/reposilite:3.5.28as a control: four of its seven tests fail there, which is what the contract says should happen to an image that does not honour it.Notes
configuration.cdnhas its header comments rebranded on first start. No configured value changes, and upstream writes its own comments back on rollback. Both products rewrite that file on every start.main, so there is no schema downgrade.mainis on Shadow 9.4.2 as well and is very likely affected, which is worth reporting there.