Deploy a folder of GitHub branch to EC2 server using Capistrano - ruby-on-rails

I am doing my first server deployment. I am developing a Rails API project with Angular as front end. Server code is saved in a folder in GitHub branch. I need to deploy only the content of that folder into the server. Currently, in deploy.rb, I have given it as
set :repo_url, "https://url to the repository"
How can I specify the repo_url?

I have found the solution. You can specify the sub folder name in the deploy.rb file as shown below
set :repo_tree, 'folder_name'
Thanks

Related

Ruby on Rails - Testing changes to Capistrano's deploy.rb

I'm trying to test some changes out on production without having to commit and push the changes because I only want to commit what actually works. The project I'm working on was created with Rails (3.0.2), and deploys with Capistrano (3.1). I've tried making changes in the root folder of my app and redeploying, and the changes are not reflected on the website. I've tried making changes in the root/current directory and redeploying and that didn't work.
Is there any way I can redeploy changes to the server without having to push it to Github first?
Is there any way I can redeploy changes to the server without having
to push it to Github first?
No this isn't possible since one of the first things that Capistrano will do is git clone the latest from whatever branch you've specified in your deploy config.
I'm not sure what your familiarity with Rails is but the proper way to do this would be to create a new staging environment and deploy to that. The staging environment would have similar settings to your production environment with a separate database so that you don't affect production data.
Capistrano 3 supports this flow out of the box so that once you've set everything up you can simply call
cap staging deploy
to deploy to the staging environment, and
cap production deploy
to deploy to the production environment.

Capistrano 3 simple update

I have a Rails application which I deployed to a remote server with git and Capistrano 3. It works fine.
Sometimes after I change some files (in app/views, for example), I want to upload those changes to the current release without running the full cycle of deploy process.
I need one command to upload changed files (files in the last commit in git) to the current release directory on the remote server.
What is the best way to do it?
Improve Performance with Remote Cache
The way Capistrano works, it will create a new clone/export of your repository on every deploy. That can be slow, so there’s an option to add some extra commands to our deploy.rb recipe to speed things up. Add the following to the section of your deploy.rb where you describe your scm settings: set :deploy_via, :remote_cache
This command makes Capistrano do a single clone/checkout of your repository on your server the first time, then do an svn up or git pull on every deploy instead of doing an entire clone/export. If you deploy often, you’ll notice that this speeds up your deployments significantly.
Hope this help you what you are looking for!!!
For more detail check out this link. deploy-with-capistrano

How do maintain different production.rb files on different branches of the same project?

We have a Rails app that's deployed on two servers. One server uses the master branch while the other uses the staging branch. We use staging internally to test the application, and then we merge with master and deploy.
The staging branch has different email settings in config/production.rb than the master branch. How can I maintain different production.rb/email settings for each branch while still merging everything else?
Adding the file to .gitignore would pull it from the repo, so that's not an option.
Make another environment called staging.
Other option is to put the environment file in shared folder on server and link to it while deploying.
Dont put these settings into production.rb. Use an initializer file in config/initializers/email.rb (or something like that) to set these initial settings based on Rails.env

git repository move rails application code to live to test repositories

Hello I am having Two Branches on Github for the Rails Application.
One is Test and Other is Live.
Problem is Live branch is having the latest changes on it and Test is not having the lates changes.
so I want to transfer the code from Live to test on github.
Both the environment having different Database name and having different deploy.rb file with their environment.
So my concern is how to update the Test environment code with live environment code without changing the database and deploy.rb file.
Please Help me.
Thanks.
You could put a merge driver which would always keep your local version for those two files (deploy.rb and database.yml).
See as an example "How do I tell git to always select my local version for conflicted merges on a specific file?".
You can declare that merger driver in a .gitattributes file, which mean it will be published from upstream repo to upstream repo (as opposed to a git config solution which would be purely local to your repo)

Track a Rails project on private repo on GitHub with Redmine and Integrity deployed on Heroku

Scenario
Project A is a Rails application:
Code hosted on GitHub on a private repo.
Deployed on Heroku (which has a readonly file system).
Project R that is an instance of Redmine, used to manage my project A:
Code hosted on GitHub on another private repo (same GitHub account).
Deployed on Heroku (which has a readonly file system).
Project CI that is an instance of Integrity, used to continuous integrate (by running tests) my project A:
Code hosted on GitHub on a third private repo (same GitHub account).
Deployed on Heroku (which has a readonly file system).
What I want
I want to be able to:
Use the Repository feature on Redmine on project R (in essence, to be able to see the repository from project R).
Run the tests on CI.
My problem
To clone and keep up to date the code of project A on both project R and project CI.
What I tried
For the 1. point, I've tried to follow the instructions found on http://www.redmine.org/wiki/1/RedmineRepositories, with the only difference that I've created the local bare copy of A into the root of R (because of Heroku's constraints on file system), which caused the creation of /A.git dir.
After that, I've re-deployed on Heroku the project R, and in the Redmine's project A settings I've configured as SCM "Git" and A.git as Path to .git directory (I've also tried ./A.git).
However, when I point to the tab Repository of A project on Redmine, I got a 500 with message:
"The entry or revision was not found in the repository."
Where am I wrong?
Any suggestion?
Thank you!
I think it is currently impossible to integrate Git or Mercurial repos with a Redmine instance running on Heroku due to the read-only filesystem constraint. I asked Eric Davis and he thinks so too. SVN and CVS don't require Redmine to have a local copy of the repo, and so I think they work, whereas Git and Hg don't.

Resources