From 6ce94ac3eea03c8fff3d254449f13f2da54f3c5b Mon Sep 17 00:00:00 2001 From: milanmajchrak Date: Wed, 18 Nov 2026 18:50:31 +0100 Subject: [PATCH 1/4] Keep the backend application files owned by root in the Docker image Co-Authored-By: Claude Opus 5.5 --- Dockerfile | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index b4aa4518c844..cbaf12e1366e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -59,7 +59,7 @@ ENV dspace__P__dir=/dspace # because Kubernetes deployment accepts only numeric user IDs when specifying the container user. RUN useradd -u 1100 -m -s /bin/bash dspace # Copy the /dspace directory from 'ant_build' container to /dspace in this container -COPY --chown=dspace:root --from=ant_build /dspace $dspace__P__dir +COPY --from=ant_build /dspace $dspace__P__dir WORKDIR $dspace__P__dir # Need host command for "[dspace]/bin/make-handle-config" RUN apt-get update \ @@ -71,6 +71,15 @@ EXPOSE 8080 8000 # Give java extra memory (2GB) ENV JAVA_OPTS=-Xmx2000m +# App files stay owned by root. dspace writes only to the data folders and solr/search/conf (reindex.flag). +# Missing folders are created so named volumes (not bind mounts) inherit the owner. +RUN for dir in assetstore ctqueues exports handle-server imports log reports sitemaps solr-export temp \ + triplestore upload var; do \ + mkdir -p /dspace/$dir && chown -R dspace:dspace /dspace/$dir; \ + done \ + && chown dspace:dspace /dspace/solr/search/conf \ + && chmod -R a+rX /dspace/bin + USER dspace # On startup, run DSpace Runnable JAR (uses the "dspace.dir" setting defined in "dspace__P__dir" env variable) From de33e5d1049309cb6814fc7f47e4cfd1614fbf8c Mon Sep 17 00:00:00 2001 From: milanmajchrak Date: Wed, 18 Nov 2026 20:42:03 +0100 Subject: [PATCH 2/4] Stop pre-creating solr-export solr-reindex-statistics removes its export folder only when it created it, so the image no longer creates /dspace/solr-export. The solr-*-statistics commands take -d instead. Co-Authored-By: Claude Opus 5.5 --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index cbaf12e1366e..a258ddbe414b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -73,7 +73,7 @@ ENV JAVA_OPTS=-Xmx2000m # App files stay owned by root. dspace writes only to the data folders and solr/search/conf (reindex.flag). # Missing folders are created so named volumes (not bind mounts) inherit the owner. -RUN for dir in assetstore ctqueues exports handle-server imports log reports sitemaps solr-export temp \ +RUN for dir in assetstore ctqueues exports handle-server imports log reports sitemaps temp \ triplestore upload var; do \ mkdir -p /dspace/$dir && chown -R dspace:dspace /dspace/$dir; \ done \ From b05dd5790bf1c1214de9f0f89f21524d153107cd Mon Sep 17 00:00:00 2001 From: milanmajchrak Date: Wed, 18 Nov 2026 21:12:10 +0100 Subject: [PATCH 3/4] Make /dspace sticky so DSpace can remove its own folders stats-util -s and -b delete /dspace/temp when they finish, and solr-reindex-statistics creates and deletes /dspace/solr-export. Both need write access to /dspace. With the sticky bit dspace can add and remove its own entries there, but not the root-owned ones. Co-Authored-By: Claude Opus 5.5 --- Dockerfile | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Dockerfile b/Dockerfile index a258ddbe414b..f4c9d9739cda 100644 --- a/Dockerfile +++ b/Dockerfile @@ -72,12 +72,15 @@ EXPOSE 8080 8000 ENV JAVA_OPTS=-Xmx2000m # App files stay owned by root. dspace writes only to the data folders and solr/search/conf (reindex.flag). +# /dspace is sticky, so dspace can add and remove its own entries there, but not replace the others. # Missing folders are created so named volumes (not bind mounts) inherit the owner. RUN for dir in assetstore ctqueues exports handle-server imports log reports sitemaps temp \ triplestore upload var; do \ mkdir -p /dspace/$dir && chown -R dspace:dspace /dspace/$dir; \ done \ && chown dspace:dspace /dspace/solr/search/conf \ + && chown root:dspace /dspace \ + && chmod 1775 /dspace \ && chmod -R a+rX /dspace/bin USER dspace From 50f32dd82d1db3b3f11c6036182703b2de2135ec Mon Sep 17 00:00:00 2001 From: milanmajchrak Date: Wed, 18 Nov 2026 21:23:37 +0100 Subject: [PATCH 4/4] Make solr/search/conf sticky instead of owned by dspace DSpace only needs to create and delete reindex.flag there. With the sticky bit it can, while schema.xml and solrconfig.xml stay root-owned. Co-Authored-By: Claude Opus 5.5 --- Dockerfile | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/Dockerfile b/Dockerfile index f4c9d9739cda..a72bbb1ad036 100644 --- a/Dockerfile +++ b/Dockerfile @@ -71,16 +71,15 @@ EXPOSE 8080 8000 # Give java extra memory (2GB) ENV JAVA_OPTS=-Xmx2000m -# App files stay owned by root. dspace writes only to the data folders and solr/search/conf (reindex.flag). -# /dspace is sticky, so dspace can add and remove its own entries there, but not replace the others. +# App files stay owned by root. dspace writes only to the data folders. /dspace and solr/search/conf are +# sticky, so dspace can add and remove its own entries there (temp, reindex.flag), but not replace the others. # Missing folders are created so named volumes (not bind mounts) inherit the owner. RUN for dir in assetstore ctqueues exports handle-server imports log reports sitemaps temp \ triplestore upload var; do \ mkdir -p /dspace/$dir && chown -R dspace:dspace /dspace/$dir; \ done \ - && chown dspace:dspace /dspace/solr/search/conf \ - && chown root:dspace /dspace \ - && chmod 1775 /dspace \ + && chown root:dspace /dspace /dspace/solr/search/conf \ + && chmod 1775 /dspace /dspace/solr/search/conf \ && chmod -R a+rX /dspace/bin USER dspace