dcs-best-practices 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (39) hide show
  1. checksums.yaml +7 -0
  2. data/.editorconfig +18 -0
  3. data/.gitignore +12 -0
  4. data/.rubocop.yml +33 -0
  5. data/.ruby-gemset +1 -0
  6. data/.ruby-version +1 -0
  7. data/CODE_OF_CONDUCT.md +13 -0
  8. data/Gemfile +3 -0
  9. data/README.md +73 -0
  10. data/Rakefile +3 -0
  11. data/bin/console +12 -0
  12. data/bin/setup +7 -0
  13. data/dcs-best-practices.gemspec +46 -0
  14. data/lib/capistrano/dcs.rb +7 -0
  15. data/lib/capistrano/dcs/assets.rb +3 -0
  16. data/lib/capistrano/dcs/defaults.rb +39 -0
  17. data/lib/capistrano/dcs/remote.rb +3 -0
  18. data/lib/capistrano/dcs/sidekiq.rb +3 -0
  19. data/lib/capistrano/dcs/ssh.rb +3 -0
  20. data/lib/capistrano/tasks/assets.cap +29 -0
  21. data/lib/capistrano/tasks/remote.cap +15 -0
  22. data/lib/capistrano/tasks/sidekiq.cap +22 -0
  23. data/lib/capistrano/tasks/ssh.cap +17 -0
  24. data/lib/dcs-best-pratices.rb +3 -0
  25. data/lib/dcs_best_practices/version.rb +5 -0
  26. data/lib/generators/dcs/deploy_generator.rb +14 -0
  27. data/lib/generators/dcs/templates/deploy/.editorconfig.tt +18 -0
  28. data/lib/generators/dcs/templates/deploy/.rubocop.yml.tt +54 -0
  29. data/lib/generators/dcs/templates/deploy/Capfile.tt +17 -0
  30. data/lib/generators/dcs/templates/deploy/config/application.yml.tt +18 -0
  31. data/lib/generators/dcs/templates/deploy/config/database.yml.tt +24 -0
  32. data/lib/generators/dcs/templates/deploy/config/deploy.rb.tt +20 -0
  33. data/lib/generators/dcs/templates/deploy/config/deploy/production.rb.tt +9 -0
  34. data/lib/generators/dcs/templates/deploy/config/deploy/staging.rb.tt +12 -0
  35. data/lib/generators/dcs/templates/deploy/config/initializers/figaro.rb.tt +2 -0
  36. data/lib/generators/dcs/templates/deploy/config/newrelic.yml.tt +21 -0
  37. data/lib/generators/dcs/templates/deploy/config/puma.rb.tt +38 -0
  38. data/lib/generators/dcs/templates/deploy/config/secrets.yml.tt +11 -0
  39. metadata +380 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 0ece3b14f9a2f2624e794a4b41f3e3f7b63f468f2a0a7c43c02ec51a30d4219a
