capistrano-mb 0.23.1 → 0.24.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +7 -1
- data/README.md +120 -82
- data/lib/capistrano/mb/templates/nginx_unicorn.erb +1 -1
- data/lib/capistrano/mb/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 63f7e5e2b8eb0f126c2ac90f753353dd425eb801
|
4
|
+
data.tar.gz: 69627248b8d4db581a8b4d2b74c2cba08bae5b88
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f5c706979093b9ab26c91659362647d13cdeff63aa2674e5bad8b543dffe5b17f5762a52348cb621f5dbcdd8adb5518d160d5f8f980c6cb9053e7beabfed0660
|
7
|
+
data.tar.gz: 2e8d185754f3d922e7abf7810ab3221a4489c82ccda59e46f2001e086201c42d84a4f931c355caf43d27ea848b962e60264333c0e42135415c54291b86fe8fa3
|
data/CHANGELOG.md
CHANGED
@@ -2,6 +2,11 @@
|
|
2
2
|
|
3
3
|
* Your contribution here!
|
4
4
|
|
5
|
+
## [0.24.0][] (2015-09-11)
|
6
|
+
|
7
|
+
* Improve README with step-by-step installation instructions.
|
8
|
+
* Expand the list of cipher suites used in the nginx SSL configuration. ([#7](https://github.com/mattbrictson/capistrano-mb/pull/7))
|
9
|
+
|
5
10
|
## [0.23.1][] (2015-08-08)
|
6
11
|
|
7
12
|
* Ensure gzip is enable for all assets, not just fingerprinted ones.
|
@@ -137,7 +142,8 @@ Flush console output after each line is printed. This allows deployment progress
|
|
137
142
|
|
138
143
|
Initial Rubygems release!
|
139
144
|
|
140
|
-
[Unreleased]: https://github.com/mattbrictson/capistrano-mb/compare/v0.
|
145
|
+
[Unreleased]: https://github.com/mattbrictson/capistrano-mb/compare/v0.24.0...HEAD
|
146
|
+
[0.24.0]: https://github.com/mattbrictson/capistrano-mb/compare/v0.23.1...v0.24.0
|
141
147
|
[0.23.1]: https://github.com/mattbrictson/capistrano-mb/compare/v0.23.0...v0.23.1
|
142
148
|
[0.23.0]: https://github.com/mattbrictson/capistrano-mb/compare/v0.22.2...v0.23.0
|
143
149
|
[0.22.2]: https://github.com/mattbrictson/capistrano-mb/compare/v0.22.1...v0.22.2
|
data/README.md
CHANGED
@@ -19,7 +19,7 @@ The capistrano-mb gem adds a `cap <stage> provision` task to Capistrano that tak
|
|
19
19
|
|
20
20
|
The gem is named "capistrano-mb" because it is prescribes my ([@mattbrictson](https://github.com/mattbrictson)) personal preferences for automating deployments of Rails projects. I'm a freelance developer juggling lots of Rails codebases, so its important for me to have a good, consistent server configuration. You'll notice that capistrano-mb is opinionated and strictly uses the following stack:
|
21
21
|
|
22
|
-
* Ubuntu
|
22
|
+
* Ubuntu 14.04 LTS
|
23
23
|
* PostgreSQL
|
24
24
|
* Unicorn
|
25
25
|
* Nginx
|
@@ -31,124 +31,160 @@ In addition, capistrano-mb changes many of Capistrano's defaults, including the
|
|
31
31
|
Not quite to your liking? Consider forking the project to meet your needs.
|
32
32
|
|
33
33
|
|
34
|
-
##
|
34
|
+
## Quick start
|
35
35
|
|
36
|
-
Please note that this project requires **Capistrano 3.x**, which is a complete
|
37
|
-
rewrite of Capistrano 2.x. The two major versions are not compatible.
|
36
|
+
Please note that this project requires **Capistrano 3.x**, which is a complete rewrite of Capistrano 2.x. The two major versions are not compatible.
|
38
37
|
|
39
|
-
### 1.
|
38
|
+
### 1. Purchase an Ubuntu 14.04 VPS
|
40
39
|
|
41
|
-
|
40
|
+
To use capistrano-mb, you'll need a clean Ubuntu server to deploy to. The only special requirement is that your public SSH key must be installed on the server for the `root` user.
|
42
41
|
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
42
|
+
Test that you can SSH to the server as `root` without being prompted for a password. If that works, capistrano-mb can take care of the rest. You're ready to proceed!
|
43
|
+
|
44
|
+
### 2. .ruby-version
|
45
|
+
|
46
|
+
capistrano-mb needs to know the version of Ruby that your app requires, so that it can install Ruby during the provisioning process. Place a `.ruby-version` file in the root of your project containing the desired version, like this:
|
47
|
+
|
48
|
+
```
|
49
|
+
2.2.3
|
50
|
+
```
|
51
|
+
|
52
|
+
*If you are using `rbenv`, just run `rbenv local 2.2.3` and it will create this file for you.*
|
53
|
+
|
54
|
+
### 3. Gemfile
|
55
|
+
|
56
|
+
capistrano-mb makes certain assumptions about your Rails app, namely that it uses [dotenv][] to manage Rails secrets via environment variables, and that it runs on top of PostgreSQL and [unicorn][]. Make sure they are specified in the Gemfile:
|
57
|
+
|
58
|
+
```ruby
|
59
|
+
gem "dotenv-rails", ">= 2.0.0"
|
60
|
+
gem "pg", "~> 0.18"
|
61
|
+
gem "unicorn"
|
62
|
+
```
|
63
|
+
|
64
|
+
Then for the capistrano-mb tools themselves, add these gems to the development group:
|
65
|
+
|
66
|
+
```ruby
|
67
|
+
group :development do
|
68
|
+
gem "capistrano-bundler", :require => false
|
69
|
+
gem "capistrano-rails", :require => false
|
70
|
+
gem "capistrano", "~> 3.4.0", :require => false
|
71
|
+
gem "capistrano-mb", :require => false
|
72
|
+
end
|
73
|
+
```
|
49
74
|
|
50
75
|
And then execute:
|
51
76
|
|
52
|
-
|
77
|
+
```
|
78
|
+
$ bundle
|
79
|
+
```
|
53
80
|
|
81
|
+
### 4. cap install
|
54
82
|
|
55
|
-
|
83
|
+
If your project doesn't yet have a `Capfile`, run `cap install` with the list of desired stages (environments). For simplicity, this installation guide will assume a single production stage:
|
56
84
|
|
57
|
-
|
58
|
-
|
85
|
+
```
|
86
|
+
cap install STAGES=production
|
87
|
+
```
|
59
88
|
|
60
|
-
|
89
|
+
### 5. Capfile
|
61
90
|
|
91
|
+
Add these lines to the **bottom** of your app's `Capfile` (order is important!):
|
62
92
|
|
63
|
-
|
93
|
+
```ruby
|
94
|
+
require "capistrano/bundler"
|
95
|
+
require "capistrano/rails"
|
96
|
+
require "capistrano/mb"
|
97
|
+
```
|
64
98
|
|
65
|
-
|
66
|
-
(order is important!):
|
99
|
+
### 6. deploy.rb
|
67
100
|
|
68
|
-
|
69
|
-
require 'capistrano/rails'
|
70
|
-
require 'capistrano/mb'
|
101
|
+
Modify `config/deploy.rb` to set the specifics of your Rails app. At the minimum, you'll need to set these two options:
|
71
102
|
|
103
|
+
```ruby
|
104
|
+
set :application, "my_app_name"
|
105
|
+
set :repo_url, "git@github.com:username/repository.git"
|
106
|
+
```
|
72
107
|
|
73
|
-
###
|
108
|
+
### 7. production.rb
|
74
109
|
|
75
|
-
|
110
|
+
Modify `config/deploy/production.rb` to specify the IP address of your production server. In this example, I have a single 1GB VPS (e.g. at DigitalOcean) that plays all the roles:
|
76
111
|
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
112
|
+
```ruby
|
113
|
+
server "my.production.ip",
|
114
|
+
:user => "deployer",
|
115
|
+
:roles => %w(app backup cron db web)
|
116
|
+
```
|
81
117
|
|
82
|
-
|
118
|
+
*Note that you must include the `backup` and `cron` roles if you want to make use of capistrano-mb's database backups and crontab features.*
|
83
119
|
|
84
|
-
|
85
|
-
aptitude
|
86
|
-
crontab
|
87
|
-
dotenv
|
88
|
-
logrotate
|
89
|
-
migrate
|
90
|
-
nginx
|
91
|
-
postgresql
|
92
|
-
rbenv
|
93
|
-
seed
|
94
|
-
ssl
|
95
|
-
ufw
|
96
|
-
unicorn
|
97
|
-
user
|
98
|
-
version
|
99
|
-
)
|
100
|
-
|
101
|
-
Even if you don't include a recipe in the auto-run list, you can still invoke
|
102
|
-
the tasks of those recipes manually at your discretion.
|
103
|
-
|
104
|
-
|
105
|
-
### 5. Configuration
|
120
|
+
### 8. secrets.yml
|
106
121
|
|
107
|
-
|
108
|
-
`deploy.rb` file to specify these overrides. Or, you can override per stage.
|
109
|
-
Here is an example override:
|
122
|
+
By default, Rails 4.2 apps have a `config/secrets.yml` file that specifies the Rails secret key. capistrano-mb configures dotenv to provide this secret in a `RAILS_SECRET_KEY_BASE` environment variable. You'll therefore need to modify `secrets.yml` as follows:
|
110
123
|
|
111
|
-
|
124
|
+
```ruby
|
125
|
+
production:
|
126
|
+
secret_key_base: <%= ENV["RAILS_SECRET_KEY_BASE"] %>
|
127
|
+
```
|
112
128
|
|
113
|
-
|
114
|
-
[defaults.rake][].
|
129
|
+
### 9. Provision and deploy!
|
115
130
|
|
131
|
+
Run capistrano-mb's `provision:14_04` task (named for Ubuntu 14.04). This will ask you a few questions, install Ruby, PostgreSQL, Nginx, etc., and set everything up. The entire process takes about 10 minutes (mostly due to compiling Ruby from source).
|
116
132
|
|
117
|
-
|
133
|
+
```
|
134
|
+
bundle exec cap production provision:14_04
|
135
|
+
```
|
118
136
|
|
119
|
-
|
137
|
+
Once that's done, your app is now ready to deploy!
|
120
138
|
|
121
|
-
|
139
|
+
```
|
140
|
+
bundle exec cap production deploy
|
141
|
+
```
|
122
142
|
|
123
|
-
|
124
|
-
entire setup of a bare Ubuntu 12.04 or 14.04 server, all the way to a fully configured
|
125
|
-
and running Rails app on top up Unicorn, Nginx, rbenv, and PostgreSQL.
|
143
|
+
## Advanced usage
|
126
144
|
|
127
|
-
###
|
145
|
+
### Choosing which recipes to auto-run
|
128
146
|
|
129
|
-
|
130
|
-
|
147
|
+
Most of the capistrano-mb recipes are designed to run automatically as part of `cap <stage> provision`, for installing and setting up various bits of the Rails infrastructure, like nginx, unicorn, and postgres. Some recipes also contribute to the `cap <stage> deploy` process.
|
148
|
+
|
149
|
+
*This auto-run behavior is fully under your control.* In your `deploy.rb`, set `:mb_recipes` to an array of the desired recipes. If you don't want a recipe to execute as part of `deploy`/`provision`, simply omit it from the list.
|
131
150
|
|
132
|
-
|
133
|
-
2. Install your public SSH key for the root user. Some providers (e.g. DigitalOcean) can do this for you automatically when you provision a new VPS.
|
134
|
-
3. Repeat steps 1-2 for all the servers in your cluster, if you are using
|
135
|
-
a multi-server setup (e.g. separate web, app, and database servers).
|
136
|
-
4. Let capistrano-mb take it from here:
|
151
|
+
The following list will suffice for most out-of-the-box Rails apps. The order of the list is not important.
|
137
152
|
|
138
|
-
|
139
|
-
|
140
|
-
|
153
|
+
```ruby
|
154
|
+
set :mb_recipes, %w(
|
155
|
+
aptitude
|
156
|
+
crontab
|
157
|
+
dotenv
|
158
|
+
logrotate
|
159
|
+
migrate
|
160
|
+
nginx
|
161
|
+
postgresql
|
162
|
+
rbenv
|
163
|
+
seed
|
164
|
+
ssl
|
165
|
+
ufw
|
166
|
+
unicorn
|
167
|
+
user
|
168
|
+
version
|
169
|
+
)
|
170
|
+
```
|
171
|
+
|
172
|
+
Even if you don't include a recipe in the auto-run list, you can still invoke the tasks of those recipes manually at your discretion. Run `bundle exec cap -T` to see the full list of tasks.
|
173
|
+
|
174
|
+
### Configuration
|
141
175
|
|
142
|
-
|
176
|
+
Many of the recipes have default settings that can be overridden. Use your
|
177
|
+
`deploy.rb` file to specify these overrides. Or, you can override per stage.
|
178
|
+
Here is an example override:
|
179
|
+
|
180
|
+
set :mb_unicorn_workers, 8
|
143
181
|
|
144
|
-
For
|
182
|
+
For the full list of settings and their default values, refer to [defaults.rake][].
|
145
183
|
|
146
|
-
cap -T
|
147
184
|
|
148
|
-
|
149
|
-
can run these tasks just like any other capistrano task, like so:
|
185
|
+
## Further reading
|
150
186
|
|
151
|
-
|
187
|
+
Check out my [rails-template][] project, which generates Rails applications with capistrano-mb pre-configured and ready to go.
|
152
188
|
|
153
189
|
|
154
190
|
## History
|
@@ -170,4 +206,6 @@ If you are upgrading from `capistrano-fiftyfive`, refer to the [CHANGELOG entry
|
|
170
206
|
[cast337]:http://railscasts.com/episodes/337-capistrano-recipes
|
171
207
|
[cast373]:http://railscasts.com/episodes/373-zero-downtime-deployment
|
172
208
|
[defaults.rake]:lib/capistrano/tasks/defaults.rake
|
173
|
-
[rails-
|
209
|
+
[rails-template]:https://github.com/mattbrictson/rails-template/
|
210
|
+
[dotenv]:https://github.com/bkeepers/dotenv
|
211
|
+
[unicorn]:http://unicorn.bogomips.org/
|
@@ -47,7 +47,7 @@ upstream unicorn_<%= application_basename %> {
|
|
47
47
|
|
48
48
|
<% if port == 443 %>
|
49
49
|
ssl on;
|
50
|
-
ssl_ciphers
|
50
|
+
ssl_ciphers 'ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:DHE-DSS-AES128-GCM-SHA256:kEDH+AESGCM:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA:ECDHE-ECDSA-AES256-SHA:DHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA:DHE-DSS-AES128-SHA256:DHE-RSA-AES256-SHA256:DHE-DSS-AES256-SHA:DHE-RSA-AES256-SHA:AES128-GCM-SHA256:AES256-GCM-SHA384:AES128-SHA256:AES256-SHA256:AES128-SHA:AES256-SHA:AES:CAMELLIA:DES-CBC3-SHA:!aNULL:!eNULL:!EXPORT:!DES:!RC4:!MD5:!PSK:!aECDH:!EDH-DSS-DES-CBC3-SHA:!EDH-RSA-DES-CBC3-SHA:!KRB5-DES-CBC3-SHA';
|
51
51
|
ssl_prefer_server_ciphers on;
|
52
52
|
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
|
53
53
|
ssl_dhparam /etc/ssl/dhparams.pem;
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: capistrano-mb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.24.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matt Brictson
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-09-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: capistrano
|