How do I target a specific commit SHA with capistrano deploy
For Capistrano 2.9 until 3.0:
cap -S revision=80655da8d80aaaf92ce5357e7828dc09adb00993 deploy
For older versions of Capistrano, you can deploy a particular git commit/tree/branch/tag by doing this:
cap -s branch=80655da8d80aaaf92ce5357e7828dc09adb00993 deploy
In some cases there may be a need of specifying the Environment as an argument as well. production
is just an example.
cap production -S revision=80655da8d80aaaf92ce5357e7828dc09adb00993 deploy
How to deploy a specific revision with capistrano 3
The parameter seems to be gone in Capistrano 3. You have to set the env variable REVISION="revision" and include it in your deploy.rb
set :branch, ENV["REVISION"] || ENV["BRANCH_NAME"]
How to deploy LAMP app with capistrano?
I am able to resolve this issue. It was due to SSH account. I used following command "sudo apt-get install openssh-server" to resolve it.
Different actions for different environments
You can always use if..elseif..end
as follows:
if fetch(:stage) == :production
...
elsif fetch(:stage) == :staging
...
end
Or, if you have staging and production only:
task :upload_config do
on roles(:all) do |host|
within fetch(:shared_path) do
upload! "#{fetch(:stage).to_s}-config.php", "#{fetch :shared_path}/#{fetch(:stage).to_s}-config.php"
end
end
end
What is your preferred php deployment strategy?
For PHP, SVN with Phing build scripts are the way to go. Phing is similar to ANT but is written in PHP, which makes it much easier for PHP developers to modify for their needs.
Our deployment routine is as follows:
- Everyone develops on the same local server at work, every developer has a checkout on his machine back home as well.
- Commits trigger a post-commit hook which updates a staging server.
- Tests are ran on staging server, if they pass - continue.
- Phing build script is ran:
- Takes down production server, switching the domain to an "Under construction" page
- Runs SVN update on production checkout
- Runs schema deltas script
- Runs tests
- If tests fail - run rollback script
- If tests pass, server routes back to production checkout
There's also phpUnderControl, which is a Continuous Integration server. I didn't find it very useful for web projects to be honest.
Atomic website update with Git
You can do what you're imagining using symlinks. Moving one symlink over another is an atomic operation, so you should be able to avoid any 404 errors.
Your hook would deploy your site to a directory, perhaps named after the commit hash. Then it would make a symlink to that, perhaps called staging. Then it would move that symlink over the production symlink.
hash=`git rev-parse HEAD`
git checkout-index -a -f --prefix=/srv/www/$hash/
ln -s /srv/www/$hash /srv/www/staging
mv -T /srv/www/staging /srv/www/production
The -T
argument is the short form for --no-target-directory
, which is a part of GNU mv
and prevents it from moving the source into the destination. Read more about target directories.
Related Topics
Replacing an Element in Nested Array Ruby
Sinatra Doesn't Know This Ditty Even When Default Route Is Implemented with Modular Style
How to Make Private Activities
Heroku-18: Git Push Fails. Showing Different Versions of Ruby on Push
To_SQL Not Working on Update_Attributes or .Save
Attr_Accessor, Not Able to Access Property
Rails + Google Calendar API Events Not Created
Error Occurs When Trying to Install Homebrew on a MAC for Ruby on Rails
{|_, E| E.Length>1} What Is the Use of Underscore ( _ ) in Ruby
Rails "Template Is Missing" Error
Rails Form_For Never Invokes the Create Controller Action to Use Redirect_To
Tilt (Kramdown) Preventing Erb Processing When Rendering Markdown
Ruby, Value Bucketing, Beautify Code
Hook Before All Delyed Job Success Callback to Save Successfully Completed Jobs
Assets Precompiling Error with Jquery UI Plugin
Check If String Is Repetition of an Unknown Substring
How to Get the Current Working Directory's Absolute Path from Irb