如何使用 Mina 部署将我的 Rails 5.2 master.key 移动到服务器?



我想使用mina deploy将我的master.key文件移动到服务器(在数字海洋上(。

在我目前拥有的deploy.rb

set :shared_files, fetch(:shared_files, []).push('config/database.yml', 'config/secrets.yml', 'config/master.key')
# Put any custom commands you need to run at setup
# All paths in `shared_dirs` and `shared_paths` will be created on their own.
task :setup do
in_path(fetch(:shared_path)) do
command %[mkdir -p config]
# Create database.yml for Postgres if it doesn't exist
path_database_yml = "config/database.yml"
database_yml = %[production:
database: #{fetch(:user)}
adapter: postgresql
pool: 5
timeout: 5000]
command %[test -e #{path_database_yml} || echo "#{database_yml}" > #{path_database_yml}]
# Create secrets.yml if it doesn't exist
path_secrets_yml = "config/secrets.yml"
secrets_yml = %[production:n  secret_key_base:n    #{`bundle exec rake secret`.strip}]
command %[test -e #{path_secrets_yml} || echo "#{secrets_yml}" > #{path_secrets_yml}]
# Remove others-permission for config directory
command %[chmod -R o-rwx config]
end
end
...
desc "Deploys the current version to the server."
task :deploy do
# uncomment this line to make sure you pushed your local branch to the remote origin
# invoke :'git:ensure_pushed'
deploy do
# Put things that will set up an empty directory into a fully set-up
# instance of your project.
invoke :'git:clone'
invoke :'deploy:link_shared_paths'
invoke :'bundle:install'
invoke :'rails:db_migrate'
invoke :'rails:assets_precompile'
invoke :'deploy:cleanup'
on :launch do
invoke :'whenever:update' # should update the cron file
command "sudo service #{fetch(:user)} restart"
end
end
# you can use `run :local` to run tasks on local machine before of after the deploy scripts
# run(:local){ say 'done' }
end

请您告诉我我需要在上面添加什么才能将文件config/master.key从我的开发机器移动到服务器上的shared/config/master.key

由于我没有得到对这个问题的任何答复,我最终通过nano .bashrcRAILS_MASTER_KEY=<my_master.key>添加到服务器上.bashrc文件的顶部。

我阅读的文章建议将其添加到.bashrc文件的最顶部,这似乎可以成功工作

这个怎么样:

run :local do
if File.exist?("config/master.key")
command "scp config/master.key #{fetch(:user)}@#{fetch(:domain)}:#{fetch(:shared_path)}/config/"
end
end

这需要定义以下设置::user:domain:shared_path

最新更新