Capistrano production.rb文件执行3个任务
composer install --no-dev
mkdir存储
上传! “ .env.production”,“。env”
前两个已执行,但上传失败:“无此文件或目录”。
我能够从命令行成功捕获文件。
如何将文件复制到当前发行目录?
$ cap --version
Capistrano Version: 3.11.0 (Rake Version: 12.3.1)
$ cap production deploy
...
01 mkdir -p ~/public_html/app/releases/20181122210112
...
composer install --no-dev
...
mkdir storage
...
SSHKit::Runner::ExecuteError:
Exception while executing as me@site.com:
scp: ~/public_html/app/releases/20181122210112/.env:
No such file or directory
DEBUG Uploading .env.production 0.0%
...
$
从命令行成功将文件保存:
$ scp .env.production me@site.com:~/public_html/app/releases/20181122210112/.env
production.rb
# use absolute path
set :deploy_to, "/home/user/public_html/app"
namespace :deploy do
desc "Install app dependencies with composer"
after :updated, :build do
on roles(:web) do
within release_path do
execute :composer, "install --no-dev"
execute :mkdir, "storage"
end
end
end
end
namespace :deploy do
desc "Copy Env"
after :finished, :copy do
on roles(:all) do
upload! ".env.production", "#{release_path}/.env"
end
end
end
答案 0 :(得分:0)
如果您需要将本地application.yml复制到服务器,并且已经在使用capistrano,则可以使用capistrano figaro gem,它会创建一个任务来更新服务器上的此文件。从理论上讲,您可以自动运行任务并使此文件更新。是一种古老的宝石,但是像吊饰一样可以工作。