使用 mina+unicorn 部署本地编译静态资源 部署命令行
deploy do
# Put things that will set up an empty directory into a fully set-up
# instance of your project.
# invoke :'sidekiq:quiet'
invoke :'git:clone'
invoke :'deploy:link_shared_paths'
invoke :'bundle:install'
invoke :'rails:db_migrate'
system "RAILS_ENV=production rails assets:precompile"
system "rsync -cvzrltogD --progress #{fetch(:local_path)}/public/assets/ #{fetch(:user)}@#{fetch(:domain)}:#{fetch(:current_path)}/public/assets/"
# system "RAILS_ENV=production rails assets:precompile"
# # command %[mkdir -p "#{fetch(:current_path)}/public/assets"]
# system "a"
# system "rsync -cvzrltogD --progress public/assets/* #{fetch(:user)}@#{fetch(:domain)}:#{fetch(:current_path)}/public/assets/"
# system "rm -rf public/assets"
# invoke :'rails:assets_precompile'
# rsync -cvzrltogD --progress public/stylesheets/* [email protected]:/home/chuck/a15321/current/public/stylesheets
# system "rsync -cvzrltogD --progress public/javascripts/* #{fetch(:user)}@#{fetch(:domain)}:#{fetch(:current_path)}/public/assets"
# system "rsync -cvzrltogD --progress public/stylesheets/* #{fetch(:user)}@#{fetch(:domain)}:#{fetch(:current_path)}/public/assets"
# system "rsync -cvzrltogD --progress public/fonts #{fetch(:user)}@#{fetch(:domain)}:#{fetch(:current_path)}/public/assets"
invoke :'deploy:cleanup'
on :launch do
command "mkdir -p #{fetch(:current_path)}/tmp/"
command "mkdir -p #{fetch(:current_path)}/tmp/logs"
command "mkdir -p #{fetch(:current_path)}/tmp/pids"
command "mkdir -p #{fetch(:current_path)}/tmp/sockets"
command "touch #{fetch(:current_path)}/tmp/restart.txt"
invoke :'unicorn:restart'
# invoke :'sidekiq:restart'
end
production.rb 文件配置
config.assets.js_compressor = Uglifier.new(harmony: true)
config.public_file_server.enabled = true
本地编译会产生 mainifese.json 这个隐藏文件。必须将其同步到生产环境的 public/aseets 目录下。 这样就可以解决使用 mina 部署时线下编译静态资源。