We are trying to move asset compilation step to deployment, after the war is exploded on deployment, but before the application starts. Our project is a Rails 3.2.10 app on JRuby 1.7.1, includes turbo-sprockets-rails3 gem, packaged as war under Jetty. I have a vendor bundle directory with all my gems in the war. I figured I could invoke the assets using java, passing the jruby-complete jar as an argument. The process finds gem dependencies and rails will start, but the rake task fails because rake/file_utils.rb tries to invoke my args as a shell argument. I think the issue is that it interpets the path to jruby with the "file:/" prefix. And if one was to try to invoke a binary with that prefix, it will simply fail. Has anyone tried to compile assets while in a war structure using jruby via java? Input: ---------- #invoked from a bash script during the deploy process but before Jetty starts up. #APP_ROOT_DIR is the root of the war file export GEM_HOME=$APP_ROOT_DIR/WEB-INF/vendor/bundle/jruby/1.9 export BUNDLE_WITHOUT="development:test" export BUNDLE_GEMFILE=$APP_ROOT_DIR/WEB-INF/Gemfile export RAILS_ENV=production java -jar lib/jruby-complete-1.7.1.jar -S $APP_ROOT_DIR/WEB-INF/vendor/bundle/jruby/1.9/bin/rake --trace assets:precompile Output: -------------- starting asset compilation... Booted rails in 3.153 Included bundled gems in 5.32 ** Invoke assets:precompile (first_time) ** Execute assets:precompile file:/Users/khutson/myapp/target/myapp-1.7.6-SNAPSHOT/WEB-INF/lib/jruby-complete-1.7.1.jar!/META-INF/jruby.home/bin/jruby /Users/khutson/myapp/target/myapp-1.7.6-SNAPSHOT/WEB-INF/vendor/bundle/jruby/1.9/bin/rake assets:precompile:all RAILS_ENV=production RAILS_GROUPS=assets --trace rake aborted! Command failed with status (127): [file:/Users/khutson/ruby_apps/secondporch/...] /Users/khutson/myapp/target/myapp-1.7.6-SNAPSHOT/WEB-INF/vendor/bundle/jruby/1.9/gems/rake-10.0.3/lib/rake/file_utils.rb:53:in `create_shell_runner' Thanks for any info you can provide. We have no issue compiling assets during our build. NOTE: I don't have rvm on the server (wish I did). thanks, Kevin
on 2013-01-25 17:00
on 2013-01-25 17:17
Why not precompile the assets before packaging up the war file? That would be much safer and standard. However, if you really need to do it at deploy time then you should check out this pull request to warbler and see if it works for you: https://github.com/jruby/warbler/pull/130
on 2013-01-25 18:01
That doesn't work very well if you don't know which env the war is going to be deployed to eg: stage or prod. The different envs will often have a different asset host.
on 2013-01-25 18:15
The wabler-exec gem might be of help: https://rubygems.org/gems/warbler-exec, depending on where you want the compiled assets to be deployed. You might have to hack it a little since in the current state it just takes the war and unpacks it to a different path, but in general, there's no reason why it shouldn't be possible to feed it the path to an unpacked war as an option. Regards Felix On Jan 25, 2013, at 5:57 PM, Patrick Ritchie wrote: >> out this pull request to warbler and see if it works for you: >>> >>> >>> java -jar lib/jruby-complete-1.7.1.jar -S >>> ** Execute assets:precompile >>> /Users/khutson/myapp/target/myapp-1.7.6-SNAPSHOT/WEB-INF/vendor/bundle/jr >> > --------------------------------------------------------------------- > To unsubscribe from this list, please visit: > > http://xircles.codehaus.org/manage_email > > -- Felix Gilcher Geschftsfhrer m. +49 172 840 88 28 asquera GmbH Ohlauer Strae 43 D-10999 Berlin AG Charlottenburg, HRB 140808 B Geschftsfhrung: Felix Gilcher, Florian Gilcher
on 2013-01-25 18:55
You can make the precompiled assets relative which will allow them to work in any environment by doing something like this: https://gist.github.com/4636450 I run rake assets:precompile and then I run assets:relativize and then when I package my war file it will work for whatever path you put it under.
on 2013-01-25 19:56
That doesn't address the issue where you have different asset *hosts* on each env. Eg: cdn-stage.example.com/assets/... cdn-prod.example.com/assets/...
on 2013-01-25 23:05
I think the way I would do that would be to just build the war for staging and build the war for production separately.
on 2013-01-25 23:12
You should make the asset host configurable using an environment variable or a system property or use another mode of deployment that doesn't use wars. Wars are not really meant to be changed or partially deployed. Regards, Florian
on 2013-01-26 01:11
That could work, but asset pre-compilation is expensive. Our build servers currently generate the war on every commit to master, compiling the assets twice (once for test and once for stage) would add significant time to the build process. What we are trying to do is disconnect asset compilation from the war and move it elsewhere in our deploy process.