Skip to content

Fix permissions before migrations #114

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ For more information about the official images process, see the [docker-library/

---

- [Travis CI:
- [Travis CI:
![build status badge](https://img.shields.io/travis/docker-library/redmine/master.svg)](https://travis-ci.org/docker-library/redmine/branches)
- [Automated `update.sh`:
- [Automated `update.sh`:
![build status badge](https://doi-janky.infosiftr.net/job/update.sh/job/redmine/badge/icon)](https://doi-janky.infosiftr.net/job/update.sh/job/redmine)

| Build | Status | Badges | (per-arch) |
Expand Down
32 changes: 16 additions & 16 deletions docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,13 @@ case "$1" in
file_env 'REDMINE_DB_MYSQL'
file_env 'REDMINE_DB_POSTGRES'
file_env 'REDMINE_DB_SQLSERVER'

if [ "$MYSQL_PORT_3306_TCP" ] && [ -z "$REDMINE_DB_MYSQL" ]; then
export REDMINE_DB_MYSQL='mysql'
elif [ "$POSTGRES_PORT_5432_TCP" ] && [ -z "$REDMINE_DB_POSTGRES" ]; then
export REDMINE_DB_POSTGRES='postgres'
fi

if [ "$REDMINE_DB_MYSQL" ]; then
adapter='mysql2'
host="$REDMINE_DB_MYSQL"
Expand Down Expand Up @@ -66,19 +66,19 @@ case "$1" in
echo >&2
echo >&2 '*** Using sqlite3 as fallback. ***'
echo >&2

adapter='sqlite3'
host='localhost'
file_env 'REDMINE_DB_PORT' ''
file_env 'REDMINE_DB_USERNAME' 'redmine'
file_env 'REDMINE_DB_PASSWORD' ''
file_env 'REDMINE_DB_DATABASE' 'sqlite/redmine.db'
file_env 'REDMINE_DB_ENCODING' 'utf8'

mkdir -p "$(dirname "$REDMINE_DB_DATABASE")"
chown -R redmine:redmine "$(dirname "$REDMINE_DB_DATABASE")"
fi

REDMINE_DB_ADAPTER="$adapter"
REDMINE_DB_HOST="$host"
echo "$RAILS_ENV:" > config/database.yml
Expand Down Expand Up @@ -107,12 +107,17 @@ case "$1" in
"
)"
fi

# ensure the right database adapter is active in the Gemfile.lock
cp "Gemfile.lock.${adapter}" Gemfile.lock
# install additional gems for Gemfile.local and plugins
bundle check || bundle install --without development test


# https://www.redmine.org/projects/redmine/wiki/RedmineInstall#Step-8-File-system-permissions
chown -R redmine:redmine files log public/plugin_assets
# directories 755, files 644:
chmod -R ugo-x,u+rwX,go+rX,go-w files log tmp public/plugin_assets

if [ ! -s config/secrets.yml ]; then
file_env 'REDMINE_SECRET_KEY_BASE'
if [ "$REDMINE_SECRET_KEY_BASE" ]; then
Expand All @@ -127,24 +132,19 @@ case "$1" in
if [ "$1" != 'rake' -a -z "$REDMINE_NO_DB_MIGRATE" ]; then
gosu redmine rake db:migrate
fi

# https://www.redmine.org/projects/redmine/wiki/RedmineInstall#Step-8-File-system-permissions
chown -R redmine:redmine files log public/plugin_assets
# directories 755, files 644:
chmod -R ugo-x,u+rwX,go+rX,go-w files log tmp public/plugin_assets


if [ "$1" != 'rake' -a -n "$REDMINE_PLUGINS_MIGRATE" ]; then
gosu redmine rake redmine:plugins:migrate
fi

# remove PID file to enable restarting the container
rm -f /usr/src/redmine/tmp/pids/server.pid

if [ "$1" = 'passenger' ]; then
# Don't fear the reaper.
set -- tini -- "$@"
fi

set -- gosu redmine "$@"
;;
esac
Expand Down