Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Build site on deploy

* Add Ruby 2.0 to Gemfile
* Add rake-pipline to trigger the assets:precompile
* Add Unicorn web server
* Add Procfile for Heroku deploys

Minor changes:

* Add gitignore file
* Add config.rb so Middleman can build
* Add sample index page
  • Loading branch information...
commit 6418ad1042ef20c809d44cb4c5c9d892e0a959a3 1 parent 4ee9ab3
@harlow harlow authored
View
14 .gitignore
@@ -0,0 +1,14 @@
+# Ignore environment data
+.env
+
+# Ignore bundler config
+/.bundle
+
+# Ignore the build directory
+/build
+
+# Ignore Sass' cache
+/.sass-cache
+
+# Ignore .DS_store file
+.DS_Store
View
7 Gemfile
@@ -1,3 +1,6 @@
-source "https://rubygems.org"
+source 'https://rubygems.org'
+ruby '2.0.0'
-gem "middleman", "~> 3.0"
+gem 'middleman', '~> 3.0'
+gem 'rake-pipeline'
+gem 'unicorn'
View
14 Gemfile.lock
@@ -23,6 +23,8 @@ GEM
rack (>= 1.0.0)
url_mount (~> 0.2.1)
i18n (0.6.4)
+ json (1.8.1)
+ kgio (2.8.1)
listen (0.7.3)
maruku (0.6.1)
syntax (>= 1.0.0)
@@ -70,6 +72,12 @@ GEM
rack
rack-test (0.6.2)
rack (>= 1.0)
+ raindrops (0.12.0)
+ rake (0.9.6)
+ rake-pipeline (0.7.0)
+ json
+ rake (~> 0.9.0)
+ thor
rb-fsevent (0.9.3)
sass (3.2.7)
sinatra (1.3.6)
@@ -90,6 +98,10 @@ GEM
uglifier (1.2.7)
execjs (>= 0.3.0)
multi_json (~> 1.3)
+ unicorn (4.7.0)
+ kgio (~> 2.6)
+ rack
+ raindrops (~> 0.7)
url_mount (0.2.1)
rack
@@ -98,3 +110,5 @@ PLATFORMS
DEPENDENCIES
middleman (~> 3.0)
+ rake-pipeline
+ unicorn
View
1  Procfile
@@ -0,0 +1 @@
+web: bundle exec unicorn -p $PORT -c ./unicorn.rb
View
1  README.md
@@ -7,6 +7,7 @@
$ bundle install && bundle exec middleman init .
$ git add . && git commit -m "brand new site"
$ heroku create && git push heroku master
+ $ heroku open
The only expectation is that `middleman build` will generate your site into `./build`. That's where Rack::TryStatic will look.
View
4 Rakefile
@@ -1,5 +1,5 @@
namespace :assets do
task :precompile do
- sh "middleman build"
+ sh 'middleman build'
end
-end
+end
View
12 config.rb
@@ -0,0 +1,12 @@
+activate :automatic_image_sizes
+activate :directory_indexes
+
+set :css_dir, 'stylesheets'
+set :js_dir, 'javascripts'
+set :images_dir, 'images'
+
+configure :build do
+ activate :minify_css
+ activate :minify_javascript
+ activate :asset_hash
+end
View
7 config.ru
@@ -6,11 +6,8 @@
# - `/foo` will try to serve `build/foo` or `build/foo.html` in that order
# - missing files will try to serve build/404.html or a tiny default 404 page
-
module Rack
-
class TryStatic
-
def initialize(app, options)
@app = app
@try = ['', *options.delete(:try)]
@@ -20,10 +17,12 @@ module Rack
def call(env)
orig_path = env['PATH_INFO']
found = nil
+
@try.each do |path|
resp = @static.call(env.merge!({'PATH_INFO' => orig_path + path}))
break if 404 != resp[0] && found = resp
end
+
found or @app.call(env.merge!('PATH_INFO' => orig_path))
end
end
@@ -40,4 +39,4 @@ run lambda{ |env|
else
[ 404, { 'Content-Type' => 'text/html' }, ['404 - page not found'] ]
end
-}
+}
View
0  source/404.html.erb → source/404.erb
File renamed without changes
View
1  source/index.erb
@@ -0,0 +1 @@
+<h1>Middleman on Heroku!</h1>
View
15 unicorn.rb
@@ -0,0 +1,15 @@
+worker_processes (ENV['WEB_CONCURRENCY'] || 3).to_i
+timeout (ENV['WEB_TIMEOUT'] || 5).to_i
+
+before_fork do |server, worker|
+ Signal.trap 'TERM' do
+ puts 'Unicorn master intercepting TERM and sending myself QUIT instead'
+ Process.kill 'QUIT', Process.pid
+ end
+end
+
+after_fork do |server, worker|
+ Signal.trap 'TERM' do
+ puts 'Unicorn worker intercepting TERM and doing nothing. Wait for master to sent QUIT'
+ end
+end
Please sign in to comment.
Something went wrong with that request. Please try again.