I noticed that the task rake assets:precompile requires a database connection: this means that the task can only be run at “run time” (after deployment) as opposed to “build time” (while building the container image). Since the task is very expensive in terms of running time, this can be annoying.
Not being a Ruby/Rails developer, I did some research and found that this behavior could be disabled until Rails 4, and afterwards developers have been resorting to some hacks (null database connection). The latter of course requires intimate knowledge of the application, in order to avoid breaking anything.
While searching for a better solution I found this commit which seems similar in spirit. So my questions are:
- are the developers already working on the matter, or are there technical reasons why this cannot be done?
- if some parts of the task indeed require the database connection, would it be feasible to split the task into two (or more), so that some work (e.g. compiling locales, minifying JS and CSS) can be done at build time?
- is there a known workaround at this moment (e.g. “null database” as mentioned above)?