capistrano-buildpack 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in capistrano-buildpack.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2012 Pete Keen
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,75 @@
1
+ # Capistrano::Buildpack
2
+
3
+ Deploy [12-factor](http://www.12factor.net/) applications using Capistrano.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'capistrano-buildpack'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install capistrano-buildpack
18
+
19
+ ## Usage
20
+
21
+ Here's a basic Capfile that uses `Capistrano::Buildpack`:
22
+
23
+ require 'rubygems'
24
+
25
+ set :application, "bugsplatdotinfo"
26
+ set :repository, "https://github.com/peterkeen/bugsplat.rb"
27
+ set :scm, :git
28
+ set :additional_domains, ['bugsplat.info']
29
+
30
+ role :web, "examplevps.bugsplat.info"
31
+ set :buildpack_url, "https://github.com/peterkeen/bugsplat-buildpack-ruby-simple"
32
+
33
+ set :user, "peter"
34
+ set :base_port, 6700
35
+ set :concurrency, "web=1"
36
+
37
+ set :deploy_env, {
38
+ 'LANG' => 'en_US.UTF-8',
39
+ 'PATH' => 'bin:vendor/bundle/ruby/1.9.1/bin:/usr/local/bin:/usr/bin:/bin',
40
+ 'GEM_PATH' => 'vendor/bundle/ruby/1.9.1:.',
41
+ 'RACK_ENV' => 'production',
42
+ }
43
+
44
+ load 'deploy'
45
+ require 'capistrano-buildpack'
46
+
47
+ To run a deploy:
48
+
49
+ $ cap deploy:setup # create the required directory structure and gem install foreman-export-nginx
50
+ $ cap deploy # actually run a deploy
51
+
52
+ Deploy will do the following things:
53
+
54
+ * Create the required directory structure at `/apps/<application>`
55
+ * Clone/update the buildpack
56
+ * Clone/update the code repository
57
+ * Apply the buildpack to the code repository
58
+ * Create `upstart`-style init files in `/etc/init` and start up the app
59
+ * Create an nginx config file at `/etc/nginx/conf.d/<application>.conf and restart nginx
60
+
61
+ The nginx config will list at least one domain for the app: `<application>.<hostname>`, which in this case is `bugsplatdotinfo.examplevps.bugsplat.info`. Anything
62
+ you add to the `:additional_domains` setting gets tacked on at the end.
63
+
64
+ ## Very Important Note
65
+
66
+ `Capistrano::Buildpack` will *not* run `bin/release` from the buildpack, so any environment variables that that attempts to set need to be set in `:deploy_env`.
67
+ addition, at the moment the exported nginx config does not have compression turned o
68
+
69
+ ## Contributing
70
+
71
+ 1. Fork it
72
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
73
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
74
+ 4. Push to the branch (`git push origin my-new-feature`)
75
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,19 @@
1
+ # -*- encoding: utf-8 -*-
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'capistrano-buildpack/version'
5
+
6
+ Gem::Specification.new do |gem|
7
+ gem.name = "capistrano-buildpack"
8
+ gem.version = Capistrano::Buildpack::VERSION
9
+ gem.authors = ["Pete Keen"]
10
+ gem.email = ["pete@bugsplat.info"]
11
+ gem.description = %q{Deploy 12-factor applications using Capistrano}
12
+ gem.summary = %q{Deploy 12-factor applications using Capistrano}
13
+ gem.homepage = "https://github.com/peterkeen/capistrano-buildpack"
14
+
15
+ gem.files = `git ls-files`.split($/)
16
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
17
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
18
+ gem.require_paths = ["lib"]
19
+ end
@@ -0,0 +1,47 @@
1
+ require 'digest/sha1'
2
+
3
+ Capistrano::Configuration.instance.load do
4
+ after "deploy:setup" do
5
+ sudo "chown -R #{user} #{deploy_to}"
6
+ sudo "gem install --upgrade foreman-export-nginx"
7
+ end
8
+
9
+ before "deploy" do
10
+ default_run_options[:pty] = true
11
+ default_run_options[:shell] = '/bin/bash'
12
+
13
+ set :deploy_to, "/apps/#{application}"
14
+ set :foreman_export_path, "/etc/init"
15
+ set :foreman_export_type, "upstart"
16
+ set :nginx_export_path, "/etc/nginx/conf.d"
17
+
18
+ set :buildpack_hash, Digest::SHA1.hexdigest(buildpack_url)
19
+ set :buildpack_path, "#{shared_path}/buildpack-#{buildpack_hash}"
20
+
21
+ run("[[ ! -e #{buildpack_path} ]] && git clone #{buildpack_url} #{buildpack_path}; exit 0")
22
+ run("cd #{buildpack_path} && git fetch origin && git reset --hard origin/master")
23
+ run("mkdir -p #{shared_path}/build_cache")
24
+ end
25
+
26
+ before "deploy:finalize_update" do
27
+ run("cd #{buildpack_path} && RACK_ENV=production bin/compile #{release_path} #{shared_path}/build_cache")
28
+
29
+ env_lines = []
30
+ deploy_env.each do |k,v|
31
+ env_lines << "#{k}=#{v}"
32
+ end
33
+ env_contents = env_lines.join("\n") + "\n"
34
+
35
+ put(env_contents, "#{release_path}/.env")
36
+ end
37
+
38
+ namespace :deploy do
39
+ task :restart do
40
+ 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}"
41
+ 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}"
42
+ sudo "service #{application} restart || service #{application} start"
43
+ sudo "service nginx reload || service nginx start"
44
+ end
45
+ end
46
+
47
+ end
@@ -0,0 +1,5 @@
1
+ module Capistrano
2
+ module Buildpack
3
+ VERSION = "0.0.1"
4
+ end
5
+ end
@@ -0,0 +1,9 @@
1
+
2
+ module Capistrano
3
+ module Buildpack
4
+
5
+ end
6
+ end
7
+
8
+ require "capistrano-buildpack/version"
9
+ require "capistrano-buildpack/tasks"
metadata ADDED
@@ -0,0 +1,74 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: capistrano-buildpack
3
+ version: !ruby/object:Gem::Version
4
+ hash: 29
5
+ prerelease:
6
+ segments:
7
+ - 0
8
+ - 0
9
+ - 1
10
+ version: 0.0.1
11
+ platform: ruby
12
+ authors:
13
+ - Pete Keen
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2012-12-30 00:00:00 Z
19
+ dependencies: []
20
+
21
+ description: Deploy 12-factor applications using Capistrano
22
+ email:
23
+ - pete@bugsplat.info
24
+ executables: []
25
+
26
+ extensions: []
27
+
28
+ extra_rdoc_files: []
29
+
30
+ files:
31
+ - .gitignore
32
+ - Gemfile
33
+ - LICENSE.txt
34
+ - README.md
35
+ - Rakefile
36
+ - capistrano-buildpack.gemspec
37
+ - lib/capistrano-buildpack.rb
38
+ - lib/capistrano-buildpack/tasks.rb
39
+ - lib/capistrano-buildpack/version.rb
40
+ homepage: https://github.com/peterkeen/capistrano-buildpack
41
+ licenses: []
42
+
43
+ post_install_message:
44
+ rdoc_options: []
45
+
46
+ require_paths:
47
+ - lib
48
+ required_ruby_version: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ">="
52
+ - !ruby/object:Gem::Version
53
+ hash: 3
54
+ segments:
55
+ - 0
56
+ version: "0"
57
+ required_rubygems_version: !ruby/object:Gem::Requirement
58
+ none: false
59
+ requirements:
60
+ - - ">="
61
+ - !ruby/object:Gem::Version
62
+ hash: 3
63
+ segments:
64
+ - 0
65
+ version: "0"
66
+ requirements: []
67
+
68
+ rubyforge_project:
69
+ rubygems_version: 1.8.24
70
+ signing_key:
71
+ specification_version: 3
72
+ summary: Deploy 12-factor applications using Capistrano
73
+ test_files: []
74
+