Skip to content
This repository has been archived by the owner on Apr 29, 2022. It is now read-only.

Capistrano setup #155

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
build
public
node_modules
.sass-cache
.DS_Store
*.orig
.tmp
npm-debug.log
.DS_Store
/.env
/log

# AppFlow
/web/.htaccess
23 changes: 23 additions & 0 deletions Capfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Load DSL and Setup Up Stages
require 'capistrano/setup'

# Includes default deployment tasks
require 'capistrano/deploy'

# Load tasks from gems
require 'capistrano/npm'

require "capistrano/scm/git"
install_plugin Capistrano::SCM::Git

# Loads custom tasks from `lib/capistrano/tasks' if you have any defined.
# Customize this path to change the location of your custom tasks.
Dir.glob('lib/capistrano/tasks/*.cap').each { |r| import r }

# require 'capistrano-nc/nc'

# load 'config/deploy/cap_notify.rb'

require 'slackistrano/capistrano'

# require 'capistrano/file-permissions'
14 changes: 14 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
source 'https://rubygems.org'

gem "capistrano", "~> 3.6"

gem 'capistrano-npm'

# gem 'capistrano-nc', '~> 0.1'

# gem 'actionmailer', '~> 4.2.0'

gem 'slackistrano'

# gem 'capistrano-file-permissions'

33 changes: 33 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
GEM
remote: https://rubygems.org/
specs:
airbrussh (1.1.2)
sshkit (>= 1.6.1, != 1.7.0)
capistrano (3.8.0)
airbrussh (>= 1.0.0)
i18n
rake (>= 10.0.0)
sshkit (>= 1.9.0)
capistrano-npm (1.0.2)
capistrano (>= 3.0.0)
i18n (0.8.1)
net-scp (1.2.1)
net-ssh (>= 2.6.5)
net-ssh (4.1.0)
rake (12.0.0)
slackistrano (3.1.0)
capistrano (>= 3.5.0)
sshkit (1.12.0)
net-scp (>= 1.1.2)
net-ssh (>= 2.8.0)

PLATFORMS
ruby

DEPENDENCIES
capistrano (~> 3.6)
capistrano-npm
slackistrano

BUNDLED WITH
1.14.6
35 changes: 35 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#
# a Makefile for node based vhosts
#

include .env

all:

#
# NDEPLOY
#
ndeploy_stage:
cap -n staging deploy

ndeploy_prod:
cap -n production deploy

#
# DEPLOY
#
deploy_stage:
cap staging deploy

deploy_prod:
cap production deploy
# cap -z node-x.foo.ch production deploy

#
# DEPLOY ROLLBACK
#
deploy_stage_rollback:
cap staging deploy:rollback

deploy_prod_rollback:
cap production deploy:rollback
65 changes: 65 additions & 0 deletions config/deploy.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
# config valid only for current version of Capistrano
lock "3.8.0"

set :application, "ginetta-skeleton"
set :repo_url, '[email protected]:ginetta/skeleton.git'

set :nc_terminal, 'com.googlecode.iterm2'

# set :file_permissions_paths, [ ]
# set :file_permissions_groups, ["www-data"]

# set :cap_notify_emails, [ '[email protected]' ]
# set :cap_notify_from, '[email protected]'
# set :cap_notify_callsign, 'GINETTA'
# set :cap_notify_latest_commit, proc { `git rev-parse HEAD`.strip }

set :slackistrano, {
channel: '#s-ginetta-ttss',
webhook: 'https://hooks.slack.com/services/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'
}

# Default branch is :master
# ask :branch, `git rev-parse --abbrev-ref HEAD`.chomp

# Default deploy_to directory is /var/www/my_app_name
set :deploy_to, -> { "/var/www/vhosts/#{fetch(:application)}" }

# set :log_level, :info
set :log_level, :debug

# Default value for :format is :airbrussh.
# set :format, :airbrussh

# You can configure the Airbrussh format using :format_options.
# These are the defaults.
# set :format_options, command_output: true, log_file: "log/capistrano.log", color: :auto, truncate: :auto

# Default value for :pty is false
# set :pty, true

# Default value for :linked_files is []
# append :linked_files, "config/database.yml", "config/secrets.yml"
# set :linked_files, %w{.env web/.htaccess}

# Default value for linked_dirs is []
# append :linked_dirs, "log", "tmp/pids", "tmp/cache", "tmp/sockets", "public/system"
# set :linked_dirs, %w{web/app/uploads web/app/ewww}

# Default value for default_env is {}
# set :default_env, { path: "/opt/ruby/bin:$PATH" }
set :default_env, { path: "/usr/local/bin:$PATH" }

# Default value for keep_releases is 5
set :keep_releases, 2

# before "deploy:updated", "deploy:set_permissions:acl"

# namespace :deploy do
# desc "Send email notification"
# task :send_notification do
# Notifier.deploy_notification(self).deliver_now
# end
# end
#
# after :deploy, 'deploy:send_notification'
67 changes: 67 additions & 0 deletions config/deploy/cap_notify.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
=begin
Capistrano deployment email notifier for Rails 3

