Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

Fix files being left over in cache

Oliver Günther67e78265516e
diff --git a/docker/prod/Dockerfile b/docker/prod/Dockerfile
index 5f97285464c..4da988f6d53 100644
--- a/docker/prod/Dockerfile
+++ b/docker/prod/Dockerfile
@@ -74,11 +74,6 @@ RUN cp Gemfile.lock.bak Gemfile.lock && rm Gemfile.lock.bak
RUN ./docker/prod/setup/precompile-assets.sh
RUN ./docker/prod/setup/postinstall-common.sh
-# We need this so puma is allowed to create the tmp/pids folder and
-# temporary upload files when running with a uid other than 1000 (app)
-# but with an allowed supplemental group (1000).
-RUN tmp_path=$APP_PATH/tmp; (mkdir -p $tmp_path || true) && chown $APP_USER:$APP_USER $tmp_path && chmod g+rw $tmp_path
-
RUN cp ./config/database.production.yml config/database.yml
RUN ln -s $APP_PATH/docker/prod/setup/.irbrc /home/$APP_USER/
diff --git a/docker/prod/setup/postinstall-common.sh b/docker/prod/setup/postinstall-common.sh
index 3da98edb802..b5c81dca833 100755
--- a/docker/prod/setup/postinstall-common.sh
+++ b/docker/prod/setup/postinstall-common.sh
@@ -5,4 +5,15 @@ set -eox pipefail
mkdir -p /tmp/op_uploaded_files/ && chown -R $APP_USER:$APP_USER /tmp/op_uploaded_files/
# Remove any existing config/database.yml
-rm -f ./config/database.yml
\ No newline at end of file
+rm -f ./config/database.yml
+
+# We need this so puma is allowed to create the tmp/pids folder and
+# temporary upload files when running with a uid other than 1000 (app)
+# but with an allowed supplemental group (1000).
+tmp_path="$APP_PATH/tmp"
+# Remove any previously cached files from e.g., asset building
+rm -rf "$tmp_path"
+# Recreate and own it for the user for later files (PID etc. see above)
+mkdir -p "$tmp_path"
+chown -R $APP_USER:$APP_USER "$tmp_path"
+chmod g+rw "$tmp_path"