add asset sync gem
This commit is contained in:
parent
e156947d0b
commit
b33ee8c688
5 changed files with 29 additions and 24 deletions
1
Gemfile
1
Gemfile
|
|
@ -119,6 +119,7 @@ group :assets do
|
||||||
|
|
||||||
gem 'handlebars_assets'
|
gem 'handlebars_assets'
|
||||||
gem 'uglifier'
|
gem 'uglifier'
|
||||||
|
gem "asset_sync"
|
||||||
end
|
end
|
||||||
|
|
||||||
gem 'jquery-rails'
|
gem 'jquery-rails'
|
||||||
|
|
|
||||||
|
|
@ -90,6 +90,9 @@ GEM
|
||||||
builder
|
builder
|
||||||
archive-tar-minitar (0.5.2)
|
archive-tar-minitar (0.5.2)
|
||||||
arel (2.2.3)
|
arel (2.2.3)
|
||||||
|
asset_sync (0.3.1)
|
||||||
|
activemodel
|
||||||
|
fog
|
||||||
bcrypt-ruby (3.0.1)
|
bcrypt-ruby (3.0.1)
|
||||||
builder (3.0.0)
|
builder (3.0.0)
|
||||||
capistrano (2.9.0)
|
capistrano (2.9.0)
|
||||||
|
|
@ -475,6 +478,7 @@ DEPENDENCIES
|
||||||
acts_as_api
|
acts_as_api
|
||||||
addressable (= 2.2.4)
|
addressable (= 2.2.4)
|
||||||
airbrake
|
airbrake
|
||||||
|
asset_sync
|
||||||
bundler (~> 1.1.0)
|
bundler (~> 1.1.0)
|
||||||
capistrano (~> 2.9.0)
|
capistrano (~> 2.9.0)
|
||||||
capistrano-ext (= 1.2.1)
|
capistrano-ext (= 1.2.1)
|
||||||
|
|
|
||||||
23
config/initializers/asset_sync.rb
Normal file
23
config/initializers/asset_sync.rb
Normal file
|
|
@ -0,0 +1,23 @@
|
||||||
|
require File.join(File.dirname(__FILE__), '..', '..', 'app', 'models', 'app_config')
|
||||||
|
AssetSync.configure do |config|
|
||||||
|
config.fog_provider = 'AWS'
|
||||||
|
config.fog_directory = AppConfig[:s3_bucket]
|
||||||
|
config.aws_access_key_id = AppConfig[:s3_key]
|
||||||
|
config.aws_secret_access_key = AppConfig[:s3_secret]
|
||||||
|
|
||||||
|
# Don't delete files from the store
|
||||||
|
# config.existing_remote_files = "keep"
|
||||||
|
#
|
||||||
|
# Increase upload performance by configuring your region
|
||||||
|
# config.fog_region = 'eu-west-1'
|
||||||
|
#
|
||||||
|
# Automatically replace files with their equivalent gzip compressed version
|
||||||
|
# config.gzip_compression = true
|
||||||
|
#
|
||||||
|
# Use the Rails generated 'manifest.yml' file to produce the list of files to
|
||||||
|
# upload instead of searching the assets directory.
|
||||||
|
# config.manifest = true
|
||||||
|
#
|
||||||
|
# Fail silently. Useful for environments such as Heroku
|
||||||
|
# config.fail_silently = true
|
||||||
|
end
|
||||||
|
|
@ -1,23 +0,0 @@
|
||||||
namespace :assets do
|
|
||||||
task :deploy do
|
|
||||||
puts "compiling sass..."
|
|
||||||
system 'sass --update public/stylesheets/sass:public/stylesheets'
|
|
||||||
|
|
||||||
puts "packaging assets..."
|
|
||||||
Jammit.package!
|
|
||||||
|
|
||||||
Rake::Task['assets:upload'].invoke
|
|
||||||
end
|
|
||||||
|
|
||||||
task :upload => [:environment] do
|
|
||||||
s3_configuration = {
|
|
||||||
:bucket_name => AppConfig[:s3_bucket],
|
|
||||||
:access_key_id => AppConfig[:s3_key],
|
|
||||||
:secret_access_key => AppConfig[:s3_secret]
|
|
||||||
}
|
|
||||||
Jammit.upload_to_s3!(s3_configuration)
|
|
||||||
asset_host = "https://#{s3_configuration[:bucket_name]}.s3.amazonaws.com"
|
|
||||||
puts "NOTE: ENV['ASSET_HOST'] is now: #{asset_host}, but you may know your cdn url better than I"
|
|
||||||
puts "Please set this in your ENV hash in a production enviroment"
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
@ -11,7 +11,7 @@ desc "Alias for resque:work (To run workers on Heroku)"
|
||||||
task "jobs:work" => "resque:work"
|
task "jobs:work" => "resque:work"
|
||||||
|
|
||||||
desc 'clear your failure queue in resque. good for crons.'
|
desc 'clear your failure queue in resque. good for crons.'
|
||||||
task 'resque:clear_failed' => [:environment]do
|
task 'resque:clear_failed' => [:environment] do
|
||||||
puts "clearing resque failures"
|
puts "clearing resque failures"
|
||||||
Resque::Failure.clear
|
Resque::Failure.clear
|
||||||
puts "complete!"
|
puts "complete!"
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue