georgia_heroku 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +17 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +29 -0
- data/Rakefile +1 -0
- data/georgia_heroku.gemspec +23 -0
- data/lib/generators/georgia/heroku/install/install_generator.rb +101 -0
- data/lib/generators/georgia/heroku/install/templates/Procfile +1 -0
- data/lib/generators/georgia/heroku/install/templates/README +37 -0
- data/lib/generators/georgia/heroku/install/templates/config/initializers/bonsai.rb +1 -0
- data/lib/generators/georgia/heroku/install/templates/config/unicorn.rb +35 -0
- data/lib/georgia_heroku.rb +10 -0
- data/lib/georgia_heroku/version.rb +3 -0
- data/lib/tasks/georgia_heroku.rake +92 -0
- metadata +86 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: e91dea62516e23c3e5eb546feee7a612e143a8e0
|
4
|
+
data.tar.gz: 24a42b2f1ba39d42b1a34d9206e9cb206984bb67
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: ff274e03669bb4d7e09d71e9844f39896ce884bd198f15cb7490851e85ceb792efd8476d9805ddf99608dc1717e5538cfd9057934ed4ac20fe2d43b5410df323
|
7
|
+
data.tar.gz: d6b8f89d485cfb06b22f63b7b0a81f9fc8f076edd1b9dc5e4e64fde2f855451f81304bd32a450770e70aaafde04b0c9fe979891c0b7c3ae672e687c9ca290ac4
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 Mathieu Gagne
|
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,29 @@
|
|
1
|
+
# GeorgiaHeroku
|
2
|
+
|
3
|
+
Prepare Georgia CMS to be hosted on Heroku's platform
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'georgia_heroku'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install georgia_heroku
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
Run the install generator to ready your app to Heroku.
|
22
|
+
|
23
|
+
## Contributing
|
24
|
+
|
25
|
+
1. Fork it ( http://github.com/<my-github-username>/georgia_heroku/fork )
|
26
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
27
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
28
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
29
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'georgia_heroku/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "georgia_heroku"
|
8
|
+
spec.version = GeorgiaHeroku::VERSION
|
9
|
+
spec.authors = ["Mathieu Gagne"]
|
10
|
+
spec.email = ["gagne.mathieu@hotmail.com"]
|
11
|
+
spec.summary = %q{Prepare Georgia for Heroku}
|
12
|
+
spec.description = %q{Prepare Georgia CMS to be hosted on Heroku's platform}
|
13
|
+
spec.homepage = "https://github.com/georgia-cms/georgia_heroku"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.5"
|
22
|
+
spec.add_development_dependency "rake"
|
23
|
+
end
|
@@ -0,0 +1,101 @@
|
|
1
|
+
module Georgia
|
2
|
+
module Heroku
|
3
|
+
module Generators
|
4
|
+
class InstallGenerator < Rails::Generators::Base
|
5
|
+
source_root File.expand_path('../templates', __FILE__)
|
6
|
+
|
7
|
+
desc "Prepare Georgia CMS to be hosted on Heroku"
|
8
|
+
|
9
|
+
def heroku_gems
|
10
|
+
gem_group :production do
|
11
|
+
gem 'heroku-deflater'
|
12
|
+
gem 'rails_12factor'
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
def heroku_environment_config
|
17
|
+
gsub_file 'config/environments/production.rb', "config.serve_static_assets = false" do <<-'RUBY'
|
18
|
+
# config.serve_static_assets = false
|
19
|
+
# Enable Rails's static asset server for Heroku
|
20
|
+
config.serve_static_assets = true
|
21
|
+
|
22
|
+
RUBY
|
23
|
+
end
|
24
|
+
application "config.assets.initialize_on_precompile = false" if Rails::VERSION::MAJOR == 3 and Rails::VERSION::MINOR >= 1
|
25
|
+
end
|
26
|
+
|
27
|
+
def cache_config
|
28
|
+
gem 'dalli'
|
29
|
+
gem 'kgio'
|
30
|
+
gem 'rack-cache'
|
31
|
+
gem 'memcachier'
|
32
|
+
inject_into_file 'config/environments/production.rb', after: "Application.configure do" do <<-'RUBY'
|
33
|
+
|
34
|
+
# Set static assets cache header. rack-cache will cache those.
|
35
|
+
config.static_cache_control = "public, max-age=31536000"
|
36
|
+
|
37
|
+
config.cache_store = :dalli_store
|
38
|
+
|
39
|
+
client = Dalli::Client.new(ENV["MEMCACHIER_SERVERS"],
|
40
|
+
:value_max_bytes => 10485760,
|
41
|
+
:expires_in => 86400)
|
42
|
+
|
43
|
+
# Configure rack-cache for using memcachier
|
44
|
+
config.action_dispatch.rack_cache = {
|
45
|
+
:metastore => client,
|
46
|
+
:entitystore => client
|
47
|
+
}
|
48
|
+
RUBY
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
def unicorn
|
53
|
+
gem 'unicorn', group: :production
|
54
|
+
copy_file "config/unicorn.rb"
|
55
|
+
copy_file "Procfile"
|
56
|
+
end
|
57
|
+
|
58
|
+
def bonsai_config
|
59
|
+
gem 'tire'
|
60
|
+
copy_file "config/initializers/bonsai.rb"
|
61
|
+
end
|
62
|
+
|
63
|
+
def sendgrid_config
|
64
|
+
inject_into_file 'config/environments/production.rb', after: "Application.configure do" do <<-'RUBY'
|
65
|
+
|
66
|
+
# Send emails via sendgrid
|
67
|
+
config.action_mailer.smtp_settings = {
|
68
|
+
:address => 'smtp.sendgrid.net',
|
69
|
+
:port => '587',
|
70
|
+
:authentication => :plain,
|
71
|
+
:user_name => ENV['SENDGRID_USERNAME'],
|
72
|
+
:password => ENV['SENDGRID_PASSWORD'],
|
73
|
+
:domain => 'heroku.com',
|
74
|
+
:enable_starttls_auto => true
|
75
|
+
}
|
76
|
+
RUBY
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
def cloudinary_config
|
81
|
+
gem 'cloudinary'
|
82
|
+
end
|
83
|
+
|
84
|
+
def deploy_config
|
85
|
+
gem_group :assets do
|
86
|
+
gem 'turbo-sprockets-rails3'
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
def bundle
|
91
|
+
run "bundle install"
|
92
|
+
end
|
93
|
+
|
94
|
+
def show_readme
|
95
|
+
readme "README"
|
96
|
+
end
|
97
|
+
|
98
|
+
end
|
99
|
+
end
|
100
|
+
end
|
101
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
web: bundle exec unicorn -p $PORT -c ./config/unicorn.rb
|
@@ -0,0 +1,37 @@
|
|
1
|
+
===============================================================================
|
2
|
+
|
3
|
+
Add the following addons:
|
4
|
+
|
5
|
+
heroku addons:add memcachier
|
6
|
+
heroku addons:add bonsai
|
7
|
+
heroku addons:add sendgrid
|
8
|
+
heroku addons:add cloudinary
|
9
|
+
|
10
|
+
Add builpack to speed up deployment
|
11
|
+
|
12
|
+
heroku config:add BUILDPACK_URL=https://github.com/ndbroadbent/heroku-buildpack-turbo-sprockets.git
|
13
|
+
|
14
|
+
Push to repository
|
15
|
+
|
16
|
+
git add . ; git commit -m "Herokuify"
|
17
|
+
|
18
|
+
Push to Heroku
|
19
|
+
|
20
|
+
rake georgia:heroku:deploy
|
21
|
+
|
22
|
+
Migrate Database
|
23
|
+
|
24
|
+
heroku run rake db:migrate
|
25
|
+
|
26
|
+
Add elasticsearch indices
|
27
|
+
|
28
|
+
heroku run rake environment tire:import CLASS=Georgia::Page FORCE=true
|
29
|
+
heroku run rake environment tire:import CLASS=Ckeditor::Asset FORCE=true
|
30
|
+
heroku run rake environment tire:import CLASS=Ckeditor::Picture FORCE=true
|
31
|
+
|
32
|
+
Add Admin user
|
33
|
+
|
34
|
+
heroku run rake db:seed
|
35
|
+
|
36
|
+
|
37
|
+
===============================================================================
|
@@ -0,0 +1 @@
|
|
1
|
+
ENV['ELASTICSEARCH_URL'] = ENV['BONSAI_URL']
|
@@ -0,0 +1,35 @@
|
|
1
|
+
# config/unicorn.rb
|
2
|
+
|
3
|
+
worker_processes 3
|
4
|
+
timeout 30
|
5
|
+
preload_app true
|
6
|
+
|
7
|
+
before_fork do |server, worker|
|
8
|
+
# Replace with MongoDB or whatever
|
9
|
+
if defined?(ActiveRecord::Base)
|
10
|
+
ActiveRecord::Base.connection.disconnect!
|
11
|
+
Rails.logger.info('Disconnected from ActiveRecord')
|
12
|
+
end
|
13
|
+
|
14
|
+
# If you are using Redis but not Resque, change this
|
15
|
+
if defined?(Resque)
|
16
|
+
Resque.redis.quit
|
17
|
+
Rails.logger.info('Disconnected from Redis')
|
18
|
+
end
|
19
|
+
|
20
|
+
sleep 1
|
21
|
+
end
|
22
|
+
|
23
|
+
after_fork do |server, worker|
|
24
|
+
# Replace with MongoDB or whatever
|
25
|
+
if defined?(ActiveRecord::Base)
|
26
|
+
ActiveRecord::Base.establish_connection
|
27
|
+
Rails.logger.info('Connected to ActiveRecord')
|
28
|
+
end
|
29
|
+
|
30
|
+
# If you are using Redis but not Resque, change this
|
31
|
+
if defined?(Resque)
|
32
|
+
Resque.redis = ENV['REDIS_URI']
|
33
|
+
Rails.logger.info('Connected to Redis')
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,92 @@
|
|
1
|
+
# For usage with Heroku
|
2
|
+
# Run this first:
|
3
|
+
# heroku config:add BUILDPACK_URL=https://github.com/ndbroadbent/heroku-buildpack-turbo-sprockets.git
|
4
|
+
|
5
|
+
require 'fileutils'
|
6
|
+
|
7
|
+
# Warning: The following deploy task will completely overwrite whatever is currently deployed to Heroku.
|
8
|
+
# The deploy branch is rebased onto master, so the push needs to be forced.
|
9
|
+
namespace :georgia do
|
10
|
+
namespace :heroku do
|
11
|
+
desc "Deploy app to Heroku after precompiling assets"
|
12
|
+
task :deploy do
|
13
|
+
deploy_branch = 'heroku'
|
14
|
+
remote = 'heroku'
|
15
|
+
deploy_repo_dir = "tmp/heroku_deploy"
|
16
|
+
|
17
|
+
begin
|
18
|
+
# Check branch and working directory. Fail if not on clean master branch.
|
19
|
+
branch = `branch_name=$(git symbolic-ref HEAD 2>/dev/null); branch_name=${branch_name##refs/heads/}; echo ${branch_name:-HEAD}`.strip
|
20
|
+
if branch != 'master'
|
21
|
+
raise "You have checked out the #{branch} branch, please only deploy from the master branch!"
|
22
|
+
end
|
23
|
+
if `git status --porcelain`.present?
|
24
|
+
raise "You have unstaged or uncommitted changes! Please only deploy from a clean working directory!"
|
25
|
+
end
|
26
|
+
|
27
|
+
unless File.exists? deploy_repo_dir
|
28
|
+
# Copy repo to tmp dir so we can continue working while it deploys
|
29
|
+
@new_repo = true
|
30
|
+
puts "Copying repo to #{deploy_repo_dir}..."
|
31
|
+
# Can't copy into self, so copy to /tmp first
|
32
|
+
FileUtils.cp_r Rails.root.to_s, "/tmp/heroku_deploy"
|
33
|
+
FileUtils.mv "/tmp/heroku_deploy", Rails.root.join('tmp')
|
34
|
+
end
|
35
|
+
|
36
|
+
# Change working directory to copied repo
|
37
|
+
Dir.chdir(deploy_repo_dir)
|
38
|
+
|
39
|
+
# Create new deploy branch if starting with a fresh repo
|
40
|
+
if @new_repo
|
41
|
+
# Set remote to parent git dir, so we can fetch updates on future deploys
|
42
|
+
system "git remote set-url origin ../.."
|
43
|
+
system "git checkout -b #{deploy_branch}"
|
44
|
+
|
45
|
+
# Allow git to see public/assets
|
46
|
+
puts "Removing public/assets from .gitignore..."
|
47
|
+
system 'sed -i '' "/^[\/?]public\/assets/d" .gitignore'
|
48
|
+
system 'git add .gitignore; git commit -m "Allow git to commit public/assets"'
|
49
|
+
else
|
50
|
+
# Otherwise, we're already on the deploy branch, so fetch any new changes from original repo
|
51
|
+
system "git fetch origin"
|
52
|
+
|
53
|
+
# Rebase onto origin/master.
|
54
|
+
# This step should never fail, because we are rebasing commits for files
|
55
|
+
# that should be ignored by the master repo.
|
56
|
+
unless system "git rebase origin/master"
|
57
|
+
raise "Rebase Failed! Please delete tmp/heroku_deploy and start again."
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
# Precompile assets
|
62
|
+
Rake::Task['assets:precompile'].invoke
|
63
|
+
|
64
|
+
# Add any extra tasks you want to run here, such as compiling static pages, etc.
|
65
|
+
|
66
|
+
|
67
|
+
# Add all changes and new files
|
68
|
+
system 'git add -A'
|
69
|
+
|
70
|
+
commit_message = "Added precompiled assets"
|
71
|
+
|
72
|
+
if @new_repo
|
73
|
+
# Create new commit for new repo
|
74
|
+
system "git commit -m '#{commit_message}'", :out => "/dev/null"
|
75
|
+
else
|
76
|
+
# If existing repo, amend previous assets commit
|
77
|
+
system "git commit --amend -m '#{commit_message}'", :out => "/dev/null"
|
78
|
+
end
|
79
|
+
puts "Commit: #{commit_message}"
|
80
|
+
|
81
|
+
|
82
|
+
# Force push deploy branch to Heroku
|
83
|
+
puts "Pushing #{deploy_branch} branch to master on #{remote}..."
|
84
|
+
IO.popen("git push #{remote} #{deploy_branch}:master -f") do |io|
|
85
|
+
while (line = io.gets) do
|
86
|
+
puts line
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
metadata
ADDED
@@ -0,0 +1,86 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: georgia_heroku
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Mathieu Gagne
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-03-18 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.5'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.5'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
description: Prepare Georgia CMS to be hosted on Heroku's platform
|
42
|
+
email:
|
43
|
+
- gagne.mathieu@hotmail.com
|
44
|
+
executables: []
|
45
|
+
extensions: []
|
46
|
+
extra_rdoc_files: []
|
47
|
+
files:
|
48
|
+
- ".gitignore"
|
49
|
+
- Gemfile
|
50
|
+
- LICENSE.txt
|
51
|
+
- README.md
|
52
|
+
- Rakefile
|
53
|
+
- georgia_heroku.gemspec
|
54
|
+
- lib/generators/georgia/heroku/install/install_generator.rb
|
55
|
+
- lib/generators/georgia/heroku/install/templates/Procfile
|
56
|
+
- lib/generators/georgia/heroku/install/templates/README
|
57
|
+
- lib/generators/georgia/heroku/install/templates/config/initializers/bonsai.rb
|
58
|
+
- lib/generators/georgia/heroku/install/templates/config/unicorn.rb
|
59
|
+
- lib/georgia_heroku.rb
|
60
|
+
- lib/georgia_heroku/version.rb
|
61
|
+
- lib/tasks/georgia_heroku.rake
|
62
|
+
homepage: https://github.com/georgia-cms/georgia_heroku
|
63
|
+
licenses:
|
64
|
+
- MIT
|
65
|
+
metadata: {}
|
66
|
+
post_install_message:
|
67
|
+
rdoc_options: []
|
68
|
+
require_paths:
|
69
|
+
- lib
|
70
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
71
|
+
requirements:
|
72
|
+
- - ">="
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
version: '0'
|
75
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
76
|
+
requirements:
|
77
|
+
- - ">="
|
78
|
+
- !ruby/object:Gem::Version
|
79
|
+
version: '0'
|
80
|
+
requirements: []
|
81
|
+
rubyforge_project:
|
82
|
+
rubygems_version: 2.2.1
|
83
|
+
signing_key:
|
84
|
+
specification_version: 4
|
85
|
+
summary: Prepare Georgia for Heroku
|
86
|
+
test_files: []
|