diff --git a/Dockerfile b/Dockerfile index cdce1f4184a7..48d58184d3c3 100644 --- a/Dockerfile +++ b/Dockerfile @@ -60,7 +60,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:dspace --from=ant_build /dspace $DSPACE_INSTALL +COPY --from=ant_build /dspace $DSPACE_INSTALL # Need host command for "[dspace]/bin/make-handle-config" RUN apt-get update \ && apt-get install -y --no-install-recommends host \ @@ -71,7 +71,7 @@ EXPOSE 8080 8009 8000 # Give java extra memory (2GB) ENV JAVA_OPTS=-Xmx2000m COPY scripts/restart_debug/* /usr/local/tomcat/bin -COPY --chown=dspace:dspace scripts/index-scripts/* /dspace/bin +COPY scripts/index-scripts/* /dspace/bin # Link the DSpace 'server' webapp into Tomcat's webapps directory. # This ensures that when we start Tomcat, it runs from /server path (e.g. http://localhost:8080/server/) RUN ln -s $DSPACE_INSTALL/webapps/server /usr/local/tomcat/webapps/server @@ -82,13 +82,25 @@ RUN ln -s $DSPACE_INSTALL/webapps/server /usr/local/tomcat/webapps/server # ln -s $DSPACE_INSTALL/webapps/server /usr/local/tomcat/webapps/ROOT WORKDIR /usr/local/tomcat/bin -RUN chmod u+x redebug.sh undebug.sh custom_run.sh +RUN chmod a+rx redebug.sh undebug.sh custom_run.sh -RUN mkdir -p /dspace/assetstore \ - && chown dspace:dspace /dspace/assetstore \ - && chown -Rv dspace:dspace /usr/local/tomcat -# NOTE: /dspace/assetstore does not exist in the base image. -# We create it so Docker named volumes inherit the correct ownership. -# This only works for *named volumes* — bind mounts use host permissions. +# App files stay owned by root. dspace writes only to the data folders, Tomcat's webapps (namespace link), +# solr/search/conf (reindex.flag) and item-submission.xml. /dspace and config are sticky, so dspace can add +# and remove its own entries there (temp folders, config backups), 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 matomo_reports 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 \ + && mkdir -p /usr/local/tomcat/conf/Catalina/localhost \ + && chown dspace:dspace /usr/local/tomcat/webapps \ + && touch /dspace/config/local.cfg \ + && chown root:dspace /dspace/config \ + && chmod 1775 /dspace/config \ + && chown dspace:dspace /dspace/config/item-submission.xml USER dspace diff --git a/scripts/restart_debug/custom_run.sh b/scripts/restart_debug/custom_run.sh index 5fc45b1c0a15..695f436f0691 100644 --- a/scripts/restart_debug/custom_run.sh +++ b/scripts/restart_debug/custom_run.sh @@ -1,5 +1,5 @@ #!/bin/bash -FILE=do_debug.txt +FILE=/home/dspace/do_debug.txt if [ -f "$FILE" ]; then export JPDA_ADDRESS="*:8000" ./catalina.sh jpda run diff --git a/scripts/restart_debug/redebug.sh b/scripts/restart_debug/redebug.sh index 84ae4a08b08b..15d46bc30dd9 100644 --- a/scripts/restart_debug/redebug.sh +++ b/scripts/restart_debug/redebug.sh @@ -1,3 +1,3 @@ #!/bin/bash -touch do_debug.txt +touch /home/dspace/do_debug.txt ./shutdown.sh diff --git a/scripts/restart_debug/undebug.sh b/scripts/restart_debug/undebug.sh index aab52a225961..56fd06050c93 100644 --- a/scripts/restart_debug/undebug.sh +++ b/scripts/restart_debug/undebug.sh @@ -1,3 +1,3 @@ #!/bin/bash -rm do_debug.txt +rm /home/dspace/do_debug.txt ./shutdown.sh