-
-
Save supremebeing7/625336bd3eb6cf048759eb42a4c2c53d to your computer and use it in GitHub Desktop.
This file contains 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
require 'mina/git' | |
require 'json' | |
set :domain, '0.0.0.0' | |
set :user, 'nodejs' | |
set :deploy_to, '/home/nodejs/api' | |
set :repository, 'git@.../api.git' | |
set :branch, 'master' | |
set :shared_paths, [ 'tmp' ] | |
set :term_mode, :pretty | |
set_default :node_version, 'stable' | |
task :setup do | |
invoke :'nvm' | |
end | |
task :environment do | |
invoke :'nvm:load' | |
end | |
task :deploy => :environment do | |
deploy do | |
invoke :'git:clone' | |
invoke :'nvm:install' | |
invoke :'npm:install' | |
invoke :'deploy:cleanup' | |
to :launch do | |
# invoke :'process:restart' | |
end | |
end | |
end | |
task :nvm do | |
queue 'echo "-----> Installing Node Version Manager"' | |
queue 'curl -s https://raw.github.com/creationix/nvm/master/install.sh | sh' | |
invoke :'nvm:load' | |
end | |
namespace :nvm do | |
task :load do | |
queue 'echo "-----> Loading nvm"' | |
queue %{ | |
source ~/.nvm/nvm.sh | |
} | |
queue 'echo "-----> Now using nvm v.`nvm --version`"' | |
end | |
task :install do | |
# Specifying a Node.js version | |
# copy from: https://devcenter.heroku.com/articles/nodejs-support#specifying-a-node-js-version | |
# | |
# Use the engines section of your package.json | |
# { | |
# "name": "myapp", | |
# "description": "a really cool app", | |
# "version": "0.0.1", | |
# "engines": { | |
# "node": "0.10.x" | |
# } | |
# } | |
package = File.read("package.json") | |
config = JSON.parse(package) | |
if config['engines'] && config['engines']['node'] | |
set :node_version, config['engines']['node'] | |
end | |
# Install Node.js via Node Version Manager | |
# and symlink it to project_dir/.bin | |
queue %{ | |
echo "-----> Install node v.#{node_version!}" | |
nvm install #{node_version!} | |
ln -s ${NVM_BIN} ./.bin | |
} | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment