Last active
August 30, 2017 07:34
-
-
Save LeoNero/f34d59c60eb169dc83e9612283253ee6 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 'capistrano/setup' | |
require 'capistrano/deploy' | |
require "capistrano/scm/git" #If using 3.9.0 | |
install_plugin Capistrano::SCM::Git #If using 3.9.0 |
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
server "1.2.3.4.5", user: "deploy", roles: %w{app web} | |
# Set some defaults | |
set :repo_url, "git@github.com:myproject.git" | |
set :application, "myproject" | |
set :branch, "master" | |
set :scm, :git #If using Capistrano 3.5.0 or 3.4.0. | |
set :format, :pretty | |
set :log_level, 'any' | |
set :pty, false | |
set :keep_releases, 2 | |
# Target roles | |
set :target_roles, %w(web) | |
set :linked_dirs, %w(node_modules) | |
# Include only the build artifact | |
set :include_dir, 'dist' | |
# Build | |
if fetch(:stage) == "production" then | |
set :deploy_to, -> { "/var/www/html/production" } | |
set :npm_env_variables, { API_URL: "https://api.mysite.com.br" } | |
else | |
set :deploy_to, -> { "/var/www/html/staging" } | |
set :npm_env_variables, { API_URL: "https://stg.api.mysite.com.br" } | |
end | |
namespace :deploy do | |
desc 'Install node modules' | |
task :install_node_modules do | |
on roles(:web) do | |
within release_path do | |
execute :npm, 'install', '-s' | |
end | |
end | |
end | |
desc 'Restart application' | |
task :restart do | |
on roles(:web) do | |
sudo :service, fetch(:application), 'restart' | |
end | |
end | |
after :updated, :install_node_modules | |
after :publishing, :restart | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment