funguy
funguy

Reputation: 2160

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. What I want to do is take my local .env and make it available on remote machine in the shared_path. Afterwards, just symlink it with the 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. What I am doing wrong? Or should I just execute rsync or something with Capistrano in order to achieve what I want?

Upvotes: 1

Views: 1048

Answers (1)

gcstr
gcstr

Reputation: 1537

I don't think puts will work there.

Try the capistrano's upload method.

upload(from, to, options={}, &block)

Upvotes: 2

Related Questions