Created
April 11, 2011 04:27
-
-
Save mrrooijen/913056 to your computer and use it in GitHub Desktop.
My Heroku Asset Packager setup
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Gemfile | |
gem 'jammit-s3', :git => 'git://github.com/meskyanichi/jammit-s3.git' | |
# config/assets.yml | |
s3_bucket: mybucket | |
s3_access_key_id: <%= ENV['AWS_ACCESS_KEY_ID'] %> | |
s3_secret_access_key: <%= ENV['AWS_SECRET_ACCESS_KEY'] %> | |
s3_permission: public_read | |
embed_assets: on | |
javascripts: | |
workspace: | |
- public/javascripts/jquery.js | |
- public/javascripts/rails.js | |
- public/javascripts/faye.js | |
- public/javascripts/live.js | |
stylesheets: | |
login: | |
- public/stylesheets/login.css | |
workspace: | |
- public/stylesheets/application.css | |
- public/stylesheets/live.css | |
# config/compass.rb | |
project_type = :rails | |
project_path = Compass::AppIntegration::Rails.root | |
http_path = '/' | |
css_dir = 'public/stylesheets' | |
sass_dir = 'app/stylesheets' | |
# config/environments/production.rb | |
config.action_controller.asset_host = 'd5k075s055b9w.cloudfront.net' | |
# app/views/layouts/application.html/haml | |
= include_javascripts :workspace | |
= include_stylesheets :workspace | |
# config/initializers/carrierwave.rb (not asset related, but still S3 file storage) | |
CarrierWave.configure do |config| | |
config.fog_credentials = { | |
:provider => 'AWS', | |
:aws_access_key_id => ENV['AWS_ACCESS_KEY_ID'], | |
:aws_secret_access_key => ENV['AWS_SECRET_ACCESS_KEY'] | |
} | |
config.fog_directory = 'mybucket' | |
config.fog_host = 'http://d5k075s055b9w.cloudfront.net' | |
end | |
# lib/tasks/heroku.rake | |
namespace :heroku do | |
desc 'Deploy application to heroku.' | |
task :deploy do | |
Thread.new do | |
Rake::Task['heroku:compile'].execute | |
Rake::Task['heroku:jammit'].execute | |
end | |
puts "Deploying application (current branch) to Heroku..\n\n" | |
system('git push heroku +HEAD:master') | |
end | |
desc 'Packages all assets and pushes to Amazon S3.' | |
task :jammit => :compile do | |
puts 'Packaging assets and pushing them to Amazon S3..' | |
system('bundle exec jammit-s3') | |
end | |
desc 'Compiles all SCSS and SASS files with Compass.' | |
task :compile do | |
puts 'Compiling SCSS and SASS with Compass..' | |
system('bundle exec compass compile') | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment