Why use capistrano
This recipe has been tested on a VPS provisioned using the method described in this post. In particular it assumes:. As well as using this in production across several sites, this process has been tested on fresh Rails 3. If you already have a Capistrano V2 configuration for the application to be deployed, I suggest you archive all of this off and start from scratch with Capistrano 3. In general this will mean renaming for example appenidng.
Then run bundle install if you're adding capistrano 3 for the first time or bundle update capistrano if you're upgrading. You may need to do some of the usual Gemfile juggling if you're updating and there are dependency conflicts. The source for this tutorial is available on github. This task, which some indeed regard as a chore, might seem to add little or no direct or additional value to your project whatsoever.
However, a well crafted process [of deployment] certainly helps to reduce the overheads, such as time being wasted trying to get products on-line.
Unless you have a very specific and changing requirements, with absolutely domain-focused needs, when the time comes to putting your application online, taking advantage of the various dedicated tools, automation methods or scripts will come to your aid to get back to your actual work of developing quicker — greatly!
In this DigitalOcean article, we will be taking a good look at Capistrano: a Ruby based remote server automation tool which can be easily used to automate mundane deployment and system management tasks. Using Capistrano, you can almost entirely automate all actions you would normally take to get your product live.
Capistrano, as mentioned in our introduction, is a Ruby based, open-source server management tool. Although it might come out as just another alternative to many existing automation solutions, it is an excellent one to use thanks to its great [advanced] features. Similar to other automation libraries, using Capistrano arbitrary functions can be performed on the virtual server without direct interference - by having Capistrano execute a script i.
However, in general, you can think of this tool as your very own deployment assistant, helping you with almost anything from getting the code on your deployment machine to bootstrapping the deployment process — and it can do this on multiple systems at once or in a round-robin fashion. Looking at many tutorials on the internet, you might get the impression that Capistrano is the perfect framework for RoR. However, despite being a Ruby focused framework or tool , you can safely use it to handle many different kind of deployment scenarios with its recipes , including deploying PHP web-applications.
Ruby is a general-purpose i. The concise and ordered way one can use Ruby to write scripts thanks to the way the language is designed helped the language gain huge momentum. Coupled with the goals and mentality of RoR framework, and features it provided as an Object Oriented Programming OOP language compared to competitors available at the time , Ruby became one of the most widely preferred languages in the last decade.
Recipes in Capistrano lingo translate to files which contain operative directions for deploying or managing applications and servers. These recipes can be modified to support a great variety of language specific deployments that are not Ruby or Rails related.
You can think of them as a script which Capistrano uses to perform its actions. Open the mod-http-passenger. Save the mod-http-passenger. First, we'll create a separate branch used to deploy our application. In the Create New Branch dialog, specify the branch name capistrano-deploy in our case and click Create. Open the project Gemfile and add the following Capistrano gems. To capify the application, select Tools Capistrano Capify Application from the main menu.
The following files will be added to the project. Note that Tools Capistrano Capify Application executes the cap install command. After running this command, RubyMine creates the run configuration for executing the install task. If necessary, you can customize this configuration to pass specific arguments. Open the Capfile and add the following lines to load the required dependencies. In the same file, specify the following settings for rbenv.
Before configuring deployment settings, commit and push changes to a remote repository. In our tutorial, it will be the capistrano-deploy branch of the sample Rails application. Here you need to specify the Git repository details and the deployment path on our web server. Since we are using the staging configuration for deployment, we need to add the staging environment in our Rails application. Then, we should provide custom credentials. Create the staging environment as described in Creating Rails Environments.
This option specifies that the master key used to decrypt credentials should be available on our web server. At this point, we should be able to deploy our app. You will see a lot of output from Capistrano that explains what it is doing. If everything went right, your app should be up and running on the IP address or domain that you specified in production. In this article we demonstrated how to configure Capistrano to deploy a Rails application to a Puma server.
You can find more information about Capistrano and its options on capistranorb. Would you like to learn how to build sustainable Rails apps and ship more often?
Learn more and download a free copy. Have a comment? Join the discussion on the forum. Search for:. Introduction Deploying a Ruby on Rails application involves a number of steps, such as copying source code files, running database migrations, pre or post-compiling assets and restarting the web server.
0コメント