Update mastodon cookbook for 1.4.1

There is a strange issue with assets precompilation. I have found a
workaround but it looks like a bug in application_ruby (in production I
fixed it manually)
This commit is contained in:
Greg 2017-06-02 18:30:57 +02:00
parent b7e395f122
commit 9065db8476
1 changed files with 28 additions and 16 deletions

View File

@ -41,13 +41,22 @@ user "mastodon" do
home mastodon_path
end
package %w(imagemagick ffmpeg libxml2-dev libxslt1-dev file git curl)
node_package %w(yarn)
package %w(imagemagick ffmpeg libxml2-dev libxslt1-dev file git curl pkg-config libprotobuf-dev protobuf-compiler)
node_package %w(yarn) # Used by Rails' assets pipeline
ruby_version = "2.4.1"
application mastodon_path do
owner "mastodon"
group "mastodon"
environment "HOME" => mastodon_path
ruby_runtime ruby_version do
provider :ruby_build
version ruby_version
end
git do
user "mastodon"
group "mastodon"
@ -83,24 +92,27 @@ application mastodon_path do
recursive true
end
ruby_runtime do
provider :ruby_build
version '2.4.1'
end
bundle_install do
user "mastodon"
deployment true
without %w(development test)
end
npm_install do
user "mastodon"
end
rails do
migrate true
rails_env "production"
precompile_assets false # buggy, done manually below
end
# This is the only way I could find that makes compiling the assets
# successfully for now. application_ruby's precompile_assets crashes because
# it cannot find the bundled gems
execute 'rake assets:precompile' do
environment "RAILS_ENV" => "production", "HOME" => mastodon_path
user "mastodon"
group "mastodon"
cwd mastodon_path
command "PATH=\"/opt/ruby_build/builds/#{ruby_version}/bin:$PATH\" /opt/ruby_build/builds/#{ruby_version}/bin/bundle exec rake assets:precompile"
end
execute "systemctl daemon-reload" do
@ -115,9 +127,9 @@ application mastodon_path do
variables user: user,
app_dir: mastodon_path,
port: node["kosmos-mastodon"]["puma_port"],
bundle_path: '/opt/ruby_build/builds/opt/mastodon/bin/bundle'
bundle_path: "/opt/ruby_build/builds/#{ruby_version}/bin/bundle"
notifies :run, "execute[systemctl daemon-reload]", :delayed
# notifies :restart, "service[mastodon-web]", :delayed
notifies :restart, "service[mastodon-web]", :delayed
end
service "mastodon-web" do
@ -130,9 +142,9 @@ application mastodon_path do
source "mastodon-sidekiq.systemd.service.erb"
variables user: user,
app_dir: mastodon_path,
bundle_path: '/opt/ruby_build/builds/opt/mastodon/bin/bundle'
bundle_path: "/opt/ruby_build/builds/#{ruby_version}/bin/bundle"
notifies :run, "execute[systemctl daemon-reload]", :delayed
# notifies :restart, "service[mastodon-sidekiq]", :delayed
notifies :restart, "service[mastodon-sidekiq]", :delayed
end
service "mastodon-sidekiq" do
@ -147,7 +159,7 @@ application mastodon_path do
app_dir: mastodon_path,
port: node["kosmos-mastodon"]["streaming_port"]
notifies :run, "execute[systemctl daemon-reload]", :delayed
# notifies :restart, "service[mastodon-streaming]", :delayed
notifies :restart, "service[mastodon-streaming]", :delayed
end
service "mastodon-streaming" do