<div dir="ltr">Hey group,<div><br></div><div style>Yesterday I was doing some deployment wrangling on my current project. As part of this I realised I didn't need to ship the asset gems to production because we precompile them elsewhere. As we're not live yet, the thought struck me that I might want to upgrade the app to Rails 4 sooner rather than later, and a colleague pointed out that there's no asset group in Rails 4 anymore.</div>
<div style><br></div><div style>So I started digging, and have to say I'm a bit confused. Assuming I want to keep doing what I'm doing:</div><div style><br></div><div style>1. run tests on jenkins</div><div style>
2. precompile assets on jenkins</div><div style>3. copy everything to a new place</div><div style>4. restrict the gems in that new place with a bundle install --deployment --without development test assets</div><div style>
5. turn that into an rpm and ship it</div><div style><br></div><div style>End result: deployed app has no development or test gems, has precompiled assets, has no asset compilation gems.</div><div style><br></div><div style>
<div>(Note, this isn't necessarily how I'd want to deploy, but it's not my infrastructure so I can't really change it. Let's not play *that* game.).</div></div><div style><br></div><div style>How can I achieve step 4 and thus not ship the asset compilation gems to my deployment machines?</div>
<div style><br></div><div style>Rails 4 has no asset group, so I can't just --without assets. The bundler line in application.rb is Bunder.require(:default, Rails.env) so I can't create an assets group for those gems and expect RAILS_ENV=production bundle exec rake assets:precompile to still work.</div>
<div style><br></div><div style>I get that this is conceptually simpler and presumably there is less bullshit magic in the assets:precompile task to make sure that the assets gem group is available. But it seems to be closing off what I assume is a pretty standard deployment process: build assets elsewhere, don't ship a javascript runtime to the deployment area when you don't need it.</div>
<div style><br></div><div style>Thoughts:</div><div style><br></div><div style>1. create a new environment "assets" that is a clone of production and make the assets gems available in that. Remember to use RAILS_ENV=assets instead of RAILS_ENV=production when compiling assets. I worry about this because rails environments can end up being a bit special - I've been bitten in the past by trying to run a test suite in an RAILS_ENV not called "test".</div>
<div style><br></div><div style>2. create a custom assets:precompile task that does some bullshit magic to make the assets gems available. I worry about this because "bullshit magic".</div><div style><br></div>
<div style>3. <your better ideas go here></div><div style><br></div><div style>Anyone?</div><div style><br></div><div style>Muz</div></div>