Skip to content

[dtq-dev-93] Run the backend images as dspace and report SEO problems as UP_WITH_ISSUES - #1775

Open
milanmajchrak wants to merge 10 commits into
dtq-dev-93from
93/be-docker-ops
Open

milanmajchrak wants to merge 10 commits into
dtq-dev-93from
93/be-docker-ops

Conversation

@milanmajchrak

@milanmajchrak milanmajchrak commented Nov 26, 2026 •

Copy link
Copy Markdown
Collaborator

References

  • Dockerfiles: same user as the dtq-dev images (useradd -u 1100, COPY --chown, USER dspace), from dtq-dev 3dc5f08 and cecb1e4. Upstream DSpace has the same idea in its open PR "[Docker] Switch DSpace to Ubuntu user and set /dspace directory ownership".
  • Handle server: HTTP port 8010 and JAVA_OPTS_HANDLE, same as make-handle-config and start-handle-server on dtq-dev (c999c5d).
  • SEO health check: copy of upstream DSpace 9.4 commit 1b65f6f ("enhance SEOHealthIndicator with detailed health check messages and unit tests"), plus one change on top (robots.txt from the site root).
  • Health report: cherry-picks of upstream DSpace dspace-9_x commits ea9878e and e0cdb3f (Solr date range in LogAnalyser).
  • LDAP health check: upstream DSpace turns it off only in application-test.properties (cfe0215), so real installs still get it.
  • Also creates /dspace/sitemaps in the image, like PR 1507. Both merge cleanly; with this PR, the mkdir of 1507 does nothing.
  • Pairs with the dspace-angular PR from 93/fe-docker-ops (compose settings, volume owners in the deploy). Merge this one first.

Description

The backend and CLI containers run as dspace (uid 1100), not root. /server/actuator/health is no longer DOWN for SEO problems (now UP_WITH_ISSUES, as in DSpace 9.4) or for Spring Boot's LDAP check, and dspace health-report runs its Log Analyser section again.

Instructions for Reviewers

