Hey guys, I have been out of the loop in rails development for a few years so I am quite out of date with my knowledge. I need some advice regarding packaging up a complex rails app in a docker container and shipping it to kubernetes. I am using gitlab CI for all of this.
What I have done so far works but the CI takes a very long time and the images are HUGE. I have several question about this process. 1. The CI takes a long time because bundle install takes a very long time. I have tried some tricks like splitting up the gemfile so the "base" gems are installed first and then later on the rest of the gems are installed. The thinking here is that you are not going to upgrade rails or pg etc all the time and that layer can be cached in the image. This does work but I don't know if this is ideal. I am about to try creating a base image with rails and other "base" gems in it but it's going to be a hassle to keep the versions synchronised with the main app. 2. I do both an yarn install and a rails:assets precompile. Do I need to do both? The assets precompile is a pain because it wants to connect to the database. I am using the nulldb adapter to get around this but is there a better way to deal with this? 3. The resultant image is 1.2 Gigs in size. This is using alpine and deleting all the crap left over from APK and Bundle installs. I tried both a three stage and a two stage docker build and I can reduce the size down a few hundred megs but the CI time shoots up because only the first stage gets cached by docker (I pull the image and use --cache-from ). Any tips or tricks to reduce the final image size and the build time would be much appreciated. Thanks. -- You received this message because you are subscribed to the Google Groups "Ruby or Rails Oceania" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/rails-oceania/8a6bdd29-7ff3-457b-8a0c-9d42dedc4675%40googlegroups.com.
