简体   繁体   English

用Capistrano部署.env文件

[英]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.

相关问题 / usr / bin / env ruby​​没有这样的文件或目录:使用capistrano 3,capistrano / rbenv,capistrano / bundler和capistrano / rails(使用rails 4) - /usr/bin/env ruby no such file or directory: Using capistrano 3, capistrano/rbenv, capistrano/bundler and capistrano/rails (using rails 4) Rails capistrano /usr/bin/env 没有文件或这样的目录 - Rails capistrano /usr/bin/env no file or such directory 使用Capistrano进行部署 - Deploying with Capistrano 没有使用Capistrano部署太阳黑子的PID文件错误 - No PID file error deploying with sunspot with Capistrano Capistrano错误:“ / usr / bin / env ruby​​:没有这样的文件或目录” - Capistrano Error: '/usr/bin/env ruby : No such file or directory' 如何让capistrano在部署时编写.rvmrc文件? - How to make capistrano write a .rvmrc file when deploying? Ruby On Rails:使用Capistrano 3进行部署时,如何在文件中写入yml配置? - Ruby On Rails: How to write yml configurations in a file when deploying with Capistrano 3? 使用Capistrano在EC2上部署Rails 3应用程序时,“在Capistrano配方中需要此文件”错误 - “Please require this file from within a Capistrano recipe” error while deploying Rails 3 app on EC2 using Capistrano Capistrano未部署回形针图像 - Capistrano not deploying paperclip images 使用Capistrano在Dreamhost上部署Rails 3 - Deploying Rails 3 on Dreamhost with Capistrano
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM