Production deployment without Javascript runtime

Hey!

I want to keep my production deployment simple, so I would like to prebuild my assets (js and css) with the asset pipeline and deploy the generated assets along with the ruby source files on a small alpine linux container without any javascript runtime (because it is not needed).

The rails guide suggests to use the mini_racer gem for production deployment when using pre-generated assets, but this brings a lot of complexity with it (Alpine Linux uses musl instead of libc, building the v8 will fail, there are a lot of dirty hacks around this, which will fail with the next version, …).

So my question is simple: Is there a way to create a group in the Gemfile for the asset pipeline only, so I can put all gems which need a javascript runtime in there and the production deployment can run without any javascript runtime? I found various outdated solutions (an :asset group, an :assets group etc.) but none of them worked. Or is there an other way to solve this (no js runtime in production)?

Thanks!

1 Like

I haven’t tested this yet but you could try having more than one gemfile. I was reading about this the other day: Faster RuboCop runs for Rails apps - DEV Community

For me it sounds like you could just use the :development group in the Gemfile:

group :development do
  gem "foo"
end

rubygems.org uses an asset group and has two docker images, one that compiles the assets and one that runs the applications web server rubygems.org/Gemfile at master · rubygems/rubygems.org · GitHub rubygems.org/Dockerfile at master · rubygems/rubygems.org · GitHub

1 Like

Thank you @dorianmariefr, the RAILS_GROUPS environment variable was the missing piece.