Skip to content
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

Must run Mastodon docker setup twice #11368

Open
BNolet opened this issue Jul 20, 2019 · 3 comments

Comments

@BNolet
Copy link

commented Jul 20, 2019

Expected behaviour

setup should pull from supposedly saved .env.production from inside the container and use that info to populate db and compile assets. It does not, and db population

Actual behaviour

image

...

image

Setup fails after answering message in screenshot, ruby errors following:

Running `RAILS_ENV=production rails db:setup` ...


rails aborted!
ArgumentError: `secret_key_base` for production environment must be a type of String`
/opt/mastodon/vendor/bundle/ruby/2.6.0/gems/railties-5.2.3/lib/rails/application.rb:583:in `validate_secret_key_base'
/opt/mastodon/vendor/bundle/ruby/2.6.0/gems/railties-5.2.3/lib/rails/application.rb:432:in `secret_key_base'
/opt/mastodon/vendor/bundle/ruby/2.6.0/gems/devise-4.6.2/lib/devise/secret_key_finder.rb:24:in `key_exists?'
/opt/mastodon/vendor/bundle/ruby/2.6.0/gems/devise-4.6.2/lib/devise/secret_key_finder.rb:16:in `find'
/opt/mastodon/vendor/bundle/ruby/2.6.0/gems/devise-4.6.2/lib/devise/rails.rb:37:in `block in <class:Engine>'
/opt/mastodon/vendor/bundle/ruby/2.6.0/gems/railties-5.2.3/lib/rails/initializable.rb:32:in `instance_exec'
/opt/mastodon/vendor/bundle/ruby/2.6.0/gems/railties-5.2.3/lib/rails/initializable.rb:32:in `run'
/opt/mastodon/vendor/bundle/ruby/2.6.0/gems/railties-5.2.3/lib/rails/initializable.rb:61:in `block in run_initializers'
/opt/mastodon/vendor/bundle/ruby/2.6.0/gems/railties-5.2.3/lib/rails/initializable.rb:60:in `run_initializers'
/opt/mastodon/vendor/bundle/ruby/2.6.0/gems/railties-5.2.3/lib/rails/application.rb:361:in `initialize!'
/opt/mastodon/config/environment.rb:5:in `<top (required)>'
/opt/mastodon/vendor/bundle/ruby/2.6.0/gems/bootsnap-1.4.4/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require'
/opt/mastodon/vendor/bundle/ruby/2.6.0/gems/bootsnap-1.4.4/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `block in require_with_bootsnap_lfi'
/opt/mastodon/vendor/bundle/ruby/2.6.0/gems/bootsnap-1.4.4/lib/bootsnap/load_path_cache/loaded_features_index.rb:92:in `register'
/opt/mastodon/vendor/bundle/ruby/2.6.0/gems/bootsnap-1.4.4/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:21:in `require_with_bootsnap_lfi'
/opt/mastodon/vendor/bundle/ruby/2.6.0/gems/bootsnap-1.4.4/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:30:in `require'
/opt/mastodon/vendor/bundle/ruby/2.6.0/gems/activesupport-5.2.3/lib/active_support/dependencies.rb:291:in `block in require'
/opt/mastodon/vendor/bundle/ruby/2.6.0/gems/activesupport-5.2.3/lib/active_support/dependencies.rb:257:in `load_dependency'
/opt/mastodon/vendor/bundle/ruby/2.6.0/gems/activesupport-5.2.3/lib/active_support/dependencies.rb:291:in `require'
/opt/mastodon/vendor/bundle/ruby/2.6.0/gems/railties-5.2.3/lib/rails/application.rb:337:in `require_environment!'
/opt/mastodon/vendor/bundle/ruby/2.6.0/gems/railties-5.2.3/lib/rails/application.rb:520:in `block in run_tasks_blocks'
/opt/mastodon/vendor/bundle/ruby/2.6.0/gems/railties-5.2.3/lib/rails/commands/rake/rake_command.rb:23:in `block in perform'
/opt/mastodon/vendor/bundle/ruby/2.6.0/gems/railties-5.2.3/lib/rails/commands/rake/rake_command.rb:20:in `perform'
/opt/mastodon/vendor/bundle/ruby/2.6.0/gems/railties-5.2.3/lib/rails/command.rb:48:in `invoke'
/opt/mastodon/vendor/bundle/ruby/2.6.0/gems/railties-5.2.3/lib/rails/commands.rb:18:in `<top (required)>'
/opt/mastodon/vendor/bundle/ruby/2.6.0/gems/bootsnap-1.4.4/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require'
/opt/mastodon/vendor/bundle/ruby/2.6.0/gems/bootsnap-1.4.4/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `block in require_with_bootsnap_lfi'
/opt/mastodon/vendor/bundle/ruby/2.6.0/gems/bootsnap-1.4.4/lib/bootsnap/load_path_cache/loaded_features_index.rb:92:in `register'
/opt/mastodon/vendor/bundle/ruby/2.6.0/gems/bootsnap-1.4.4/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:21:in `require_with_bootsnap_lfi'
/opt/mastodon/vendor/bundle/ruby/2.6.0/gems/bootsnap-1.4.4/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:30:in `require'
/opt/mastodon/vendor/bundle/ruby/2.6.0/gems/activesupport-5.2.3/lib/active_support/dependencies.rb:291:in `block in require'
/opt/mastodon/vendor/bundle/ruby/2.6.0/gems/activesupport-5.2.3/lib/active_support/dependencies.rb:257:in `load_dependency'
/opt/mastodon/vendor/bundle/ruby/2.6.0/gems/activesupport-5.2.3/lib/active_support/dependencies.rb:291:in `require'
bin/rails:4:in `<main>'
Tasks: TOP => db:setup => db:schema:load_if_ruby => db:create => db:load_config => environment
(See full trace by running task with --trace)
That failed! Perhaps your configuration is not right

Steps to reproduce the problem

After setting up the environment I ran docker-compose run --rm web bundle exec rake mastodon:setup using the pre-built images from the Docker Hub. I entered the required information, but didn't set up email.

Specifications

Using container image 2.9.2 for Mastodon, Ubuntu linux as the host. Docker version 18.09.8, build 0dd43dd87f. docker-compose version 1.24.1, build 4667896b

@BNolet

This comment has been minimized.

Copy link
Author

commented Jul 21, 2019

From an inspection of the .env.production file located inside the container, it seems that the proper configuration is saved in the container, but it's not actually used.

I tried to search through the scripts and whatnot, but couldn't turn up anything. Maybe someone much more familiar with the project can pinpoint the issue.

A possible workaround is to not include the line env_file: .env.production line in the docker-compose.yml's web service entry. This results in not having to run the script twice. However, you still have to add it back in after you finish the setup to run the web container in prod.

I'm not entirely sure what to suggest but I see a few options:

  • mount the file from the host filesystem (least work required by the admin, would not have to copy-paste the config if perms are set right)
  • reload the file before setting up the db (not sure if this is possible)
  • actually use the file that's written into the container (should have happened in the first place)

Edit: It's fully possible this is an issue with the container image itself, I'm just realizing.

@BNolet BNolet changed the title Must run docker setup twice Must run Mastodon docker setup twice Jul 22, 2019

@mfa777

This comment has been minimized.

Copy link

commented Jul 29, 2019

I just run RAILS_ENV=production bundle rails mastodon:setup outside the docker to get one .env.production file, then to try to setup again inside docker.

Looks like mastodon didn't use docker image environment variable properly:

# Precompile assets
RUN cd ~ && \
	OTP_SECRET=precompile_placeholder SECRET_KEY_BASE=precompile_placeholder rails assets:precompile

The image has set SECRET_KEY_BASE already, but setup Processing didn't use this environment variable.

ArgumentError: `secret_key_base` for production environment must be a type of String`
/opt/mastodon/vendor/bundle/ruby/2.6.0/gems/railties-5.2.3/lib/rails/application.rb:583:in `validate_secret_key_base'
@BNolet

This comment has been minimized.

Copy link
Author

commented Jul 29, 2019

But you shouldn't have to run any of these things twice :/

I can see what you're saying here though with the envvar. However, this is for the compilation of assets? There's also a failure at the db population

@Gargron Gargron added the bug label Aug 5, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
You can’t perform that action at this time.