4
+ data.tar.gz: 4e1bfdb59d1a05ef32faa2a26f7f326826f6d207544185eca2e0ade9c907c654
5
+ SHA512:
6
+ metadata.gz: 1f68def26578c50ed7b0a27cac8914e0a44239add33c30533c44358b6d85ba2211e18dcb1abaabe3b159517cbaeccc245b03d1f7f7c7e70915d3eaf952412b69
7
+ data.tar.gz: 761d95be0ab805b9b96e940ae4c6c05b7ec567dc3a5d366afe7ad965ad84ee7ffc31a831f6f152f1de41f08bfd72d7ce7d3d111b46b30b0c7916bfb8f5b67cbc
data/.editorconfig ADDED
@@ -0,0 +1,18 @@
1
+ # EditorConfig helps developers define and maintain consistent
2
+ # coding styles between different editors and IDEs
3
+ # editorconfig.org
4
+
5
+ root = true
6
+ [*]
7
+ # Change these settings to your own preference
8
+ indent_style = space
9
+ indent_size = 2
10
+
11
+ # We recommend you to keep these unchanged
12
+ end_of_line = lf
13
+ charset = utf-8
14
+ trim_trailing_whitespace = true
15
+ insert_final_newline = true
16
+
17
+ [*.md]
18
+ trim_trailing_whitespace = false
data/.gitignore ADDED
@@ -0,0 +1,12 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ .idea/
11
+ doc/
12
+ *.gem
data/.rubocop.yml ADDED
@@ -0,0 +1,33 @@
1
+ require:
2
+ - rubocop-performance
3
+
4
+ AllCops:
5
+ TargetRubyVersion: 2.5.1
6
+ DisplayCopNames: true
7
+
8
+ Exclude:
9
+ - bin/**/*
10
+ - test/**/*
11
+
12
+ Style/Documentation:
13
+ Enabled: false
14
+ Bundler/OrderedGems:
15
+ Enabled: false
16
+ Style/DoubleNegation:
17
+ Enabled: false
18
+ Style/ClassAndModuleChildren:
19
+ EnforcedStyle: compact
20
+
21
+ Metrics/AbcSize:
22
+ Max: 25
23
+ Metrics/LineLength:
24
+ Max: 120
25
+ Metrics/MethodLength:
26
+ Max: 25
27
+ Metrics/BlockLength:
28
+ Max: 30
29
+ Exclude:
30
+ - "app/admin/**/*"
31
+ - "Rakefile"
32
+ - "**/*.rake"
33
+ - "spec/**/*.rb"
data/.ruby-gemset ADDED
@@ -0,0 +1 @@
1
+ dcs-best-practices
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ ruby-2.6.5
@@ -0,0 +1,13 @@
1
+ # Contributor Code of Conduct
2
+
3
+ As contributors and maintainers of this project, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities.
4
+
5
+ We are committed to making participation in this project a harassment-free experience for everyone, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, ethnicity, age, or religion.
6
+
7
+ Examples of unacceptable behavior by participants include the use of sexual language or imagery, derogatory comments or personal attacks, trolling, public or private harassment, insults, or other unprofessional conduct.
8
+
9
+ Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct. Project maintainers who do not follow the Code of Conduct may be removed from the project team.
10
+
11
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by opening an issue or contacting one or more of the project maintainers.
12
+
13
+ This Code of Conduct is adapted from the [Contributor Covenant](http://contributor-covenant.org), version 1.0.0, available at [http://contributor-covenant.org/version/1/0/0/](http://contributor-covenant.org/version/1/0/0/)
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
data/README.md ADDED
@@ -0,0 +1,73 @@
1
+ # DarkCreative Studio Best Practices
2
+ This gem makes your configuring deployment faster!
3
+ > for Ruby on Rails applications
4
+
5
+ ## Features
6
+
7
+ * Deployment
8
+ - Capistrano integration
9
+ - Configuration generator
10
+ - Custom tasks
11
+ - Predefined default [settings](lib/capistrano/dcs/defaults.rb)
12
+ - Pretty logs with [Airbrussh gem](https://github.com/mattbrictson/airbrussh)
13
+
14
+ * Environment
15
+ - All secret variables in one file [application](lib/generators/dcs/templates/deploy/config/application.yml.tt)
16
+ - Variables with [Figaro gem](https://github.com/laserlemon/figaro)
17
+ - Require keys
18
+
19
+ * Web server
20
+ - Unicorn in requirements
21
+ - Config predefined
22
+
23
+ ## Requirements
24
+
25
+ It is tested and works with:
26
+
27
+ * MRI >= 2.1
28
+ * Rails >= 4.2
29
+
30
+ Other versions are untested but might work fine.
31
+
32
+ ## Installation
33
+
34
+ Add this line to your application's Gemfile into `development` group:
35
+
36
+ gem 'dcs-best-practices'
37
+
38
+ And then execute:
39
+
40
+ $ bundle
41
+
42
+ ## Usage
43
+
44
+ ### Add deployment configuration:
45
+
46
+ $ rails g dcs:deploy
47
+
48
+ This creates the following files, you can edit them for your choice.
49
+
50
+ ```
51
+ ├── Capfile
52
+ └── config
53
+ ├── initializers
54
+ │ └── figaro.rb
55
+ ├── deploy
56
+ │ ├── production.rb
57
+ │ └── testing.rb
58
+ ├── environments
59
+ │ └── testing.rb
60
+ ├── deploy.rb
61
+ ├── newrelic.yml
62
+ ├── database.yml
63
+ ├── secrets.yml
64
+ └── application.yml
65
+ ├── .editorconfig
66
+ └── .rubocop.yml
67
+ ```
68
+
69
+ ## License
70
+
71
+ This project rocks and uses MIT License (MIT).
72
+
73
+ Copyright (c) 2019 DarkCreative Studio
data/Rakefile ADDED
@@ -0,0 +1,3 @@
1
+ require 'bundler/gem_tasks'
2
+ require 'yard'
3
+ YARD::Rake::YardocTask.new
data/bin/console ADDED
@@ -0,0 +1,12 @@
1
+ ßrequire "bundler/setup"
2
+ require "locum_best_practices"
3
+
4
+ # You can add fixtures and/or initialization code here to make experimenting
5
+ # with your gem easier. You can also use a different console, if you like.
6
+
7
+ # (If you use this, don't forget to add pry to your Gemfile!)
8
+ # require "pry"
9
+ # Pry.start
10
+
11
+ require "irb"
12
+ IRB.start
data/bin/setup ADDED
@@ -0,0 +1,7 @@
1
+ #!/bin/bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+
5
+ bundle install
6
+
7
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,46 @@
1
+ # frozen_string_literal: true
2
+
3
+ lib = File.expand_path('lib', __dir__)
4
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
+ require 'dcs_best_practices/version'
6
+
7
+ Gem::Specification.new do |spec|
8
+ spec.name = 'dcs-best-practices'
9
+ spec.version = DCSBestPractices::VERSION
10
+ spec.authors = %w[DarkWater]
11
+ spec.email = %w[denis.arushanov@darkcreative.ru]
12
+
13
+ spec.summary = 'Simple best practices, used for soft deployment with capistrano to some servers'
14
+ spec.description = 'Contains deploy configuration'
15
+ spec.homepage = 'https://bitbucket.org/DCStudio/best-prectices'
16
+
17
+ raise 'RubyGems 2.5.1 or newer is required to protect against public gem pushes.' unless spec.respond_to?(:metadata)
18
+
19
+ spec.metadata['allowed_push_host'] = 'https://rubygems.org'
20
+
21
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(/^(test|spec|features)/) }
22
+ spec.bindir = 'exe'
23
+ spec.executables = spec.files.grep(/^exe/) { |f| File.basename(f) }
24
+ spec.require_paths = %w[lib]
25
+
26
+ spec.required_ruby_version = '>= 2.5'
27
+
28
+ spec.add_development_dependency 'bundler', '~> 1.17.3', '>= 1.17.3'
29
+ spec.add_development_dependency 'rake', '~> 12.0', '>= 12.0.0'
30
+
31
+ spec.add_development_dependency 'redcarpet', '~> 3.4', '>= 3.5.0'
32
+ spec.add_development_dependency 'yard', '~> 0.7', '>= 0.7.5'
33
+
34
+ spec.add_dependency 'airbrussh', '~> 1.3', '>= 1.3.0'
35
+ spec.add_dependency 'capistrano', '~> 3.10', '>= 3.10.0'
36
+ spec.add_dependency 'capistrano-rails', '~> 1.4', '>= 1.4.0'
37
+ spec.add_dependency 'capistrano-rails-console', '~> 2.3', '>= 2.3.0'
38
+ spec.add_dependency 'capistrano-rvm', '~> 0.1', '>= 0.1.0'
39
+ spec.add_dependency 'capistrano3-puma', '~> 4.0', '>= 4.0.0'
40
+ spec.add_dependency 'figaro', '~> 1.1', '>= 1.1.1'
41
+ spec.add_dependency 'puma', '~> 4.1', '>= 4.1.0'
42
+
43
+ spec.add_development_dependency 'rubocop', '~> 0.7', '>= 0.7.0'
44
+ spec.add_development_dependency 'rubocop-performance', '~> 1.5', '>= 1.5.0'
45
+ spec.add_development_dependency 'solargraph', '~> 0.35', '>= 0.35.0'
46
+ end
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'capistrano/dcs/defaults'
4
+ require 'capistrano/dcs/assets'
5
+ require 'capistrano/dcs/remote'
6
+ require 'capistrano/dcs/sidekiq'
7
+ require 'capistrano/dcs/ssh'
@@ -0,0 +1,3 @@
1
+ # frozen_string_literal: true
2
+
3
+ load File.expand_path('../tasks/assets.cap', __dir__)
@@ -0,0 +1,39 @@
1
+ # frozen_string_literal: true
2
+
3
+ namespace :load do
4
+ task :defaults do
5
+ lock '>= 3.4.0'
6
+ load 'config/deploy.rb'
7
+ load "config/deploy/#{fetch(:stage)}.rb" if fetch(:stage)
8
+
9
+ set :deploy_to, "/home/#{fetch(:user)}/projects/#{fetch(:application)}"
10
+ set :sidekiq_pid, "#{fetch(:deploy_to)}/shared/tmp/pids/sidekiq-0.pid"
11
+ set :bundle_without, %i[development test console doc]
12
+ set :use_sudo, false
13
+
14
+ ask :branch, proc { `git rev-parse --abbrev-ref HEAD`.chomp }.call
15
+
16
+ set :pty, true
17
+
18
+ set :log_level, :info
19
+ set :keep_releases, 5
20
+ set :env, worker_count: 8
21
+
22
+ set :linked_files, fetch(:linked_files, []) + %w[config/application.yml public/sitemap.xml]
23
+ set :linked_dirs, fetch(:linked_dirs, []) + %w[bin log tmp/cache tmp/pids tmp/sockets vendor/bundle
24
+ public/system public/uploads public/mails]
25
+
26
+ set :default_environments, 'RAILS_ENV=production'
27
+ set :production_rake, "rvm use #{fetch(:rvm_ruby_version)} do bundle exec rake #{fetch(:default_environments)}"
28
+ set :rake, "rvm use #{fetch(:rvm_ruby_version)} do bundle exec rake"
29
+ set :bundle_cmd, "rvm use #{fetch(:rvm_ruby_version)} do bundle"
30
+
31
+ set :assets_roles, %i[web app db]
32
+
33
+ set :sidekiq_start_cmd, "cd #{fetch(:deploy_to)}/current; #{fetch(:bundle_cmd)} exec sidekiq " \
34
+ '--index 0 -C config/sidekiq.yml --environment production --daemon'
35
+ set :sidekiq_stop_cmd, "kill -QUIT `cat #{fetch(:sidekiq_pid)}`"
36
+
37
+ after 'deploy:publishing', 'puma:restart'
38
+ end
39
+ end
@@ -0,0 +1,3 @@
1
+ # frozen_string_literal: true
2
+
3
+ load File.expand_path('../tasks/remote.cap', __dir__)
@@ -0,0 +1,3 @@
1
+ # frozen_string_literal: true
2
+
3
+ load File.expand_path('../tasks/sidekiq.cap', __dir__)
@@ -0,0 +1,3 @@
1
+ # frozen_string_literal: true
2
+
3
+ load File.expand_path('../tasks/ssh.cap', __dir__)
@@ -0,0 +1,29 @@
1
+ namespace :assets do
2
+ desc 'Precompile all assets in pipeline'
3
+ task :precompile do
4
+ on roles(:app, :web, :db) do
5
+ execute "cd #{fetch(:deploy_to)}/current; #{fetch(:production_rake)} assets:precompile"
6
+ end
7
+ end
8
+
9
+ desc 'Clears not actual versions of assets'
10
+ task :clear do
11
+ on roles(:app, :wev, :db) do
12
+ execute "cd #{fetch(:deploy_to)}/current; #{fetch(:production_rake)} assets:clean"
13
+ end
14
+ end
15
+
16
+ desc 'Clobber?'
17
+ task :clobber do
18
+ on roles(:app, :wev, :db) do
19
+ execute "cd #{fetch(:deploy_to)}/current; #{fetch(:production_rake)} assets:clobber"
20
+ end
21
+ end
22
+
23
+ desc 'Permanent removes all assets'
24
+ task :explode do
25
+ on roles(:app, :wev, :db) do
26
+ execute "cd #{fetch(:deploy_to)}/shared/public; rm -rf assets"
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,15 @@
1
+ namespace :remote do
2
+ # TODO: move comments to README
3
+ # e.g: 'cap stage logs:tail[logfile]' will tail 'shared_path/log/logfile.log'.
4
+ desc 'Tail logs on remote host'
5
+ task :logs, :file do |_t, args|
6
+ on roles(:app) do |server|
7
+ info "Opening a console on: #{server} ..."
8
+ params = "#{fetch(:user)}@#{server}"
9
+ file = "#{args[:file] || fetch(:rails_env)}"
10
+ params += %( -t "tail -f #{fetch(:deploy_to)}/shared/log/#{file}.log")
11
+ info "Read logs for user: #{fetch(:user)}"
12
+ exec "ssh #{params}"
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,22 @@
1
+ namespace :sidekiq do
2
+ desc 'Sidekiq start'
3
+ task :start do
4
+ on roles(:app, :web) do
5
+ execute "#{fetch(:sidekiq_start_cmd)}"
6
+ end
7
+ end
8
+
9
+ desc 'Sidekiq Stop'
10
+ task :stop do
11
+ on roles(:app, :web) do
12
+ execute "#{fetch(:sidekiq_stop_cmd)}"
13
+ end
14
+ end
15
+
16
+ desc 'Sidekiq restart'
17
+ task :restart do
18
+ on roles(:app, :web) do
19
+ execute "#{fetch(:sidekiq_stop_cmd)}; sleep 5; #{fetch(:sidekiq_start_cmd)}"
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,17 @@
1
+ namespace :ssh do
2
+ desc 'SSH connect and move to current folder'
3
+ task :connect do
4
+ on roles(:app) do |server|
5
+ server_index = ARGV[2].to_i
6
+
7
+ return if server != roles(:app)[server_index]
8
+
9
+ info "Opening a console on: #{server} ..."
10
+ params = "#{fetch(:user)}@#{server}"
11
+ params += " -p #{server.port}" if server.port
12
+ params += %( -t "cd #{fetch(:deploy_to)}/current && bash -l")
13
+ info "Connection success for user: #{fetch(:user)}"
14
+ exec "ssh #{params}"
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,3 @@
1
+ # frozen_string_literal: true
2
+
3
+ module DCSBestPractices; end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module DCSBestPractices
4
+ VERSION = '0.0.1'
5
+ end
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ class DCS::DeployGenerator < Rails::Generators::Base
4
+ desc <<~EOF
5
+ Prepares application to deploy and add custom stages. `testing` and `production` stages are created by default.
6
+ EOF
7
+
8
+ argument :stages, type: :array, default: [], banner: 'custom stages'
9
+ source_root File.expand_path('templates', __dir__)
10
+
11
+ def add_deploy_templates
12
+ directory 'deploy', '.'
13
+ end
14
+ end
@@ -0,0 +1,18 @@
1
+ # EditorConfig helps developers define and maintain consistent
2
+ # coding styles between different editors and IDEs
3
+ # editorconfig.org
4
+
5
+ root = true
6
+ [*]
7
+ # Change these settings to your own preference
8
+ indent_style = space
9
+ indent_size = 2
10
+
11
+ # We recommend you to keep these unchanged
12
+ end_of_line = lf
13
+ charset = utf-8
14
+ trim_trailing_whitespace = true
15
+ insert_final_newline = true
16
+
17
+ [*.md]
18
+ trim_trailing_whitespace = false
@@ -0,0 +1,54 @@
1
+ require:
2
+ - rubocop-performance
3
+ - rubocop-rspec
4
+ - rubocop-rails
5
+
6
+ AllCops:
7
+ TargetRubyVersion: 2.5.1
8
+ TargetRailsVersion: 5.2.3
9
+ DisplayCopNames: true
10
+
11
+ Exclude:
12
+ - bin/**/*
13
+ - db/**/*
14
+ - test/**/*
15
+ - config/initializers/devise.rb
16
+ - config/initializers/active_admin.rb
17
+ - config/environments/production.rb
18
+ - config/environments/development.rb
19
+ - config/routes.rb
20
+ - node_modules/**/*
21
+
22
+ Style/FrozenStringLiteralComment:
23
+ Enabled: false
24
+ Style/Documentation:
25
+ Enabled: false
26
+ Bundler/OrderedGems:
27
+ Enabled: false
28
+ Style/DoubleNegation:
29
+ Enabled: false
30
+ Style/ClassAndModuleChildren:
31
+ EnforcedStyle: compact
32
+
33
+ Metrics/AbcSize:
34
+ Max: 25
35
+ Metrics/LineLength:
36
+ Max: 120
37
+ Metrics/MethodLength:
38
+ Max: 25
39
+ Metrics/BlockLength:
40
+ Max: 30
41
+ Exclude:
42
+ - "app/admin/**/*"
43
+ - "Rakefile"
44
+ - "**/*.rake"
45
+ - "spec/**/*.rb"
46
+
47
+ Rails:
48
+ Enabled: true
49
+
50
+ Rails/SkipsModelValidations:
51
+ Whitelist: [update_all, decrement!, increment!, touch]
52
+ Exclude:
53
+ - "db/migrate/**/*"
54
+ - "spec/**/*"
@@ -0,0 +1,17 @@
1
+ require 'capistrano/setup'
2
+ require 'capistrano/deploy'
3
+ require 'capistrano/scm/git'
4
+ require 'capistrano/rvm'
5
+ require 'capistrano/rails'
6
+ require 'capistrano/bundler'
7
+ require 'capistrano/rails/migrations'
8
+ require 'capistrano/rails/assets'
9
+ require 'capistrano/puma'
10
+ require 'capistrano/rails/console'
11
+ require 'airbrussh/capistrano'
12
+ require 'capistrano/dcs'
13
+
14
+ install_plugin Capistrano::SCM::Git
15
+ install_plugin Capistrano::Puma
16
+
17
+ Dir.glob('lib/capistrano/tasks/*.cap').each { |r| import r }
@@ -0,0 +1,18 @@
1
+ title: 'application_title'
2
+ project: 'project_name'
3
+
4
+ protocol: 'http_protocl'
5
+ host: 'host_and_port_to_run'
6
+ redis_url: 'host_redis'
7
+ stage: "development"
8
+
9
+ db_user: 'database_user'
10
+ db_password: 'database_password'
11
+ db_host: 'database_host'
12
+ db_threads: '5'
13
+
14
+ secret_development: 'rake secret'
15
+ secret_testing: 'rake secret'
16
+ secret_production: 'rake secret'
17
+ newrelic_key: 'newrelic_licence_key'
18
+ rollbar_key: 'rollbar_ticket'
@@ -0,0 +1,24 @@
1
+ default: &default
2
+ adapter: postgresql
3
+ encoding: unicode
4
+ pool: <%= Figaro.env.db_threads %>
5
+ username: <%= Figaro.env.db_user %>
6
+ password: <%= Figaro.env.db_password %>
7
+
8
+ development:
9
+ <<: *default
10
+ database: <%= Figaro.env.project %>
11
+ pool: 10
12
+
13
+ staging:
14
+ <<: *default
15
+ database: <%= Figaro.env.db_user %>
16
+ host: <%= Figaro.env.db_host %>
17
+
18
+ production:
19
+ <<: *default
20
+ database: <%= Figaro.env.db_user %>
21
+ host: <%= Figaro.env.db_host %>
22
+
23
+ test:
24
+ <<: *default
@@ -0,0 +1,20 @@
1
+ set :user, 'your_ssh_user'
2
+ set :login, 'your_locum_login'
3
+ set :rvm_ruby_version, 'your_ruby_version'
4
+ set :repo_url, 'git_path_to_your_application'
5
+
6
+ #after 'unicorn:restart', 'sidekiq:restart'
7
+
8
+
9
+ set :user, 'your_ssh_user'
10
+ set :rvm_ruby_version, 'your_ruby_version'
11
+ set :repo_url, 'git_path_to_your_application'
12
+ set :stages, %w[staging production]
13
+
14
+ set :rollbar_token, 'your_rollbar_token'
15
+ set :rollbar_env, (proc { fetch :stage })
16
+ set :rollbar_role, (proc { :app })
17
+
18
+ # set :linked_dirs, fetch(:linked_dirs, []) + %w(public/static)
19
+
20
+ after 'puma:restart', 'sidekiq:restart'
@@ -0,0 +1,9 @@
1
+ set :application, 'your_application_name'
2
+ set :stage, :production
3
+ set :rails_env, :production
4
+ set :ssh_options, forward_agent: true
5
+
6
+ server 'production-host.domain',
7
+ roles: %w(web app db),
8
+ primary: true,
9
+ user: fetch(:user)
@@ -0,0 +1,12 @@
1
+ set :application, 'your_application_name'
2
+ set :stage, :staging
3
+ set :rails_env, :staging
4
+ set :keep_releases, 3
5
+ set :env, worker_count: 4
6
+ set :ssh_options, forward_agent: true
7
+
8
+ server 'staging-host.domain',
9
+ roles: %w(web app db),
10
+ primary: true,
11
+ user: fetch(:user)
12
+
@@ -0,0 +1,2 @@
1
+ Figaro.require_keys('title', 'project', 'host', 'db_user', 'db_password', 'db_host',
2
+ 'secret_development', 'secret_testing', 'secret_production')
@@ -0,0 +1,21 @@
1
+ common: &default_settings
2
+ license_key: <%= Figaro.env.newrelic_key %>
3
+ app_name: Geotech Company
4
+ log_level: info
5
+
6
+ development:
7
+ <<: *default_settings
8
+ app_name: Geotech Company (Development)
9
+ developer_mode: true
10
+ monitor_mode: false
11
+
12
+ test:
13
+ <<: *default_settings
14
+ monitor_mode: false
15
+
16
+ staging:
17
+ <<: *default_settings
18
+ app_name: Geotech Company (Staging)
19
+
20
+ production:
21
+ <<: *default_settings
@@ -0,0 +1,38 @@
1
+ # Puma can serve each request in a thread from an internal thread pool.
2
+ # The `threads` method setting takes two numbers: a minimum and maximum.
3
+ # Any libraries that use thread pools should be configured to match
4
+ # the maximum value specified for Puma. Default is set to 5 threads for minimum
5
+ # and maximum; this matches the default thread size of Active Record.
6
+ #
7
+ threads_count = ENV.fetch('RAILS_MAX_THREADS') { 5 }
8
+ threads threads_count, threads_count
9
+
10
+ # Specifies the `port` that Puma will listen on to receive requests; default is 3000.
11
+ #
12
+
13
+ port ENV.fetch('PORT') { 3000 }
14
+
15
+ # Specifies the `environment` that Puma will run in.
16
+ #
17
+ environment ENV.fetch('RAILS_ENV') { 'development' }
18
+
19
+ # Specifies the number of `workers` to boot in clustered mode.
20
+ # Workers are forked webserver processes. If using threads and workers together
21
+ # the concurrency of the application would be max `threads` * `workers`.
22
+ # Workers do not work on JRuby or Windows (both of which do not support
23
+ # processes).
24
+ #
25
+ # workers ENV.fetch('WEB_CONCURRENCY') { 2 }
26
+
27
+ # Use the `preload_app!` method when specifying a `workers` number.
28
+ # This directive tells Puma to first boot the application and load code
29
+ # before forking the application. This takes advantage of Copy On Write
30
+ # process behavior so workers use less memory.
31
+ #
32
+ preload_app!
33
+
34
+ # Allow puma to be restarted by `rails restart` command.
35
+ plugin :tmp_restart
36
+
37
+ on_worker_boot { ActiveRecord::Base.establish_connection }
38
+
@@ -0,0 +1,11 @@
1
+ development:
2
+ secret_key_base: <%= Figaro.env.secret_development %>
3
+
4
+ test:
5
+ secret_key_base: <%= Figaro.env.secret_test %>
6
+
7
+ staging:
8
+ secret_key_base: <%= Figaro.env.secret_production %>
9
+
10
+ production:
11
+ secret_key_base: <%= Figaro.env.secret_production %>
metadata ADDED
@@ -0,0 +1,380 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: dcs-best-practices
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - DarkWater
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2019-12-02 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: 1.17.3
20
+ - - "~>"
21
+ - !ruby/object:Gem::Version
22
+ version: 1.17.3
23
+ type: :development
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ version: 1.17.3
30
+ - - "~>"
31
+ - !ruby/object:Gem::Version
32
+ version: 1.17.3
33
+ - !ruby/object:Gem::Dependency
34
+ name: rake
35
+ requirement: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - ">="
38
+ - !ruby/object:Gem::Version
39
+ version: 12.0.0
40
+ - - "~>"
41
+ - !ruby/object:Gem::Version
42
+ version: '12.0'
43
+ type: :development
44
+ prerelease: false
45
+ version_requirements: !ruby/object:Gem::Requirement
46
+ requirements:
47
+ - - ">="
48
+ - !ruby/object:Gem::Version
49
+ version: 12.0.0
50
+ - - "~>"
51
+ - !ruby/object:Gem::Version
52
+ version: '12.0'
53
+ - !ruby/object:Gem::Dependency
54
+ name: redcarpet
55
+ requirement: !ruby/object:Gem::Requirement
56
+ requirements:
57
+ - - "~>"
58
+ - !ruby/object:Gem::Version
59
+ version: '3.4'
60
+ - - ">="
61
+ - !ruby/object:Gem::Version
62
+ version: 3.5.0
63
+ type: :development
64
+ prerelease: false
65
+ version_requirements: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - "~>"
68
+ - !ruby/object:Gem::Version
69
+ version: '3.4'
70
+ - - ">="
71
+ - !ruby/object:Gem::Version
72
+ version: 3.5.0
73
+ - !ruby/object:Gem::Dependency
74
+ name: yard
75
+ requirement: !ruby/object:Gem::Requirement
76
+ requirements:
77
+ - - "~>"
78
+ - !ruby/object:Gem::Version
79
+ version: '0.7'
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: 0.7.5
83
+ type: :development
84
+ prerelease: false
85
+ version_requirements: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '0.7'
90
+ - - ">="
91
+ - !ruby/object:Gem::Version
92
+ version: 0.7.5
93
+ - !ruby/object:Gem::Dependency
94
+ name: airbrussh
95
+ requirement: !ruby/object:Gem::Requirement
96
+ requirements:
97
+ - - ">="
98
+ - !ruby/object:Gem::Version
99
+ version: 1.3.0
100
+ - - "~>"
101
+ - !ruby/object:Gem::Version
102
+ version: '1.3'
103
+ type: :runtime
104
+ prerelease: false
105
+ version_requirements: !ruby/object:Gem::Requirement
106
+ requirements:
107
+ - - ">="
108
+ - !ruby/object:Gem::Version
109
+ version: 1.3.0
110
+ - - "~>"
111
+ - !ruby/object:Gem::Version
112
+ version: '1.3'
113
+ - !ruby/object:Gem::Dependency
114
+ name: capistrano
115
+ requirement: !ruby/object:Gem::Requirement
116
+ requirements:
117
+ - - ">="
118
+ - !ruby/object:Gem::Version
119
+ version: 3.10.0
120
+ - - "~>"
121
+ - !ruby/object:Gem::Version
122
+ version: '3.10'
123
+ type: :runtime
124
+ prerelease: false
125
+ version_requirements: !ruby/object:Gem::Requirement
126
+ requirements:
127
+ - - ">="
128
+ - !ruby/object:Gem::Version
129
+ version: 3.10.0
130
+ - - "~>"
131
+ - !ruby/object:Gem::Version
132
+ version: '3.10'
133
+ - !ruby/object:Gem::Dependency
134
+ name: capistrano-rails
135
+ requirement: !ruby/object:Gem::Requirement
136
+ requirements:
137
+ - - ">="
138
+ - !ruby/object:Gem::Version
139
+ version: 1.4.0
140
+ - - "~>"
141
+ - !ruby/object:Gem::Version
142
+ version: '1.4'
143
+ type: :runtime
144
+ prerelease: false
145
+ version_requirements: !ruby/object:Gem::Requirement
146
+ requirements:
147
+ - - ">="
148
+ - !ruby/object:Gem::Version
149
+ version: 1.4.0
150
+ - - "~>"
151
+ - !ruby/object:Gem::Version
152
+ version: '1.4'
153
+ - !ruby/object:Gem::Dependency
154
+ name: capistrano-rails-console
155
+ requirement: !ruby/object:Gem::Requirement
156
+ requirements:
157
+ - - ">="
158
+ - !ruby/object:Gem::Version
159
+ version: 2.3.0
160
+ - - "~>"
161
+ - !ruby/object:Gem::Version
162
+ version: '2.3'
163
+ type: :runtime
164
+ prerelease: false
165
+ version_requirements: !ruby/object:Gem::Requirement
166
+ requirements:
167
+ - - ">="
168
+ - !ruby/object:Gem::Version
169
+ version: 2.3.0
170
+ - - "~>"
171
+ - !ruby/object:Gem::Version
172
+ version: '2.3'
173
+ - !ruby/object:Gem::Dependency
174
+ name: capistrano-rvm
175
+ requirement: !ruby/object:Gem::Requirement
176
+ requirements:
177
+ - - ">="
178
+ - !ruby/object:Gem::Version
179
+ version: 0.1.0
180
+ - - "~>"
181
+ - !ruby/object:Gem::Version
182
+ version: '0.1'
183
+ type: :runtime
184
+ prerelease: false
185
+ version_requirements: !ruby/object:Gem::Requirement
186
+ requirements:
187
+ - - ">="
188
+ - !ruby/object:Gem::Version
189
+ version: 0.1.0
190
+ - - "~>"
191
+ - !ruby/object:Gem::Version
192
+ version: '0.1'
193
+ - !ruby/object:Gem::Dependency
194
+ name: capistrano3-puma
195
+ requirement: !ruby/object:Gem::Requirement
196
+ requirements:
197
+ - - ">="
198
+ - !ruby/object:Gem::Version
199
+ version: 4.0.0
200
+ - - "~>"
201
+ - !ruby/object:Gem::Version
202
+ version: '4.0'
203
+ type: :runtime
204
+ prerelease: false
205
+ version_requirements: !ruby/object:Gem::Requirement
206
+ requirements:
207
+ - - ">="
208
+ - !ruby/object:Gem::Version
209
+ version: 4.0.0
210
+ - - "~>"
211
+ - !ruby/object:Gem::Version
212
+ version: '4.0'
213
+ - !ruby/object:Gem::Dependency
214
+ name: figaro
215
+ requirement: !ruby/object:Gem::Requirement
216
+ requirements:
217
+ - - "~>"
218
+ - !ruby/object:Gem::Version
219
+ version: '1.1'
220
+ - - ">="
221
+ - !ruby/object:Gem::Version
222
+ version: 1.1.1
223
+ type: :runtime
224
+ prerelease: false
225
+ version_requirements: !ruby/object:Gem::Requirement
226
+ requirements:
227
+ - - "~>"
228
+ - !ruby/object:Gem::Version
229
+ version: '1.1'
230
+ - - ">="
231
+ - !ruby/object:Gem::Version
232
+ version: 1.1.1
233
+ - !ruby/object:Gem::Dependency
234
+ name: puma
235
+ requirement: !ruby/object:Gem::Requirement
236
+ requirements:
237
+ - - ">="
238
+ - !ruby/object:Gem::Version
239
+ version: 4.1.0
240
+ - - "~>"
241
+ - !ruby/object:Gem::Version
242
+ version: '4.1'
243
+ type: :runtime
244
+ prerelease: false
245
+ version_requirements: !ruby/object:Gem::Requirement
246
+ requirements:
247
+ - - ">="
248
+ - !ruby/object:Gem::Version
249
+ version: 4.1.0
250
+ - - "~>"
251
+ - !ruby/object:Gem::Version
252
+ version: '4.1'
253
+ - !ruby/object:Gem::Dependency
254
+ name: rubocop
255
+ requirement: !ruby/object:Gem::Requirement
256
+ requirements:
257
+ - - ">="
258
+ - !ruby/object:Gem::Version
259
+ version: 0.7.0
260
+ - - "~>"
261
+ - !ruby/object:Gem::Version
262
+ version: '0.7'
263
+ type: :development
264
+ prerelease: false
265
+ version_requirements: !ruby/object:Gem::Requirement
266
+ requirements:
267
+ - - ">="
268
+ - !ruby/object:Gem::Version
269
+ version: 0.7.0
270
+ - - "~>"
271
+ - !ruby/object:Gem::Version
272
+ version: '0.7'
273
+ - !ruby/object:Gem::Dependency
274
+ name: rubocop-performance
275
+ requirement: !ruby/object:Gem::Requirement
276
+ requirements:
277
+ - - ">="
278
+ - !ruby/object:Gem::Version
279
+ version: 1.5.0
280
+ - - "~>"
281
+ - !ruby/object:Gem::Version
282
+ version: '1.5'
283
+ type: :development
284
+ prerelease: false
285
+ version_requirements: !ruby/object:Gem::Requirement
286
+ requirements:
287
+ - - ">="
288
+ - !ruby/object:Gem::Version
289
+ version: 1.5.0
290
+ - - "~>"
291
+ - !ruby/object:Gem::Version
292
+ version: '1.5'
293
+ - !ruby/object:Gem::Dependency
294
+ name: solargraph
295
+ requirement: !ruby/object:Gem::Requirement
296
+ requirements:
297
+ - - ">="
298
+ - !ruby/object:Gem::Version
299
+ version: 0.35.0
300
+ - - "~>"
301
+ - !ruby/object:Gem::Version
302
+ version: '0.35'
303
+ type: :development
304
+ prerelease: false
305
+ version_requirements: !ruby/object:Gem::Requirement
306
+ requirements:
307
+ - - ">="
308
+ - !ruby/object:Gem::Version
309
+ version: 0.35.0
310
+ - - "~>"
311
+ - !ruby/object:Gem::Version
312
+ version: '0.35'
313
+ description: Contains deploy configuration
314
+ email:
315
+ - denis.arushanov@darkcreative.ru
316
+ executables: []
317
+ extensions: []
318
+ extra_rdoc_files: []
319
+ files:
320
+ - ".editorconfig"
321
+ - ".gitignore"
322
+ - ".rubocop.yml"
323
+ - ".ruby-gemset"
324
+ - ".ruby-version"
325
+ - CODE_OF_CONDUCT.md
326
+ - Gemfile
327
+ - README.md
328
+ - Rakefile
329
+ - bin/console
330
+ - bin/setup
331
+ - dcs-best-practices.gemspec
332
+ - lib/capistrano/dcs.rb
333
+ - lib/capistrano/dcs/assets.rb
334
+ - lib/capistrano/dcs/defaults.rb
335
+ - lib/capistrano/dcs/remote.rb
336
+ - lib/capistrano/dcs/sidekiq.rb
337
+ - lib/capistrano/dcs/ssh.rb
338
+ - lib/capistrano/tasks/assets.cap
339
+ - lib/capistrano/tasks/remote.cap
340
+ - lib/capistrano/tasks/sidekiq.cap
341
+ - lib/capistrano/tasks/ssh.cap
342
+ - lib/dcs-best-pratices.rb
343
+ - lib/dcs_best_practices/version.rb
344
+ - lib/generators/dcs/deploy_generator.rb
345
+ - lib/generators/dcs/templates/deploy/.editorconfig.tt
346
+ - lib/generators/dcs/templates/deploy/.rubocop.yml.tt
347
+ - lib/generators/dcs/templates/deploy/Capfile.tt
348
+ - lib/generators/dcs/templates/deploy/config/application.yml.tt
349
+ - lib/generators/dcs/templates/deploy/config/database.yml.tt
350
+ - lib/generators/dcs/templates/deploy/config/deploy.rb.tt
351
+ - lib/generators/dcs/templates/deploy/config/deploy/production.rb.tt
352
+ - lib/generators/dcs/templates/deploy/config/deploy/staging.rb.tt
353
+ - lib/generators/dcs/templates/deploy/config/initializers/figaro.rb.tt
354
+ - lib/generators/dcs/templates/deploy/config/newrelic.yml.tt
355
+ - lib/generators/dcs/templates/deploy/config/puma.rb.tt
356
+ - lib/generators/dcs/templates/deploy/config/secrets.yml.tt
357
+ homepage: https://bitbucket.org/DCStudio/best-prectices
358
+ licenses: []
359
+ metadata:
360
+ allowed_push_host: https://rubygems.org
361
+ post_install_message:
362
+ rdoc_options: []
363
+ require_paths:
364
+ - lib
365
+ required_ruby_version: !ruby/object:Gem::Requirement
366
+ requirements:
367
+ - - ">="
368
+ - !ruby/object:Gem::Version
369
+ version: '2.5'
370
+ required_rubygems_version: !ruby/object:Gem::Requirement
371
+ requirements:
372
+ - - ">="
373
+ - !ruby/object:Gem::Version
374
+ version: '0'
375
+ requirements: []
376
+ rubygems_version: 3.0.6
377
+ signing_key:
378
+ specification_version: 4
379
+ summary: Simple best practices, used for soft deployment with capistrano to some servers
380
+ test_files: []