-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdocker-entrypoint.sh
More file actions
executable file
·100 lines (86 loc) · 2.72 KB
/
docker-entrypoint.sh
File metadata and controls
executable file
·100 lines (86 loc) · 2.72 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
#!/bin/bash
set -e
case "$1" in
rails|rake|passenger)
if [ ! -f './config/database.yml' ]; then
if [ "$MYSQL_PORT_3306_TCP" ]; then
adapter='mysql2'
host='mysql'
port="${MYSQL_PORT_3306_TCP_PORT:-3306}"
username="${MYSQL_ENV_MYSQL_USER:-root}"
password="${MYSQL_ENV_MYSQL_PASSWORD:-$MYSQL_ENV_MYSQL_ROOT_PASSWORD}"
database="${MYSQL_ENV_MYSQL_DATABASE:-${MYSQL_ENV_MYSQL_USER:-redmine}}"
encoding=
elif [ "$POSTGRES_PORT_5432_TCP" ]; then
adapter='postgresql'
host='postgres'
port="${POSTGRES_PORT_5432_TCP_PORT:-5432}"
username="${POSTGRES_ENV_POSTGRES_USER:-postgres}"
password="${POSTGRES_ENV_POSTGRES_PASSWORD}"
database="${POSTGRES_ENV_POSTGRES_DB:-$username}"
encoding=utf8
else
echo >&2 'warning: missing MYSQL_PORT_3306_TCP or POSTGRES_PORT_5432_TCP environment variables'
echo >&2 ' Did you forget to --link some_mysql_container:mysql or some-postgres:postgres?'
echo >&2
echo >&2 '*** Using sqlite3 as fallback. ***'
adapter='sqlite3'
host='localhost'
username='redmine'
database='sqlite/redmine.db'
encoding=utf8
mkdir -p "$(dirname "$database")"
chown -R redmine:redmine "$(dirname "$database")"
fi
cat > './config/database.yml' <<-YML
$RAILS_ENV:
adapter: $adapter
database: $database
host: $host
username: $username
password: "$password"
encoding: $encoding
port: $port
YML
fi
if [ ! -f './config/configuration.yml' ]; then
address="${SMTP_PORT_587_TCP_ADDR}"
port="${SMTP_PORT_587_TCP_PORT:-587}"
mailname="${SMTP_PORT_587_TCP_DOMAIN:-$address}
cat > './config/configuration.yml' <<-YML
$RAILS_ENV:
email_delivery:
delivery_method: :smtp
smtp_settings:
enable_starttls_auto: false
address: $address
port: $port
domain: $mailname
YML
fi
# ensure the right database adapter is active in the Gemfile.lock
bundle install --without development test
if [ ! -s config/secrets.yml ]; then
if [ "$REDMINE_SECRET_KEY_BASE" ]; then
cat > 'config/secrets.yml' <<-YML
$RAILS_ENV:
secret_key_base: "$REDMINE_SECRET_KEY_BASE"
YML
elif [ ! -f /usr/src/redmine/config/initializers/secret_token.rb ]; then
rake generate_secret_token
fi
fi
if [ "$1" != 'rake' -a -z "$REDMINE_NO_DB_MIGRATE" ]; then
gosu redmine rake db:migrate --trace
fi
chown -R redmine:redmine files log public/plugin_assets
# 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
exec "$@"