While I have to use the following construct to ensure that the Ruby environment is setup for building gems, and it’s a recommended practice for Docker,
RUN /bin/bash -c "source /usr/local/rvm/scripts/rvm \ && gem update --system --no-rdoc --no-ri \ && gem update --no-rdoc --no-ri \ && gem install --no-rdoc --no-ri bundler \ && gem install --no-rdoc --no-ri libv8 \ && gem install --no-rdoc --no-ri mysql2"
One implication of this is that it is an atomic operation and when you discover that the libmysqlclient-dev package is missing and the build needs to be run again, there’s no cache to fall back on. Ruby takes 5 hours on an r-pi, libv8 is 2 hours. This is not quick turnaround stuff for the background build although it will really improve Rails container deployment times. Always a tradeoff.