Rails 4 + Capistrano 3 - 从本地仓库部署到生产服务器
Rails 4 + Capistrano 3 - Deploy to Production Server from Local Repo
我正在使用 Windows 10 和 Cygwin,我正在设置 Capistrano 3 以部署到我的生产环境。我相信我已经正确设置了所有内容,但我不知道如何将我的本地存储库推送到我的生产服务器。我在 GitHub 或其他此类网站上没有我的回购协议,我想将其保留在本地。我在 运行 cap production deploy
.
时收到以下错误消息
SSHKit::Runner::ExecuteError: Exception while executing as
myappuser@myappname.website.com: git exit status: 128 git stdout:
Nothing written git stderr: fatal: No remote configured to list refs
from.
SSHKit::Command::Failed: git exit status: 128 git stdout: Nothing
written git stderr: fatal: No remote configured to list refs from.
Tasks: TOP => git:check (See full trace by running task with --trace)
The deploy has failed with an error: Exception while executing as
myappuser@myappname.website.com: git exit status : 128 git stdout:
Nothing written git stderr: fatal: No remote configured to list refs
from.
这是我的 config\deploy.rb
文件:
# config valid only for current version of Capistrano
lock '3.4.0'
set :application, 'myappname
set :deploy_user, 'myappuser'
set :repo_url, "file:///C:/Users/me/Documents/repo/myappname.git"
# setup rvm.
set :rbenv_type, :user
set :rbenv_ruby, '2.1.5-p273'
set :rbenv_prefix, "RBENV_ROOT=#{fetch(:rbenv_path)} RBENV_VERSION=#{fetch(:rbenv_ruby)} #{fetch(:rbenv_path)}/bin/rbenv exec"
set :rbenv_map_bins, %w{rake gem bundle ruby rails}
set :assets_roles, [:app]
# Default value for :scm is :git
set :scm, :git
# Default value for :linked_files is []
set :linked_files, %w{config/database.yml config/application.yml}
# Default value for linked_dirs is []
set :linked_dirs, %w{bin log tmp/pids tmp/cache tmp/sockets vendor/bundle public/system}
# Default value for keep_releases is 5
set :keep_releases, 5
# which config files should be copied by deploy:setup_config
# see documentation in lib/capistrano/tasks/setup_config.cap
# for details of operations
set(:config_files, %w(
nginx.conf
application.yml
database.yml
unicorn.rb
unicorn_init.sh
))
# which config files should be made executable after copying
# by deploy:setup_config
set(:executable_config_files, %w(
unicorn_init.sh
))
# files which need to be symlinked to other parts of the
# filesystem. For example nginx virtualhosts, log rotation
# init scripts etc. The full_app_name variable isn't
# available at this point so we use a custom template {{}}
# tag and then add it at run time.
set(:symlinks, [
{
source: "nginx.conf",
link: "/etc/nginx/sites-enabled/{{full_app_name}}"
},
{
source: "unicorn_init.sh",
link: "/etc/init.d/unicorn_{{full_app_name}}"
},
{
source: "log_rotation",
link: "/etc/logrotate.d/{{full_app_name}}"
}
])
namespace :deploy do
# compile assets locally then rsync
after :finishing, 'deploy:cleanup'
end
我找到的所有答案都没有解决方案或针对 Capistrano 2,所以我想知道选项是否已更改。任何帮助将不胜感激!
编辑
我取得了一些进展,但它仍然没有读取我的本地存储库。这是错误消息:
SSHKit::Command::Failed: git exit status: 128 git stdout: Nothing
written git stderr: fatal: '/C:/Users/me/Documents/repo/myappname.git'
does not appear to be a git repository fatal: Could not read from
remote repository.
Please make sure you have the correct access rights and the repository
exists.
我已经为我的存储库尝试了所有不同的路径组合。我的 git 存储库位于以下路径:C:/Users/me/Documents/repo/myappname
。有没有具体的方法来引用我的本地存储库?
不幸的是,这不是 Capistrano 设计的工作方式。 Capistrano 所做的基本假设是您的项目驻留在服务器可以访问的存储库中(几乎总是这是托管在例如 Bitbucket 或 GitHub 上的 Git 存储库)。
Capistrano 通过运行 git 命令在服务器 上拉取 您的源代码。服务器无法查看您的本地存储库,这就是它不起作用的原因。
有一些插件试图改变 Capistrano 的行为以允许您正在寻找的 push 样式部署。在 GitHub 中搜索 "capistrano copy" 并试用它们。这可能是您要找的:
我一直在使用 capistrano-scm-copy 通过 SCP 从我的开发箱上传到 AWS 进行部署。注意事项 - 这就像 运行 剪刀。很高兴能够进行快速修补程序部署,在生产中验证它并执行 git 提交。但是你需要非常小心,不要忘记提交部分。
我正在使用 Windows 10 和 Cygwin,我正在设置 Capistrano 3 以部署到我的生产环境。我相信我已经正确设置了所有内容,但我不知道如何将我的本地存储库推送到我的生产服务器。我在 GitHub 或其他此类网站上没有我的回购协议,我想将其保留在本地。我在 运行 cap production deploy
.
SSHKit::Runner::ExecuteError: Exception while executing as myappuser@myappname.website.com: git exit status: 128 git stdout: Nothing written git stderr: fatal: No remote configured to list refs from.
SSHKit::Command::Failed: git exit status: 128 git stdout: Nothing written git stderr: fatal: No remote configured to list refs from.
Tasks: TOP => git:check (See full trace by running task with --trace) The deploy has failed with an error: Exception while executing as myappuser@myappname.website.com: git exit status : 128 git stdout: Nothing written git stderr: fatal: No remote configured to list refs from.
这是我的 config\deploy.rb
文件:
# config valid only for current version of Capistrano
lock '3.4.0'
set :application, 'myappname
set :deploy_user, 'myappuser'
set :repo_url, "file:///C:/Users/me/Documents/repo/myappname.git"
# setup rvm.
set :rbenv_type, :user
set :rbenv_ruby, '2.1.5-p273'
set :rbenv_prefix, "RBENV_ROOT=#{fetch(:rbenv_path)} RBENV_VERSION=#{fetch(:rbenv_ruby)} #{fetch(:rbenv_path)}/bin/rbenv exec"
set :rbenv_map_bins, %w{rake gem bundle ruby rails}
set :assets_roles, [:app]
# Default value for :scm is :git
set :scm, :git
# Default value for :linked_files is []
set :linked_files, %w{config/database.yml config/application.yml}
# Default value for linked_dirs is []
set :linked_dirs, %w{bin log tmp/pids tmp/cache tmp/sockets vendor/bundle public/system}
# Default value for keep_releases is 5
set :keep_releases, 5
# which config files should be copied by deploy:setup_config
# see documentation in lib/capistrano/tasks/setup_config.cap
# for details of operations
set(:config_files, %w(
nginx.conf
application.yml
database.yml
unicorn.rb
unicorn_init.sh
))
# which config files should be made executable after copying
# by deploy:setup_config
set(:executable_config_files, %w(
unicorn_init.sh
))
# files which need to be symlinked to other parts of the
# filesystem. For example nginx virtualhosts, log rotation
# init scripts etc. The full_app_name variable isn't
# available at this point so we use a custom template {{}}
# tag and then add it at run time.
set(:symlinks, [
{
source: "nginx.conf",
link: "/etc/nginx/sites-enabled/{{full_app_name}}"
},
{
source: "unicorn_init.sh",
link: "/etc/init.d/unicorn_{{full_app_name}}"
},
{
source: "log_rotation",
link: "/etc/logrotate.d/{{full_app_name}}"
}
])
namespace :deploy do
# compile assets locally then rsync
after :finishing, 'deploy:cleanup'
end
我找到的所有答案都没有解决方案或针对 Capistrano 2,所以我想知道选项是否已更改。任何帮助将不胜感激!
编辑
我取得了一些进展,但它仍然没有读取我的本地存储库。这是错误消息:
SSHKit::Command::Failed: git exit status: 128 git stdout: Nothing written git stderr: fatal: '/C:/Users/me/Documents/repo/myappname.git' does not appear to be a git repository fatal: Could not read from remote repository.
Please make sure you have the correct access rights and the repository exists.
我已经为我的存储库尝试了所有不同的路径组合。我的 git 存储库位于以下路径:C:/Users/me/Documents/repo/myappname
。有没有具体的方法来引用我的本地存储库?
不幸的是,这不是 Capistrano 设计的工作方式。 Capistrano 所做的基本假设是您的项目驻留在服务器可以访问的存储库中(几乎总是这是托管在例如 Bitbucket 或 GitHub 上的 Git 存储库)。
Capistrano 通过运行 git 命令在服务器 上拉取 您的源代码。服务器无法查看您的本地存储库,这就是它不起作用的原因。
有一些插件试图改变 Capistrano 的行为以允许您正在寻找的 push 样式部署。在 GitHub 中搜索 "capistrano copy" 并试用它们。这可能是您要找的:
我一直在使用 capistrano-scm-copy 通过 SCP 从我的开发箱上传到 AWS 进行部署。注意事项 - 这就像 运行 剪刀。很高兴能够进行快速修补程序部署,在生产中验证它并执行 git 提交。但是你需要非常小心,不要忘记提交部分。