[英]Deploying .env file with Capistrano
I want to upload .env
file to my remote machine from local machine while deploying with Capistrano, but as I am not a Ruby pro I do not get the result I want. 我要在使用Capistrano进行部署时从本地计算机
.env
文件上传到本地计算机上,但是由于我不是Ruby专业人士,因此无法获得所需的结果。 What I want to do is take my local .env
and make it available on remote machine in the shared_path
. 我想做的是获取本地
.env
并使其在shared_path
远程计算机上可用。 Afterwards, just symlink it with the current_path
. 之后,只需将其与
current_path
符号链接即可。
namespace :env do
desc "We take local env and set up on remote"
task :setup do
on roles(:app), in: :sequence, wait: 5 do
puts File.read(".env"), "#{shared_path}/config/.env"
execute "ln -nfs #{shared_path}/config/.env #{current_path}/.env"
end
end
end
Now this code creates .env as an empty file. 现在,此代码将.env创建为空文件。 What I am doing wrong?
我做错了什么? Or should I just execute
rsync
or something with Capistrano in order to achieve what I want? 还是我应该只执行
rsync
或Capistrano来完成我想要的事情?
I don't think puts
will work there. 我认为
puts
不会在那里起作用。
Try the capistrano's upload method . 尝试capistrano的上载方法 。
upload(from, to, options={}, &block)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.