freerange_deploy 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/README ADDED
@@ -0,0 +1,33 @@
1
+ freerange/deploy
2
+ ================
3
+
4
+ Allows simple, git-based deployment on freerange-compatible servers (see assumptions below)
5
+
6
+ How to use
7
+ ----------
8
+
9
+ In your project, create a Capfile, like this:
10
+
11
+ require 'freerange/deploy'
12
+
13
+ server "gofreerange.com", :app, :web, :db, :primary => true
14
+ set :application, "gofreerange.com" # defaults to the name of the repo at origin
15
+
16
+ Next, prepare the server:
17
+
18
+ $ cap deploy:setup
19
+
20
+ This adds a git remote to your local repository, and creates an apache virtual host configuration on the server, and performs the initial git deploy. To deploy again, just push to 'production'
21
+
22
+ % git push production master
23
+
24
+
25
+
26
+ Assumptions
27
+ -----------
28
+
29
+ 1. You're deploying as 'deploy'
30
+ 2. You're deploying to /var/www/<application>
31
+ 3. Your apache is setup to read vhost files from /var/www/apache_vhost
32
+ 4. The deploy user has write access to that directory
33
+ 5. The deploy user is a sudoer
@@ -0,0 +1,67 @@
1
+ require "rubygems"
2
+ require "rake/gempackagetask"
3
+ require "rake/rdoctask"
4
+
5
+
6
+
7
+ task :default => :package do
8
+ puts "Don't forget to write some tests!"
9
+ end
10
+
11
+ # This builds the actual gem. For details of what all these options
12
+ # mean, and other ones you can add, check the documentation here:
13
+ #
14
+ # http://rubygems.org/read/chapter/20
15
+ #
16
+ spec = Gem::Specification.new do |s|
17
+
18
+ # Change these as appropriate
19
+ s.name = "freerange_deploy"
20
+ s.version = "0.1.1"
21
+ s.summary = "Enables simple git-based deployments to freerange-compatible hosts"
22
+ s.author = "James Adam"
23
+ s.email = "james.adam@gofreerange.com"
24
+ s.homepage = "http://gofreerange.com"
25
+
26
+ s.has_rdoc = true
27
+ s.extra_rdoc_files = %w(README)
28
+ s.rdoc_options = %w(--main README)
29
+
30
+ # Add any extra files to include in the gem
31
+ s.files = %w(freerange_deploy.gemspec Rakefile README) + Dir.glob("{lib/**/*}")
32
+ s.require_paths = ["lib"]
33
+
34
+ # If you want to depend on other gems, add them here, along with any
35
+ # relevant versions
36
+ s.add_dependency("git-deploy", "~> 0.3.0")
37
+
38
+ # If your tests use any gems, include them here
39
+ # s.add_development_dependency("mocha") # for example
40
+ end
41
+
42
+ # This task actually builds the gem. We also regenerate a static
43
+ # .gemspec file, which is useful if something (i.e. GitHub) will
44
+ # be automatically building a gem for this project. If you're not
45
+ # using GitHub, edit as appropriate.
46
+ #
47
+ # To publish your gem online, install the 'gemcutter' gem; Read more
48
+ # about that here: http://gemcutter.org/pages/gem_docs
49
+ Rake::GemPackageTask.new(spec) do |pkg|
50
+ pkg.gem_spec = spec
51
+
52
+ # Generate the gemspec file for github.
53
+ file = File.dirname(__FILE__) + "/#{spec.name}.gemspec"
54
+ File.open(file, "w") {|f| f << spec.to_ruby }
55
+ end
56
+
57
+ # Generate documentation
58
+ Rake::RDocTask.new do |rd|
59
+ rd.main = "README"
60
+ rd.rdoc_files.include("README", "lib/**/*.rb")
61
+ rd.rdoc_dir = "rdoc"
62
+ end
63
+
64
+ desc 'Clear out RDoc and generated packages'
65
+ task :clean => [:clobber_rdoc, :clobber_package] do
66
+ rm "#{spec.name}.gemspec"
67
+ end
@@ -0,0 +1,31 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ Gem::Specification.new do |s|
4
+ s.name = %q{freerange_deploy}
5
+ s.version = "0.1.1"
6
+
7
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
+ s.authors = ["James Adam"]
9
+ s.date = %q{2010-02-22}
10
+ s.email = %q{james.adam@gofreerange.com}
11
+ s.extra_rdoc_files = ["README"]
12
+ s.files = ["freerange_deploy.gemspec", "Rakefile", "README", "lib/freerange", "lib/freerange/deploy.rb"]
13
+ s.homepage = %q{http://gofreerange.com}
14
+ s.rdoc_options = ["--main", "README"]
15
+ s.require_paths = ["lib"]
16
+ s.rubygems_version = %q{1.3.5}
17
+ s.summary = %q{Enables simple git-based deployments to freerange-compatible hosts}
18
+
19
+ if s.respond_to? :specification_version then
20
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
21
+ s.specification_version = 3
22
+
23
+ if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
24
+ s.add_runtime_dependency(%q<git-deploy>, ["~> 0.3.0"])
25
+ else
26
+ s.add_dependency(%q<git-deploy>, ["~> 0.3.0"])
27
+ end
28
+ else
29
+ s.add_dependency(%q<git-deploy>, ["~> 0.3.0"])
30
+ end
31
+ end
@@ -0,0 +1,60 @@
1
+ require "git_deploy"
2
+
3
+ Capistrano::Configuration.instance(:must_exist).load do
4
+ # User details
5
+ set :user, 'deploy'
6
+ set :group, 'admin'
7
+
8
+ # Application details
9
+ set(:runner) { user }
10
+ set :use_sudo, false
11
+
12
+ # SCM settings
13
+ set :scm, 'git'
14
+ # set to the name of git remote you intend to deploy to
15
+ set :remote, 'production' # overrides the default git-deploy setting of 'origin'
16
+ # specify the deployment branch
17
+ set :branch, 'master'
18
+
19
+ # The appliation name defaults to the name of the repository at the origin remote
20
+ set(:application) { File.basename(`#{source.local.scm('config', "remote.origin.url")}`, ".git") }
21
+
22
+ # Deploy to our default location
23
+ set(:deploy_to) { "/var/www/#{application}" }
24
+
25
+ # Git settings for Capistrano
26
+ default_run_options[:pty] = true # needed for git password prompts
27
+ ssh_options[:forward_agent] = true # use the keys for the person running the cap command to check out the app
28
+
29
+
30
+ before "deploy:setup", "freerange:setup_git_remote"
31
+ after "deploy:setup", "freerange:setup_apache"
32
+
33
+ namespace "freerange" do
34
+ task :setup_git_remote do
35
+ remote_url = "deploy@#{roles[:app].first}:/var/www/#{application}"
36
+ puts "Setting up git remote '#{remote}' -> #{remote_url}"
37
+ `git remote add #{remote} #{remote_url}`
38
+ end
39
+ task :setup_apache do
40
+ vhost_template =<<-EOT
41
+ <VirtualHost *:80>
42
+ DocumentRoot /var/www/#{application}/public
43
+ ServerName #{application}
44
+ <Directory "/var/www/#{application}/public">
45
+ allow from all
46
+ Options +Indexes
47
+ </Directory>
48
+ </VirtualHost>
49
+ EOT
50
+
51
+ put vhost_template.strip, "/var/www/apache_vhosts/#{application}"
52
+
53
+ # Disable the default site, just in case; it will get in the way.
54
+ sudo "a2dissite default"
55
+
56
+ # Restart apache
57
+ sudo "apache2ctl restart"
58
+ end
59
+ end
60
+ end
metadata ADDED
@@ -0,0 +1,68 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: freerange_deploy
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.1
5
+ platform: ruby
6
+ authors:
7
+ - James Adam
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2010-02-22 00:00:00 +00:00
13
+ default_executable:
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: git-deploy
17
+ type: :runtime
18
+ version_requirement:
19
+ version_requirements: !ruby/object:Gem::Requirement
20
+ requirements:
21
+ - - ~>
22
+ - !ruby/object:Gem::Version
23
+ version: 0.3.0
24
+ version:
25
+ description:
26
+ email: james.adam@gofreerange.com
27
+ executables: []
28
+
29
+ extensions: []
30
+
31
+ extra_rdoc_files:
32
+ - README
33
+ files:
34
+ - freerange_deploy.gemspec
35
+ - Rakefile
36
+ - README
37
+ - lib/freerange/deploy.rb
38
+ has_rdoc: true
39
+ homepage: http://gofreerange.com
40
+ licenses: []
41
+
42
+ post_install_message:
43
+ rdoc_options:
44
+ - --main
45
+ - README
46
+ require_paths:
47
+ - lib
48
+ required_ruby_version: !ruby/object:Gem::Requirement
49
+ requirements:
50
+ - - ">="
51
+ - !ruby/object:Gem::Version
52
+ version: "0"
53
+ version:
54
+ required_rubygems_version: !ruby/object:Gem::Requirement
55
+ requirements:
56
+ - - ">="
57
+ - !ruby/object:Gem::Version
58
+ version: "0"
59
+ version:
60
+ requirements: []
61
+
62
+ rubyforge_project:
63
+ rubygems_version: 1.3.5
64
+ signing_key:
65
+ specification_version: 3
66
+ summary: Enables simple git-based deployments to freerange-compatible hosts
67
+ test_files: []
68
+