capistrano-buildpack 0.0.7 → 0.0.8
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +7 -2
- data/lib/capistrano-buildpack/tasks.rb +26 -9
- data/lib/capistrano-buildpack/version.rb +1 -1
- metadata +2 -2
data/README.md
CHANGED
@@ -64,6 +64,13 @@ Deploy will do the following things:
|
|
64
64
|
The nginx config will list at least one domain for the app: `<application>.<hostname>`, which in this case is `bugsplatdotinfo.examplevps.bugsplat.info`. Anything
|
65
65
|
you add to the `:additional_domains` setting gets tacked on at the end.
|
66
66
|
|
67
|
+
Several other settings are available for controlling SSL:
|
68
|
+
|
69
|
+
* `use_ssl`: true to listen on port 443
|
70
|
+
* `ssl_cert_path`: a path to a certificate file on the server. You are responsible for getting the certificate there.
|
71
|
+
* `ssl_key_path`: a path to a key file on the server. You are responsible for getting it there.
|
72
|
+
* `force_ssl`: Force a redirect to SSL. This will unconditionally redirect to the first domain in `additional_domains`, so if you have multiple you may want to do this in your app instead.
|
73
|
+
|
67
74
|
## Running remote commands
|
68
75
|
|
69
76
|
Sometimes you want to run a command on the other end that isn't defined in a Procfile. Do that with `cap remote`:
|
@@ -75,8 +82,6 @@ Sometimes you want to run a command on the other end that isn't defined in a Pro
|
|
75
82
|
`Capistrano::Buildpack` will *not* run `bin/release` from the buildpack, so any environment variables that that attempts to set need to be set using `read_env`.
|
76
83
|
In addition, at the moment the exported nginx config does not have compression turned on.
|
77
84
|
|
78
|
-
Also, note that right now this does not support HTTPS. I'm working on it.
|
79
|
-
|
80
85
|
## Contributing
|
81
86
|
|
82
87
|
1. Fork it
|
@@ -1,8 +1,24 @@
|
|
1
1
|
require 'digest/sha1'
|
2
2
|
|
3
|
+
def _cset(name, *args, &block)
|
4
|
+
unless exists?(name)
|
5
|
+
set(name, *args, &block)
|
6
|
+
end
|
7
|
+
end
|
8
|
+
|
3
9
|
if Capistrano::Configuration.instance
|
4
10
|
Capistrano::Configuration.instance.load do
|
5
11
|
|
12
|
+
_cset(:deploy_to) { "/apps/#{application}" }
|
13
|
+
_cset(:buildpack_url) { abort "Please specify the buildpack URL to use, set :buildpack_url, 'http://example.com/buildpack'" }
|
14
|
+
_cset(:base_port) { abort "Please specify a base port to use, set :base_port, 6500" }
|
15
|
+
_cset(:concurrency) { abort "Please specify a concurrency level to use, set :concurrency, 'web-1'" }
|
16
|
+
|
17
|
+
_cset :foreman_export_path, "/etc/init"
|
18
|
+
_cset :foreman_export_type, "upstart"
|
19
|
+
_cset :nginx_export_path, "/etc/nginx/conf.d"
|
20
|
+
_cset :additional_domains, []
|
21
|
+
|
6
22
|
def read_env(name)
|
7
23
|
env = {}
|
8
24
|
filename = ".env.#{name}"
|
@@ -21,20 +37,15 @@ if Capistrano::Configuration.instance
|
|
21
37
|
namespace :buildpack do
|
22
38
|
|
23
39
|
task :setup_env do
|
24
|
-
set :deploy_to, "/apps/#{application}"
|
25
|
-
set :foreman_export_path, "/etc/init"
|
26
|
-
set :foreman_export_type, "upstart"
|
27
|
-
set :nginx_export_path, "/etc/nginx/conf.d"
|
28
40
|
|
29
|
-
set
|
30
|
-
set
|
41
|
+
set(:buildpack_hash) { Digest::SHA1.hexdigest(buildpack_url) }
|
42
|
+
set(:buildpack_path) { "#{shared_path}/buildpack-#{buildpack_hash}" }
|
31
43
|
|
32
44
|
default_run_options[:pty] = true
|
33
45
|
default_run_options[:shell] = '/bin/bash'
|
34
46
|
end
|
35
47
|
|
36
48
|
task :setup do
|
37
|
-
setup_env
|
38
49
|
|
39
50
|
sudo "mkdir -p #{deploy_to}"
|
40
51
|
sudo "chown -R #{user} #{deploy_to}"
|
@@ -62,15 +73,21 @@ if Capistrano::Configuration.instance
|
|
62
73
|
end
|
63
74
|
|
64
75
|
task "foreman_export" do
|
76
|
+
_use_ssl = exists?(:use_ssl) ? "USE_SSL=on" : ''
|
77
|
+
_ssl_cert_path = exists?(:ssl_cert_path) ? "SSL_CERT_PATH=#{ssl_cert_path}" : ''
|
78
|
+
_ssl_key_path = exists?(:ssl_key_path) ? "SSL_KEY_PATH=#{ssl_key_path}" : ''
|
79
|
+
_force_ssl = exists?(:force_ssl) ? "FORCE_SSL=#{force_ssl}" : ''
|
80
|
+
|
65
81
|
sudo "foreman export #{foreman_export_type} #{foreman_export_path} -d #{release_path} -l /var/log/#{application} -a #{application} -u #{user} -p #{base_port} -c #{concurrency}"
|
66
|
-
sudo "env ADDITIONAL_DOMAINS=#{additional_domains.join(',')} BASE_DOMAIN=$CAPISTRANO:HOST$ nginx-foreman export nginx #{nginx_export_path} -d #{release_path} -l /var/log/apps -a #{application} -u #{user} -p #{base_port} -c #{concurrency}"
|
82
|
+
sudo "env #{_use_ssl} #{_ssl_cert_path} #{_ssl_key_path} #{_force_ssl} ADDITIONAL_DOMAINS=#{additional_domains.join(',')} BASE_DOMAIN=$CAPISTRANO:HOST$ nginx-foreman export nginx #{nginx_export_path} -d #{release_path} -l /var/log/apps -a #{application} -u #{user} -p #{base_port} -c #{concurrency}"
|
67
83
|
sudo "service #{application} restart || service #{application} start"
|
68
84
|
sudo "service nginx reload || service nginx start"
|
69
85
|
end
|
70
86
|
|
71
87
|
end
|
72
88
|
|
73
|
-
|
89
|
+
before "deploy", "buildpack:setup_env"
|
90
|
+
before "deploy:setup", "buildpack:setup_env"
|
74
91
|
before "deploy:setup", "buildpack:setup"
|
75
92
|
after "deploy:setup", "buildpack:install_foreman_export_nginx"
|
76
93
|
before "deploy", "buildpack:setup"
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: capistrano-buildpack
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.8
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-01-
|
12
|
+
date: 2013-01-11 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
14
|
description: Deploy 12-factor applications using Capistrano
|
15
15
|
email:
|