From 7342a6b3fb3b3e882432337ee57c3c52b648e44b Mon Sep 17 00:00:00 2001 From: milanmajchrak Date: Wed, 18 Nov 2026 18:50:26 +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 | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index fc888a214165..8758dcbf2a47 100644 --- a/Dockerfile +++ b/Dockerfile @@ -63,7 +63,7 @@ ENV DSPACE_INSTALL=/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_INSTALL +COPY --from=ant_build /dspace $DSPACE_INSTALL WORKDIR $DSPACE_INSTALL # Need host command for "[dspace]/bin/make-handle-config" RUN apt-get update \ @@ -74,8 +74,17 @@ RUN apt-get update \ EXPOSE 8080 8000 # Give java extra memory (2GB) ENV JAVA_OPTS=-Xmx2000m -# On startup, run DSpace Runnable JAR + +# 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 ENTRYPOINT ["java", "-jar", "webapps/server-boot.jar", "--dspace.dir=$DSPACE_INSTALL"] From e4bcff8fd7c6070f86d00d6830dbcf490495759a Mon Sep 17 00:00:00 2001 From: milanmajchrak Date: Wed, 18 Nov 2026 20:41:59 +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 8758dcbf2a47..93fa2cf6d1bc 100644 --- a/Dockerfile +++ b/Dockerfile @@ -77,7 +77,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 18f67437be599c570dcfc4896066a9edb8147065 Mon Sep 17 00:00:00 2001 From: milanmajchrak Date: Wed, 18 Nov 2026 21:12:06 +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 93fa2cf6d1bc..87aeec85c92d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -76,12 +76,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 a035e66460df256fb35d64ca62482b2fdaaf6012 Mon Sep 17 00:00:00 2001 From: milanmajchrak Date: Wed, 18 Nov 2026 21:23:33 +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 87aeec85c92d..8f442892f3e6 100644 --- a/Dockerfile +++ b/Dockerfile @@ -75,16 +75,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