Skip to content

Instantly share code, notes, and snippets.

@stephenreid
Created April 13, 2016 03:01
Show Gist options
  • Save stephenreid/bc708484101a2b3d3475e91a651a9680 to your computer and use it in GitHub Desktop.
Save stephenreid/bc708484101a2b3d3475e91a651a9680 to your computer and use it in GitHub Desktop.
Amazon Opsworks Assets Deploy
Chef::Log.info("Precompiling assets for RAILS_ENV=#{rails_env}...")
# Precompile assets. Assets are compiled into shared/assets and shared between deploys.
shared_path = "#{new_resource.deploy_to}/shared"
# create shared directory for assets, if it doesn't exist
directory "#{shared_path}/assets" do
mode 0770
action :create
recursive true
end
# symlink current deploy's asset folder to shared assets each deploy
link "#{release_path}/public/assets" do
to "#{shared_path}/assets"
end
directory "#{shared_path}/cache" do
mode 0770
action :create
recursive true
end
# symlink current deploy's cache folder to cache assets each deploy
link "#{release_path}/tmp/cache" do
to "#{shared_path}/cache"
end
execute "rake assets:precompile" do
cwd release_path
command "bundle exec rake assets:precompile"
environment "RAILS_ENV" => rails_env
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment