Skip to content

Commit a57cd24

Browse files
committed
Drop secrets.yml and just use SECRET_KEY_BASE
1 parent 2ac7919 commit a57cd24

File tree

10 files changed

+170
-100
lines changed

10 files changed

+170
-100
lines changed

5.0/alpine3.20/docker-entrypoint.sh

+17-10
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

5.0/alpine3.21/docker-entrypoint.sh

+17-10
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

5.0/bookworm/docker-entrypoint.sh

+17-10
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

5.1/alpine3.20/docker-entrypoint.sh

+17-10
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

5.1/alpine3.21/docker-entrypoint.sh

+17-10
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

5.1/bookworm/docker-entrypoint.sh

+17-10
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

6.0/alpine3.20/docker-entrypoint.sh

+17-10
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

6.0/alpine3.21/docker-entrypoint.sh

+17-10
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

6.0/bookworm/docker-entrypoint.sh

+17-10
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docker-entrypoint.sh

+17-10
Original file line numberDiff line numberDiff line change
@@ -139,17 +139,24 @@ if [ -n "$isLikelyRedmine" ]; then
139139
# install additional gems for Gemfile.local and plugins
140140
bundle check || bundle install
141141

142-
if [ ! -s config/secrets.yml ]; then
143-
file_env 'REDMINE_SECRET_KEY_BASE'
144-
if [ -n "$REDMINE_SECRET_KEY_BASE" ]; then
145-
cat > 'config/secrets.yml' <<-YML
146-
$RAILS_ENV:
147-
secret_key_base: "$REDMINE_SECRET_KEY_BASE"
148-
YML
149-
elif [ ! -f config/initializers/secret_token.rb ]; then
150-
rake generate_secret_token
151-
fi
142+
file_env 'REDMINE_SECRET_KEY_BASE'
143+
# just use the rails variable rather than trying to put it into a yml file
144+
# https://github.com/rails/rails/blob/6-1-stable/railties/lib/rails/application.rb#L438
145+
# https://github.com/rails/rails/blob/1aa9987169213ce5ce43c20b2643bc64c235e792/railties/lib/rails/application.rb#L484 (rails 7.1-stable)
146+
if [ -n "${SECRET_KEY_BASE}" ] && [ -n "${REDMINE_SECRET_KEY_BASE}" ]; then
147+
echo >&2
148+
echo >&2 'warning: both SECRET_KEY_BASE and REDMINE_SECRET_KEY_BASE{_FILE} set, only SECRET_KEY_BASE will apply'
149+
echo >&2
150+
fi
151+
: "${SECRET_KEY_BASE:=$REDMINE_SECRET_KEY_BASE}"
152+
export SECRET_KEY_BASE
153+
# generate SECRET_KEY_BASE if not set; this is not recommended unless the secret_token.rb is saved when container is recreated
154+
if [ -z "$SECRET_KEY_BASE" ] && [ ! -f config/initializers/secret_token.rb ]; then
155+
echo >&2 'warning: no *SECRET_KEY_BASE set; running `rake generate_secret_token` to create one in "config/initializers/secret_token.rb"'
156+
unset SECRET_KEY_BASE # just in case
157+
rake generate_secret_token
152158
fi
159+
153160
if [ "$1" != 'rake' -a -z "$REDMINE_NO_DB_MIGRATE" ]; then
154161
rake db:migrate
155162
fi

0 commit comments

Comments
 (0)