简体   繁体   English

Rails 4.2 Capistrano 3部署

[英]Rails 4.2 capistrano 3 deployment

I am totally new to rails deployment. 我对Rails部署完全陌生。 After googling, I still find it hard to understand how to deploy rails apps. 谷歌搜索之后,我仍然很难理解如何部署Rails应用程序。

So, my questions are: 因此,我的问题是:

  1. After setting up the VPS with all rails dependencies, where do I store my codebase? 设置完所有Rails依赖关系的VPS之后,我该在哪里存储我的代码库? The root directory of the VPS or some specific locations eg www/ or public/ ? VPS的根目录或某些特定位置,例如www/public/

  2. Should I upload the whole rails app folder or just part of it? 我应该上传整个Rails应用文件夹还是其中一部分? I have paperclip in my rails app, and paperclip creates a system/ directory in the public/ folder, so should I upload system/ ? 我的Rails应用程序中有回形针,并且回形针在public/文件夹中创建了system/目录,因此我应该上传system/吗?

  3. In Capistrano 3, there is a repo_url field, I know they support file://, https://, ssh://, or svn+ssh:// , but most of the articles about capistrano put github repositories into that. 在Capistrano 3中,有一个repo_url字段,我知道它们支持file://, https://, ssh://, or svn+ssh:// ,但是有关capistrano的大多数文章都将github存储库放入其中。 However, I do not have such a github repo. 但是,我没有这样的github存储库。 What should I input then? 那我应该输入什么呢?

Thank you for your attention. 感谢您的关注。

Answers to the specific questions raised: 对提出的具体问题的答案:

After setting up the VPS with all rails dependencies, where do I store my codebase? 设置完所有Rails依赖关系的VPS之后,我该在哪里存储我的代码库? The root directory of the VPS or some specific locations eg www/ or public/? VPS的根目录或某些特定位置,例如www /或public /?

It will be deployed to the folder pointed by :deploy_to parameter. 它将部署到:deploy_to参数指向的文件夹中。 If not specified, :deploy_to defaults to /var/www/#{fetch(:application) See: https://github.com/capistrano/capistrano/blob/05f63f5f333bb261f2a4c4497174361c48143252/lib/capistrano/defaults.rb#L3 如果未指定, :deploy_to默认为/var/www/#{fetch(:application)请参阅: https : //github.com/capistrano/capistrano/blob/05f63f5f333bb261f2a4c4497174361c48143252/lib/capistrano/defaults.rb#L3

Should I upload the whole rails app folder or just part of it? 我应该上传整个Rails应用文件夹还是其中一部分? I have paperclip in my rails app, and paperclip creates a system/ directory in the public/ folder, so should I upload system/? 我的Rails应用程序中有回形针,并且回形针在public /文件夹中创建了system /目录,因此我应该上传system /吗?

Paperclip system folder is specific to the environment; 回形针system文件夹特定于环境; each environment (development, production,...) will have its own system folder which will store the files uploaded on that specific environment. 每个环境(开发,生产等)都将拥有自己的system文件夹,该文件夹将存储在该特定环境上上传的文件。 This folder should not be part of the code being deployed. 此文件夹不应成为正在部署的代码的一部分。

The recommended way of handing such folders is the keep them in a shared folder on the server, and create symlinks in the current version of the code so that the same folder is used for storing/retrieving attachments. 推荐的处理此类文件夹的方法是将其保存在服务器上的共享文件夹中,并在当前版本的代码中创建符号链接,以便使用同一文件夹存储/检索附件。 See Section 3. Update custom links section in http://robmclarty.com/blog/how-to-deploy-a-rails-4-app-with-git-and-capistrano for more details about this. 有关此详细信息,请参见http://robmclarty.com/blog/how-to-deploy-a-rails-4-app-with-git-and-capistrano中的 Section 3. Update custom links节。

As mentioned there, the same applies to config/database.yml file, and any other file containing environment specific configurations. 如此处所述,这同样适用于config/database.yml文件以及包含环境特定配置的任何其他文件。

In Capistrano 3, there is a repo_url field, I know they support file://, https://, ssh://, or svn+ssh://, but most of the articles about capistrano put github repositories into that. 在Capistrano 3中,有一个repo_url字段,我知道它们支持file://,https://,ssh://或svn + ssh://,但是有关capistrano的大多数文章都将github存储库放入其中。 However, I do not have such a github repo. 但是,我没有这样的github存储库。 What should I input then? 那我应该输入什么呢?

Depends on where the code you are deploying is stored. 取决于要部署的代码的存储位置。 If it is in a local folder, use the file::// format to specify where the files are located. 如果它在本地文件夹中,请使用file:://格式来指定文件的位置。

You can set up your own private git server , then in deploy.rb you can put something like 您可以设置自己的私有git服务器 ,然后在deploy.rb中输入以下内容:

set :repo_url, 'ssh://user@server_ip/path/to/your_git_repo.git'

When you commit your changes to the git repo, you do not have to upload the app to the server. 将更改提交到git repo时,不必将应用程序上载到服务器。 Capistrano will upload the app for you when you deploy. Capistrano将在您部署时为您上传应用程序。

where do i put my code base? 我在哪里放置代码库? This is determined by what you put in deploy.rb eg 这取决于您在deploy.rbdeploy.rb例如

set :deploy_to, '/path/to/my_codebase'

Whether to upload the /system directory will depend on whether you want the paperclip images on your version control. 是否上载/system目录将取决于您是否要在版本控件上使用回形针图像。 If not you can add the directory to gitignore . 如果没有,您可以将目录添加到gitignore Here is a tutorial on how to deploy on ubuntu 14.04 passenger and NGINX. 这是一个关于如何在ubuntu 14.04 passenger和NGINX上进行部署的教程 if you are not using Passenger and Nginx you can skip to how to configure capistrano and make adjustments depending on your setup. 如果您不使用Passenger和Nginx,则可以跳至如何配置capistrano并根据设置进行调整。

EDIT 编辑

You need to install git on your development machine and set up a git server on your VPS as explained on the link above, add your remote server to your local machine using 您需要按照上述链接上的说明在开发计算机上安装git并在VPS上设置git服务器,然后使用以下命令将远程服务器添加到本地计算机

git remote add origin <server>

where 'server' is the url to your git repo in the VPS eg 其中“服务器”是您在VPS中的git repo的网址,例如

ssh://VPS_user@VPS_ip/path/to/your_git_repo.git

Now when you commit and push your changes to the server, capistrano will deploy the latest version on your git server. 现在,当您提交并将更改推送到服务器时,capistrano将在您的git服务器上部署最新版本。

Here is a link with a guide on how to get started with git 这是有关如何开始使用git的指南的链接

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM