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

make image run unprivileged

Markus Kahl7831fed79ab7
diff --git a/docker/prod/Dockerfile b/docker/prod/Dockerfile
index a9355275590..b2f057ca67c 100644
--- a/docker/prod/Dockerfile
+++ b/docker/prod/Dockerfile
@@ -187,6 +187,10 @@ RUN cp Gemfile.lock.bak Gemfile.lock && rm Gemfile.lock.bak
RUN ./docker/prod/setup/postinstall.sh
+# We need this so puma is allowed to create the tmp/pids folder and files
+# even when the container is run as a user other than 1000 (app)
+RUN tmp_path=$APP_PATH/tmp; (mkdir -p $tmp_path || true) && chmod og+rw $tmp_path
+
# Expose ports for apache and postgres
EXPOSE 80 5432
diff --git a/docker/prod/wait-for-db b/docker/prod/wait-for-db
new file mode 100755
index 00000000000..64c2f1a35c5
--- /dev/null
+++ b/docker/prod/wait-for-db
@@ -0,0 +1,5 @@
+#!/bin/bash -e
+
+SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
+
+bundle exec rails runner $SCRIPT_DIR/wait_for_db.rb
diff --git a/docker/prod/wait_for_db.rb b/docker/prod/wait_for_db.rb
new file mode 100644
index 00000000000..5fd23e6a866
--- /dev/null
+++ b/docker/prod/wait_for_db.rb
@@ -0,0 +1,19 @@
+require 'timeout'
+
+timeout = (ENV['WAIT_FOR_DB_TIMEOUT_SECONDS'] || 120).to_i
+
+Timeout::timeout(timeout) do
+ loop do
+ puts "[#{DateTime.now}] waiting for db"
+ sleep 4
+
+ begin
+ ActiveRecord::Migration.check_pending!
+
+ puts "[#{DateTime.now}] db ready"
+ exit 0
+ rescue StandardError => e
+ puts "[#{DateTime.now}] not ready yet: #{e.message}"
+ end
+ end
+end