Do you need to send email notifications after application deployments?

Christopher Sexton developed a Simple Capistrano email notifier for rails. You can find details at http://www.codeography.com/2010/03/24/simple-capistrano-email-notifier-for-rails.html.

Here is Rails 3 port of the notifier.

The notifier sends an email after application deployment has been completed.

How to use it?

1. Add this file to config/deploy folder.
2. Update the file with your google credentials and from email address.
3. Add the following content to config/deploy.rb.

require 'config/deploy/cap_notify.rb'

# add email addresses for people who should receive deployment notifications
set :notify_emails, ['[email protected]', '[email protected]']

after :deploy, 'deploy:send_notification'

# Create task to send a notification
namespace :deploy do
desc 'Send email notification'
task :send_notification do
Notifier.deploy_notification(self).deliver
end
end

4. Update deploy.rb with destination email addresses for the notifications.
5. To test run this command:

cap deploy:send_notification
bundle exec cap production deploy:send_notification

=end

require 'action_mailer'

ActionMailer::Base.delivery_method = :smtp
ActionMailer::Base.smtp_settings = {
:enable_starttls_auto => false,
:tls => false,
:ssl => true,
:address => '',
:port => 465,
:domain => '',
:authentication => '',
:user_name => '',
:password => ''
}

class Notifier < ActionMailer::Base
default :from => ''
def deploy_notification(cap_vars)
now = Time.now

mail(:to => fetch(:cap_notify_emails),
:subject => "") do |format|
format.text { render :text => msg}
format.html { render :text => "<p>" + msg + "<\p>"}
end
end
end
23 changes: 23 additions & 0 deletions config/deploy/development.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
set :stage, :development

# Simple Role Syntax
# ==================
#role :app, %w{[email protected]}
#role :web, %w{[email protected]}
#role :db, %w{[email protected]}

# Extended Server Syntax
# ======================
server 'atlantis', user: 'deploy', roles: %w{web app db}

# you can set custom ssh options
# it's possible to pass any option but you need to keep in mind that net/ssh understand limited list of options
# you can see them in [net/ssh documentation](http://net-ssh.github.io/net-ssh/classes/Net/SSH.html#method-c-start)
# set it globally
# set :ssh_options, {
# keys: %w(~/.ssh/id_rsa),
# forward_agent: false,
# auth_methods: %w(password)
# }

fetch(:default_env).merge!(wp_env: :production)
26 changes: 26 additions & 0 deletions config/deploy/production.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
set :stage, :production

set :deploy_to, -> { "/var/www/vhosts/#{fetch(:application)}" }

# Simple Role Syntax
# ==================
#role :app, %w{[email protected]}
#role :web, %w{[email protected]}
#role :db, %w{[email protected]}

# Extended Server Syntax
# ======================
server 'compute-01.stage.ginetta.net', user: 'deploy', roles: %w{web app db}
#server 'DUMMY.LINK.DUM', user: 'deploy', roles: %w{web app db}

# you can set custom ssh options
# it's possible to pass any option but you need to keep in mind that net/ssh understand limited list of options
# you can see them in [net/ssh documentation](http://net-ssh.github.io/net-ssh/classes/Net/SSH.html#method-c-start)
# set it globally
# set :ssh_options, {
# keys: %w(~/.ssh/id_rsa),
# forward_agent: false,
# auth_methods: %w(password)
# }

# fetch(:default_env).merge!(wp_env: :production)
25 changes: 25 additions & 0 deletions config/deploy/staging.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
set :stage, :staging

set :deploy_to, -> { "/var/www/vhosts/#{fetch(:application)}" }

# Simple Role Syntax
# ==================
#role :app, %w{[email protected]}
#role :web, %w{[email protected]}
#role :db, %w{[email protected]}

# Extended Server Syntax
# ======================
server 'compute-01.stage.ginetta.net', user: 'deploy', roles: %w{web app db}

# you can set custom ssh options
# it's possible to pass any option but you need to keep in mind that net/ssh understand limited list of options
# you can see them in [net/ssh documentation](http://net-ssh.github.io/net-ssh/classes/Net/SSH.html#method-c-start)
# set it globally
# set :ssh_options, {
# keys: %w(~/.ssh/id_rsa),
# forward_agent: false,
# auth_methods: %w(password)
# }

# fetch(:default_env).merge!(wp_env: :staging)
16 changes: 8 additions & 8 deletions gulp/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,14 @@ module.exports = () => {
};

const destPaths = {
root: 'build/',
scripts: 'build/js/',
styles: 'build/css/',
pages: 'build/',
content: 'build/content/',
assets: 'build/assets/',
meta: 'build/',
revManifest: 'build/rev-manifest.json',
root: 'public/',
scripts: 'public/js/',
styles: 'public/css/',
pages: 'public/',
content: 'public/content/',
assets: 'public/assets/',
meta: 'public/',
revManifest: 'public/rev-manifest.json',
};

return {
Expand Down
1 change: 1 addition & 0 deletions public