List of changes in this PR:

  • Dockerfile, Dockerfile.cli: the ant stage creates the volume folders ant does not create (assetstore, and sitemaps for the backend). The final stage adds the dspace user, copies /dspace with --chown=dspace:dspace and ends with USER dspace. A new named volume on these folders is owned by dspace.
  • make-handle-config: the Handle server HTTP port is 8010. Port 8000 is the debug port of Dockerfile.test. EXPOSE follows.
  • start-handle-server: drops JAVA_TOOL_OPTIONS, like bin/dspace does, so the Handle JVM does not take the debug port the webapp needs. The heap comes from JAVA_OPTS_HANDLE (256 MB), not from the webapp JAVA_OPTS.
  • SEOHealthIndicator: builder.down() becomes builder.status(UP_WITH_ISSUES_STATUS), the texts become constants, and the config service is injected. Same code as upstream 9.4.
  • SEOHealthIndicator also reads robots.txt from the site root (scheme://host/robots.txt). Crawlers only look there. Upstream reads it under dspace.ui.url, which is wrong when the UI runs under a path like /repository.
  • An HTML page at /robots.txt (a catch-all route of the site) counts as missing. A missing dspace.ui.url gives robots.txt missing, not DOWN.
  • SEOHealthIndicatorTest: the 4 upstream cases, plus one each for a UI under a path, an HTML page as robots.txt, and a missing dspace.ui.url.
  • LogAnalyser.getNumItems: the Solr date range uses full timestamps, from the start of the first day to the end of the last. Before, dspace health-report stopped in "Log Analyser Check" with Invalid Date String:'2026-11-19'. Upstream code, unchanged.
  • actuator.cfg: new management.health.ldap.enabled = false. spring-ldap-core brings in Spring Boot's LDAP check. It does not read authentication-ldap.cfg and fails on localhost:389, so health was DOWN on every install. LDAP login does not use it. The same line goes out of application-test.properties, so the ITs use the shipped setting.
  • HealthIndicatorsIT.testLdapIndicatorIsOff: an admin sees no ldap component.

Boxes that already ran the root image have root-owned volumes. Give them to uid 1100 once: docker exec -u root dspace<INSTANCE> chown -R dspace:dspace /dspace/assetstore, and the same for any other volume or bind mount under /dspace. The 8603 deploy does this itself after the dspace-angular PR.

How to test:

  • docker build -t dspace-nonroot . and docker run --rm --entrypoint id dspace-nonroot prints uid=1100(dspace) gid=1100(dspace) groups=1100(dspace). The same for Dockerfile.cli.
  • docker run --rm -v t_assets:/dspace/assetstore -v t_maps:/dspace/sitemaps -v t_logs:/dspace/log -v t_handle:/dspace/handle-server --entrypoint sh dspace-nonroot -c 'touch /dspace/assetstore/x /dspace/sitemaps/x /dspace/log/x /dspace/handle-server/x && echo writable' prints writable.
  • Handle server: docker run --rm -e "JAVA_TOOL_OPTIONS=-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=*:8000" --entrypoint sh dspace-nonroot -c '/dspace/bin/make-handle-config; /dspace/bin/start-handle-server; sleep 15; grep -A2 "HTTP handle" /dspace/log/handle-server.log; java -version'. The log shows port: 8010, and the last JVM prints Listening for transport dt_socket at address: 8000. Before this PR it fails with bind failed: Address already in use.
  • mvn test -pl dspace-server-webapp -DskipUnitTests=false -Dtest=SEOHealthIndicatorTest: 7 tests pass. With builder.down() back, 3 fail. With robots.txt read under dspace.ui.url, the path case fails.
  • mvn verify -pl dspace-api,dspace-server-webapp,dspace -am -DskipIntegrationTests=false -Dit.test=HealthIndicatorsIT: 4 tests pass. Without the actuator.cfg line all 4 fail: health is DOWN and the admin sees ldap with CommunicationException: localhost:389.
  • dspace health-report prints Items added since [...] in the "Log Analyser Check" section, not Invalid Date String.
  • After deploy, /server/actuator/health should answer UP_WITH_ISSUES instead of DOWN, as long as the database and Solr are up.

Codex review (gpt-6.2-sol, high), 2 rounds on the Docker, Handle and SEO commits: 1 finding fixed (an HTML page at /robots.txt counted as a valid robots.txt). Left as they are:

  • Existing root-owned volumes need the one-time chown above.
  • Dockerfile.test still runs as root, as on dtq-dev.
  • make-handle-config writes port 8010 and start-handle-server reads JAVA_OPTS_HANDLE, as on dtq-dev. It also drops JAVA_TOOL_OPTIONS, as bin/dspace does.

The last round also found that a BOM before an HTML page at /robots.txt still counts as valid. Not changed.

Codex review: not run (usage limit) on the last 3 commits, the LogAnalyser cherry-picks and the LDAP check.

Checklist

  • My PR is created against the main branch of code (unless it is a backport or is fixing an issue specific to an older branch).
  • My PR is small in size (e.g. less than 1,000 lines of code, not including comments & integration tests). Exceptions may be made if previously agreed upon.
  • My PR passes Checkstyle validation based on the Code Style Guide.
  • My PR includes Javadoc for all new (or modified) public methods and classes. It also includes Javadoc for large or complex private methods.
  • My PR passes all tests and includes new/updated Unit or Integration Tests based on the Code Testing Guide.
  • My PR includes details on how to test it. I've provided clear instructions to reviewers on how to successfully test this fix or feature.
  • If my PR includes new libraries/dependencies (in any pom.xml), I've made sure their licenses align with the DSpace BSD License based on the Licensing of Contributions documentation.
  • If my PR modifies REST API endpoints, I've opened a separate REST Contract PR related to this change.
  • If my PR includes new configurations, I've provided basic technical documentation in the PR itself.
  • If my PR fixes an issue ticket, I've linked them together.

🤖 Generated with Claude Code

milanmajchrak and others added 10 commits November 26, 2026 14:16
The image runs DSpace as dspace (uid 1100, as in the 7.x image) instead of root.
The assetstore and sitemaps folders exist in the image, so new named volumes get the same owner.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Copy of the upstream DSpace 9.4 change: a missing sitemap, robots.txt or SSR no longer makes
the whole health endpoint DOWN. Adds the upstream SEOHealthIndicatorTest.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The CLI shares the assetstore volume with the backend, so it uses the same uid 1100.
Otherwise folders it creates there are root-owned and the backend cannot write into them.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The test image uses 8000 for the Java debugger, which every JVM in the container opens.
Same port as in the 7.x image.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Crawlers read robots.txt only at the root of the site, so the SEO check
no longer reports it missing when the UI runs under a path.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The Handle server JVM takes JAVA_OPTS_HANDLE (256 MB by default) instead of the webapp JAVA_OPTS,
and drops JAVA_TOOL_OPTIONS so the debug port of the test image stays free for DSpace.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The robots.txt URL is built inside the try, so a missing or invalid dspace.ui.url reports
robots.txt as missing instead of DOWN. An HTML page at /robots.txt also counts as missing.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…time

(cherry picked from commit d931ba1)
(cherry picked from commit ea9878e)
…the day

(cherry picked from commit c3a3750)
(cherry picked from commit e0cdb3f)
spring-ldap-core brings in Spring Boot's LDAP indicator. It does not use authentication-ldap.cfg, so it fails on localhost:389 and turns /actuator/health DOWN. Tests now use the shipped setting.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

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