docker-library / redmine

Docker Official Image packaging for Redmine
GNU General Public License v2.0
212 stars 173 forks source link

Container (Redmine 6.0.1) not starting when using the REDMINE_SECRET_KEY_BASE environment variable #349

Open Waigie opened 4 days ago

Waigie commented 4 days ago

The Redmine container is not starting when setting the REDMINE_SECRET_KEY_BASE environment variable as shown in the docker compose example.

Error message and stacktrace:

ArgumentError: Missing `secret_key_base` for 'production' environment, set this string with `bin/rails credentials:edit` (ArgumentError)

          raise ArgumentError, "Missing `secret_key_base` for '#{Rails.env}' environment, set this string with `bin/rails credentials:edit`"
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
/usr/local/bundle/gems/railties-7.2.2/lib/rails/application/configuration.rb:519:in `secret_key_base='
/usr/local/bundle/gems/railties-7.2.2/lib/rails/application/configuration.rb:503:in `secret_key_base'
/usr/local/bundle/gems/railties-7.2.2/lib/rails/application.rb:470:in `secret_key_base'
/usr/local/bundle/gems/railties-7.2.2/lib/rails/application.rb:205:in `block in message_verifiers'
/usr/local/bundle/gems/activesupport-7.2.2/lib/active_support/message_verifiers.rb:132:in `build'
/usr/local/bundle/gems/activesupport-7.2.2/lib/active_support/messages/rotation_coordinator.rb:85:in `block in build_with_rotations'
/usr/local/bundle/gems/activesupport-7.2.2/lib/active_support/messages/rotation_coordinator.rb:85:in `map'
/usr/local/bundle/gems/activesupport-7.2.2/lib/active_support/messages/rotation_coordinator.rb:85:in `build_with_rotations'
/usr/local/bundle/gems/activesupport-7.2.2/lib/active_support/messages/rotation_coordinator.rb:19:in `[]'
/usr/local/bundle/gems/railties-7.2.2/lib/rails/application.rb:232:in `message_verifier'
/usr/local/bundle/gems/activerecord-7.2.2/lib/active_record/railtie.rb:355:in `block (3 levels) in <class:Railtie>'
/usr/local/bundle/gems/activesupport-7.2.2/lib/active_support/lazy_load_hooks.rb:97:in `class_eval'
/usr/local/bundle/gems/activesupport-7.2.2/lib/active_support/lazy_load_hooks.rb:97:in `block in execute_hook'
/usr/local/bundle/gems/activesupport-7.2.2/lib/active_support/lazy_load_hooks.rb:87:in `with_execution_control'
/usr/local/bundle/gems/activesupport-7.2.2/lib/active_support/lazy_load_hooks.rb:92:in `execute_hook'
/usr/local/bundle/gems/activesupport-7.2.2/lib/active_support/lazy_load_hooks.rb:62:in `block in on_load'
/usr/local/bundle/gems/activesupport-7.2.2/lib/active_support/lazy_load_hooks.rb:61:in `each'
/usr/local/bundle/gems/activesupport-7.2.2/lib/active_support/lazy_load_hooks.rb:61:in `on_load'
/usr/local/bundle/gems/activerecord-7.2.2/lib/active_record/railtie.rb:354:in `block (2 levels) in <class:Railtie>'
/usr/local/bundle/gems/activesupport-7.2.2/lib/active_support/lazy_load_hooks.rb:94:in `block in execute_hook'
/usr/local/bundle/gems/activesupport-7.2.2/lib/active_support/lazy_load_hooks.rb:87:in `with_execution_control'
/usr/local/bundle/gems/activesupport-7.2.2/lib/active_support/lazy_load_hooks.rb:92:in `execute_hook'
/usr/local/bundle/gems/activesupport-7.2.2/lib/active_support/lazy_load_hooks.rb:78:in `block in run_load_hooks'
/usr/local/bundle/gems/activesupport-7.2.2/lib/active_support/lazy_load_hooks.rb:77:in `each'
/usr/local/bundle/gems/activesupport-7.2.2/lib/active_support/lazy_load_hooks.rb:77:in `run_load_hooks'
/usr/local/bundle/gems/railties-7.2.2/lib/rails/application/finisher.rb:94:in `block in <module:Finisher>'
/usr/local/bundle/gems/railties-7.2.2/lib/rails/initializable.rb:32:in `instance_exec'
/usr/local/bundle/gems/railties-7.2.2/lib/rails/initializable.rb:32:in `run'
/usr/local/bundle/gems/railties-7.2.2/lib/rails/initializable.rb:61:in `block in run_initializers'
/usr/local/bundle/gems/railties-7.2.2/lib/rails/initializable.rb:60:in `run_initializers'
/usr/local/bundle/gems/railties-7.2.2/lib/rails/application.rb:435:in `initialize!'
/usr/src/redmine/config/environment.rb:16:in `<top (required)>'
/usr/local/bundle/gems/zeitwerk-2.7.1/lib/zeitwerk/core_ext/kernel.rb:34:in `require'
/usr/local/bundle/gems/railties-7.2.2/lib/rails/application.rb:411:in `require_environment!'
/usr/local/bundle/gems/railties-7.2.2/lib/rails/application.rb:559:in `block in run_tasks_blocks'
/usr/local/bundle/gems/rake-13.2.1/exe/rake:27:in `<top (required)>'
Tasks: TOP => db:migrate => db:load_config => environment
(See full trace by running task with --trace)
ctassell commented 3 days ago

Yeah, this is a problem with the config/initializers/secret_tokens.rb file not existing. If you backup and delete the config/secrets.yml and set the REDMINE_SECRETS_KEY_BASE environmental variable to contain your secret key it should automatically generate that .rb file. I actually just cloned the image, generated it manually with rake generate_secret_token, and then copied the rb file in, so I'm not 100% certain the file removal will work. It should from how I read the code though:

       if [ ! -s config/secrets.yml ]; then
                file_env 'REDMINE_SECRET_KEY_BASE'
                if [ -n "$REDMINE_SECRET_KEY_BASE" ]; then
                        cat > 'config/secrets.yml' <<-YML
                                $RAILS_ENV:
                                  secret_key_base: "$REDMINE_SECRET_KEY_BASE"
                        YML
                elif [ ! -f config/initializers/secret_token.rb ]; then
                        rake generate_secret_token
                fi
        fi

The new release seems a little buggy. My system got completely hosed when I upgraded. Still can't get a custom theme to be recognized.

achernyakevich-sc commented 3 days ago

The new release seems a little buggy. My system got completely hosed when I upgraded. Still can't get a custom theme to be recognized.

@ctassell Redmine 6.0.x has incompatible changes about Themes. Maybe this is the root of your problems. See:

I hope it helps. :)

ctassell commented 3 days ago

Thanks, I reverted back to 5.1 for now, I'll make sure to bookmark that so our web dev can upgrade the theme when we are prepared to migrate. One of our plugins also had issues, it must need to be patched as well.

Waigie commented 3 days ago

@ctassell Thanks for the help, i'll tests it as soon as possible