-
-
Save harrylove/6557062 to your computer and use it in GitHub Desktop.
Capistrano deploy script for Meteor on AWS running RedHat
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This assumes you've already set up your instance with node, npm, forever, mongodb, configured ports, and have optionally added a web server like nginx to proxy access to meteor. | |
Local | |
1. Install Ruby | |
2. gem install capistrano | |
3. cd /your/meteor/project | |
4. capify . | |
5. edit config/deploy.rb as needed with below | |
AWS | |
6. Add your public key to authorized_keys on the EC2 instance | |
7. On the EC2 instance, create a ssh key for the instance itself; add that public key to authorized_keys on the same instance | |
8. From the EC2 instance, ssh [your EC2instance], accept the fingerprint, etc., then exit | |
Local | |
9. cap deploy:setup | |
10: cap deploy:check | |
11: cap deploy:cold | |
12: cap deploy:start | |
The app should be running on your instance now | |
13. Edit your meteor project and push changes to your git repo | |
14. cap deploy:restart | |
The app should be running with your updates |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
default_run_options[:pty] = true | |
set :ssh_options, { | |
:forward_agent => true, | |
:auth_methods => ['publickey'], | |
:keys => ['~/.ssh/pemfile.pem'] | |
} | |
set :use_sudo, false | |
set :user, 'ssh_username' | |
set :scm, :git | |
set :application, 'Your application name' | |
set :repository, 'ssh://ssh_username@domain/home/user/etc/git/repo.git' | |
set :deploy_via, :remote_cache | |
set :deploy_to, '/var/www/apps/myapp' | |
set :domain, 'www.example.com' | |
set :server_name, domain | |
role :web, domain | |
role :app, domain | |
set :default_environment, { | |
'ROOT_URL' => 'http://www.example.com', | |
'MONGO_URL' => 'mongodb://localhost', | |
'PORT' => 8080 | |
} | |
# This is a Rails-specific param, just want to disable the functionality | |
set :normalize_asset_timestamps, false | |
# This would be set to an array of dirs from your app that you want | |
# to persist across deploys | |
set :shared_children, %w(log) | |
# Set this to 'mrt' if you want to use Meteorite | |
set :meteor, 'meteor' | |
namespace :deploy do | |
task :start, :roles => :app do | |
run "forever start --sourceDir #{current_path} -a -l #{shared_path}/log/production.log -e #{shared_path}/log/error.log bundle/main.js" | |
end | |
task :restart, :roles => :app do | |
run "forever stop --sourceDir #{current_path} bundle/main.js" | |
run "forever start --sourceDir #{current_path} -a -l #{shared_path}/log/production.log -e #{shared_path}/log/error.log bundle/main.js" | |
end | |
end | |
after "deploy:finalize_update" do | |
run "cd #{release_path}; #{meteor} bundle bundle.tgz" | |
run "cd #{release_path}; tar xvf #{File.join(release_path, "bundle.tgz")}" | |
run "rm -rf #{File.join(release_path, "bundle.tgz")}" | |
run "cd #{release_path}/bundle/programs/server; npm rm fibers; npm install fibers" | |
end | |
# if you want to clean up old releases on each deploy uncomment this: | |
# after "deploy:restart", "deploy:cleanup" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment