From e739aff5eab29f78f0c23eda64d780f52b7045ba Mon Sep 17 00:00:00 2001 From: f Date: Fri, 2 Feb 2018 19:50:45 -0300 Subject: [PATCH] deploy --- .env.example | 1 + Capfile | 17 +++++++++++++++++ Gemfile | 8 ++++++++ Gemfile.lock | 39 +++++++++++++++++++++++++++++++++++++++ bin/cap | 21 +++++++++++++++++++++ bin/capify | 21 +++++++++++++++++++++ config/deploy.rb | 9 +++++++++ config/deploy/example.rb | 22 ++++++++++++++++++++++ 8 files changed, 138 insertions(+) create mode 100644 .env.example create mode 100644 Capfile create mode 100755 bin/cap create mode 100755 bin/capify create mode 100644 config/deploy.rb create mode 100644 config/deploy/example.rb diff --git a/.env.example b/.env.example new file mode 100644 index 00000000..1cca08ad --- /dev/null +++ b/.env.example @@ -0,0 +1 @@ +SECRET_KEY_BASE= diff --git a/Capfile b/Capfile new file mode 100644 index 00000000..13f00797 --- /dev/null +++ b/Capfile @@ -0,0 +1,17 @@ +# frozen_string_literal: true +# Load DSL and Setup Up Stages +require 'capistrano/setup' + +# Includes default deployment tasks +require 'capistrano/deploy' + +# Includes tasks from other gems included in your Gemfile +require 'capistrano/passenger' +require 'capistrano/bundler' +require 'capistrano/rbenv' +require 'capistrano/rails' +require 'capistrano/scm/git' +install_plugin Capistrano::SCM::Git + +# Loads custom tasks from `lib/capistrano/tasks' if you have any defined. +Dir.glob('lib/capistrano/tasks/*.rake').each { |r| import r } diff --git a/Gemfile b/Gemfile index d2c77d8e..c449ad09 100644 --- a/Gemfile +++ b/Gemfile @@ -5,6 +5,7 @@ git_source(:github) do |repo_name| "https://github.com/#{repo_name}.git" end +gem 'dotenv-rails', require: 'dotenv/rails-now' # Bundle edge Rails instead: gem 'rails', github: 'rails/rails' gem 'rails', '~> 5.1.4' @@ -49,4 +50,11 @@ group :development do # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring gem 'spring' gem 'spring-watcher-listen', '~> 2.0.0' + gem 'bcrypt_pbkdf' + gem 'capistrano' + gem 'capistrano-bundler' + gem 'capistrano-passenger' + gem 'capistrano-rails' + gem 'capistrano-rbenv' + gem 'rbnacl', '< 5.0' end diff --git a/Gemfile.lock b/Gemfile.lock index f162718a..79b5ea85 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -40,15 +40,34 @@ GEM tzinfo (~> 1.1) addressable (2.5.2) public_suffix (>= 2.0.2, < 4.0) + airbrussh (1.3.0) + sshkit (>= 1.6.1, != 1.7.0) arel (8.0.0) autoprefixer-rails (7.2.4) execjs + bcrypt_pbkdf (1.0.0) bindex (0.5.0) bootstrap (4.0.0.beta3) autoprefixer-rails (>= 6.0.3) popper_js (>= 1.12.3, < 2) sass (>= 3.5.2) builder (3.2.3) + capistrano (3.10.1) + airbrussh (>= 1.0.0) + i18n + rake (>= 10.0.0) + sshkit (>= 1.9.0) + capistrano-bundler (1.3.0) + capistrano (~> 3.1) + sshkit (~> 1.2) + capistrano-passenger (0.2.0) + capistrano (~> 3.0) + capistrano-rails (1.3.1) + capistrano (~> 3.1) + capistrano-bundler (~> 1.1) + capistrano-rbenv (2.1.3) + capistrano (~> 3.1) + sshkit (~> 1.3) capybara (2.16.1) addressable mini_mime (>= 0.1.3) @@ -62,6 +81,10 @@ GEM colorator (1.1.0) concurrent-ruby (1.0.5) crass (1.0.3) + dotenv (2.2.1) + dotenv-rails (2.2.1) + dotenv (= 2.2.1) + railties (>= 3.2, < 5.2) em-websocket (0.5.1) eventmachine (>= 0.12.9) http_parser.rb (~> 0.6.0) @@ -130,6 +153,9 @@ GEM mini_portile2 (2.3.0) minitest (5.11.3) multi_json (1.12.2) + net-scp (1.2.1) + net-ssh (>= 2.6.5) + net-ssh (4.2.0) netaddr (1.5.1) nio4r (2.2.0) nokogiri (1.8.2) @@ -174,6 +200,8 @@ GEM rb-fsevent (0.10.2) rb-inotify (0.9.10) ffi (>= 0.5.0, < 2) + rbnacl (4.0.2) + ffi rouge (3.1.0) ruby_dep (1.5.0) ruby_parser (3.10.1) @@ -209,6 +237,9 @@ GEM activesupport (>= 4.0) sprockets (>= 3.0.0) sqlite3 (1.3.13) + sshkit (1.15.1) + net-scp (>= 1.1.2) + net-ssh (>= 2.8.0) temple (0.8.0) thor (0.20.0) thread_safe (0.3.6) @@ -237,8 +268,15 @@ PLATFORMS ruby DEPENDENCIES + bcrypt_pbkdf bootstrap (~> 4.0.0.beta3) + capistrano + capistrano-bundler + capistrano-passenger + capistrano-rails + capistrano-rbenv capybara (~> 2.13) + dotenv-rails email_address haml-rails jbuilder (~> 2.5) @@ -248,6 +286,7 @@ DEPENDENCIES puma (~> 3.7) rails (~> 5.1.4) rails_warden + rbnacl (< 5.0) sass-rails (~> 5.0) selenium-webdriver spring diff --git a/bin/cap b/bin/cap new file mode 100755 index 00000000..1c425e44 --- /dev/null +++ b/bin/cap @@ -0,0 +1,21 @@ +#!/usr/bin/env ruby +# frozen_string_literal: true + +# +# This file was generated by Bundler. +# +# The application 'cap' is installed as part of a gem, and +# this file is here to facilitate running it. +# + +bundle_binstub = File.expand_path("../bundle", __FILE__) +load(bundle_binstub) if File.file?(bundle_binstub) + +require "pathname" +ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile", + Pathname.new(__FILE__).realpath) + +require "rubygems" +require "bundler/setup" + +load Gem.bin_path("capistrano", "cap") diff --git a/bin/capify b/bin/capify new file mode 100755 index 00000000..c219b055 --- /dev/null +++ b/bin/capify @@ -0,0 +1,21 @@ +#!/usr/bin/env ruby +# frozen_string_literal: true + +# +# This file was generated by Bundler. +# +# The application 'capify' is installed as part of a gem, and +# this file is here to facilitate running it. +# + +bundle_binstub = File.expand_path("../bundle", __FILE__) +load(bundle_binstub) if File.file?(bundle_binstub) + +require "pathname" +ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile", + Pathname.new(__FILE__).realpath) + +require "rubygems" +require "bundler/setup" + +load Gem.bin_path("capistrano", "capify") diff --git a/config/deploy.rb b/config/deploy.rb new file mode 100644 index 00000000..0f6181d6 --- /dev/null +++ b/config/deploy.rb @@ -0,0 +1,9 @@ +# frozen_string_literal: true +set :application, 'sutty' +set :repo_url, 'git@0xacab.org:itacate-kefir/sutty.git' + +set :bundle_flags, '--deployment' +set :default_env, path: '/usr/lib/passenger/bin:$PATH' + +set :linked_dirs, %w{_sites} +set :linked_files, %w{.env} diff --git a/config/deploy/example.rb b/config/deploy/example.rb new file mode 100644 index 00000000..c1ace7cc --- /dev/null +++ b/config/deploy/example.rb @@ -0,0 +1,22 @@ +# frozen_string_literal: true +set :deploy_user, 'DEPLOY_USER' +set :deploy_to, '/srv/http/sutty.kefir.red' +set :branch, 'rails' +set :rack_env, 'production' + +set :tmp_dir, "#{fetch :deploy_to}/tmp" +set :bundle_path, '/srv/http/gems.kefir.red' + +set :rbenv_type, :user +set :rbenv_ruby, '2.3.6' + +set :rbenv_prefix, "RBENV_ROOT=#{fetch(:rbenv_path)} RBENV_VERSION=#{fetch(:rbenv_ruby)} #{fetch(:rbenv_path)}/bin/rbenv exec" +set :rbenv_map_bins, %w(rake gem bundle ruby rails) +set :rbenv_roles, :all # default value + +# Evitar compilar nokogiri +set :bundle_env_variables, nokogiri_use_system_libraries: 1 + +server 'DEPLOY_SERVER', + user: fetch(:deploy_user), + roles: %w(app web db)