This repository has been archived by the owner on Nov 10, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 24
/
defaults.rake
135 lines (120 loc) · 3.94 KB
/
defaults.rake
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
namespace :load do
task :defaults do
set :mb_recipes, %w(
aptitude
bundler
crontab
dotenv
logrotate
migrate
nginx
postgresql
rbenv
seed
ssl
ufw
unicorn
user
version
)
set :mb_privileged_user, "root"
set :mb_aptitude_packages,
"build-essential" => :all,
"curl" => :all,
"debian-goodies" => :all,
"git-core" => :all,
"libpq-dev" => :all,
"libreadline-gplv2-dev" => :all,
"libssl-dev" => :all,
"libxml2" => :all,
"libxml2-dev" => :all,
"libxslt1-dev" => :all,
"nginx@ppa:nginx/stable" => :web,
"nodejs" => :all,
"ntp" => :all,
"postgresql" => :db,
"postgresql-client" => :all,
"tklib" => :all,
"ufw" => :all,
"zlib1g-dev" => :all
set :mb_bundler_lockfile, "Gemfile.lock"
set :mb_bundler_gem_install_command,
"gem install bundler --conservative --no-document"
set :mb_dotenv_keys, %w(rails_secret_key_base postmark_api_key)
set :mb_dotenv_filename, -> { ".env.#{fetch(:rails_env)}" }
set :mb_log_file, "log/capistrano.log"
set :mb_nginx_force_https, false
set :mb_nginx_redirect_hosts, {}
ask :mb_postgresql_password, nil, :echo => false
set :mb_postgresql_pool_size, 5
set :mb_postgresql_host, "localhost"
set :mb_postgresql_database,
-> { "#{application_basename}_#{fetch(:rails_env)}" }
set :mb_postgresql_user, -> { application_basename }
set :mb_postgresql_pgpass_path,
proc{ "#{shared_path}/config/pgpass" }
set :mb_postgresql_backup_path, -> {
"#{shared_path}/backups/postgresql-dump.dmp"
}
set :mb_postgresql_backup_exclude_tables, []
set :mb_postgresql_dump_options, -> {
options = fetch(:mb_postgresql_backup_exclude_tables).map do |t|
"-T #{t.shellescape}"
end
options.join(" ")
}
set :mb_rbenv_ruby_version, -> { IO.read(".ruby-version").strip }
set :mb_rbenv_vars, -> {
{
"RAILS_ENV" => fetch(:rails_env),
"PGPASSFILE" => fetch(:mb_postgresql_pgpass_path)
}
}
set :mb_sidekiq_concurrency, 25
set :mb_sidekiq_role, :sidekiq
ask :mb_ssl_csr_country, "US"
ask :mb_ssl_csr_state, "California"
ask :mb_ssl_csr_city, "San Francisco"
ask :mb_ssl_csr_org, "Example Company"
ask :mb_ssl_csr_name, "www.example.com"
# WARNING: misconfiguring firewall rules could lock you out of the server!
set :mb_ufw_rules,
"allow ssh" => :all,
"allow http" => :web,
"allow https" => :web
set :mb_unicorn_workers, 2
set :mb_unicorn_timeout, 30
set :mb_unicorn_config, proc{ "#{current_path}/config/unicorn.rb" }
set :mb_unicorn_log, proc{ "#{current_path}/log/unicorn.log" }
set :mb_unicorn_pid, proc{ "#{current_path}/tmp/pids/unicorn.pid" }
set :bundle_binstubs, false
set :bundle_flags, "--deployment --retry=3 --quiet"
set :bundle_path, -> { shared_path.join("bundle") }
set :deploy_to, -> { "/home/deployer/apps/#{fetch(:application)}" }
set :keep_releases, 10
set :linked_dirs, -> {
["public/#{fetch(:assets_prefix, 'assets')}"] +
%w(
.bundle
log
tmp/pids
tmp/cache
tmp/sockets
public/.well-known
public/system
)
}
set :linked_files, -> {
[fetch(:mb_dotenv_filename)] +
%w(
config/database.yml
config/unicorn.rb
)
}
set :log_level, :debug
set :migration_role, :app
set :rails_env, -> { fetch(:stage) }
set :ssh_options, :compression => true, :keepalive => true
SSHKit.config.command_map[:rake] = "bundle exec rake"
end
end