Minimise filesize for rails dockerfile
Currently our base rails dockerfile comes in at 1.42 GB, larger than our omnibus image.
This is due to it having most of it's build dependencies still within it's layers.
Normally in the past we have fixed this by having all using only ~2 RUN
commands. One to install dependencies (ie compile ruby, and then clean up it's build files) and the other to install the service (and cleanup it's build files)
This time around, with a newish version of docker
. We should be able to use multistage builds to do this. https://docs.docker.com/engine/userguide/eng-image/multistage-build/
Our first stage building dependencies (mostly ruby at this point) Second stage building gitlab Third stage, copy the results of the first two stages.
This will allow us to balance the container object re-use of the ruby dependencies, while still squashing down the size of each layer.
I did a quick test and it reduced the size by half.