diff --git a/.gitignore b/.gitignore index 7940c4c..732bfd4 100644 --- a/.gitignore +++ b/.gitignore @@ -1,7 +1,13 @@ -build +public node_modules .sass-cache .DS_Store *.orig .tmp npm-debug.log +.DS_Store +/.env +/log + +# AppFlow +/web/.htaccess diff --git a/Capfile b/Capfile new file mode 100644 index 0000000..e0e3bd9 --- /dev/null +++ b/Capfile @@ -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' diff --git a/Gemfile b/Gemfile new file mode 100644 index 0000000..f84b980 --- /dev/null +++ b/Gemfile @@ -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' + diff --git a/Gemfile.lock b/Gemfile.lock new file mode 100644 index 0000000..927e411 --- /dev/null +++ b/Gemfile.lock @@ -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 diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..b4e9350 --- /dev/null +++ b/Makefile @@ -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 diff --git a/config/deploy.rb b/config/deploy.rb new file mode 100644 index 0000000..5f67e17 --- /dev/null +++ b/config/deploy.rb @@ -0,0 +1,65 @@ +# config valid only for current version of Capistrano +lock "3.8.0" + +set :application, "ginetta-skeleton" +set :repo_url, 'git@github.com:ginetta/skeleton.git' + +set :nc_terminal, 'com.googlecode.iterm2' + +# set :file_permissions_paths, [ ] +# set :file_permissions_groups, ["www-data"] + +# set :cap_notify_emails, [ 'tech@ttss.ch' ] +# set :cap_notify_from, 'deploy@ginetta.net' +# 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' diff --git a/config/deploy/cap_notify.rb b/config/deploy/cap_notify.rb new file mode 100644 index 0000000..85ab28c --- /dev/null +++ b/config/deploy/cap_notify.rb @@ -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, ['EMAIL1@YOURDOMAIN.COM', 'EMAIL2@YOURDOMAIN.COM'] + + 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 => "
" + msg + "<\p>"} + end + end +end diff --git a/config/deploy/development.rb b/config/deploy/development.rb new file mode 100644 index 0000000..82de793 --- /dev/null +++ b/config/deploy/development.rb @@ -0,0 +1,23 @@ +set :stage, :development + +# Simple Role Syntax +# ================== +#role :app, %w{deploy@example.com} +#role :web, %w{deploy@example.com} +#role :db, %w{deploy@example.com} + +# 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) diff --git a/config/deploy/production.rb b/config/deploy/production.rb new file mode 100644 index 0000000..b4a3627 --- /dev/null +++ b/config/deploy/production.rb @@ -0,0 +1,26 @@ +set :stage, :production + +set :deploy_to, -> { "/var/www/vhosts/#{fetch(:application)}" } + +# Simple Role Syntax +# ================== +#role :app, %w{deploy@example.com} +#role :web, %w{deploy@example.com} +#role :db, %w{deploy@example.com} + +# 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) diff --git a/config/deploy/staging.rb b/config/deploy/staging.rb new file mode 100644 index 0000000..8a1e9b7 --- /dev/null +++ b/config/deploy/staging.rb @@ -0,0 +1,25 @@ +set :stage, :staging + +set :deploy_to, -> { "/var/www/vhosts/#{fetch(:application)}" } + +# Simple Role Syntax +# ================== +#role :app, %w{deploy@example.com} +#role :web, %w{deploy@example.com} +#role :db, %w{deploy@example.com} + +# 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) diff --git a/gulp/config.js b/gulp/config.js index 943ac18..8a8a892 100644 --- a/gulp/config.js +++ b/gulp/config.js @@ -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 { diff --git a/public b/public new file mode 120000 index 0000000..c795b05 --- /dev/null +++ b/public @@ -0,0 +1 @@ +build \ No newline at end of file