Closed DeeDeeG closed 5 years ago
Speed comparison (docker-compose build
on Ubuntu):
2.3.7
base image, our develop
branch built in 6 minutes (and 0 seconds) on my computer. @81bd2d0
Compared to...
btyy77c:dockerAlpine
@393cf46
DeeDeeG:cleanup-Dockerfile
@cb258ad
DeeDeeG:dockerAlpine-2.5.3
@4a26021
DeeDeeG:update-Dockerfile-2
@0626c44
RefugeRestrooms:update-Dockerfile
@7bca310
DeeDeeG:slim-docker-image-optimized
@ac30878
darpr:slim-docker-image
* @b7ecb5b
* (The branch with the 2.3.7-slim
base image needs to download more packages than 2.3.7
non-slim, since it "slims down" by including less packages. Downloading and installing packages is slow. Still, this could be optimized by cleaning up the Dockerfile
. This branch is equivalent to develop
just with the slim ruby base image.)
Size of built images:
refugerestrooms_web latest . . . 1.5GB # develop
refugerestrooms_web latest . . . 1.48GB # cleanup-Dockerfile
refugerestrooms_web latest . . . 1.17GB # slim-docker-image
refugerestrooms_web latest . . . 1.02GB # slim-docker-image-optimized
refugerestrooms_web latest . . . 791MB # dockerAlpine
refugerestrooms_web latest . . . 763MB # update-Dockerfile
refugerestrooms_web latest . . . 743MB # dockerAlpine-2.5.3
refugerestrooms_web latest . . . 729MB # update-Dockerfile-2
Size of base images:
ruby 2.3.7 . . . 941MB # Regular (debian) ruby base image
ruby 2.3.7-slim . . . 254MB # Slim (debian) ruby base image
ruby 2.5.3-slim . . . 129MB # Slim (debian) ruby base image (2.5.3)
ruby 2.3.7-alpine3.7 . . . 94.4MB # Alpine ruby base image
ruby 2.5.3-alpine3.7 . . . 43.7MB # Alpine ruby base image (2.5.3)
I have a branch where I updated the Dockerfile to be simpler, build a smaller image, and build faster. (This branch is still based on the ruby:2.5.3-slim
Docker image).
Here's the link to the branch: https://github.com/RefugeRestrooms/refugerestrooms/blob/update-Dockerfile/Dockerfile
The charts in the previous two comments are updated to show how it stacks up.
This is the second-fastest build time I've recorded out of the various Dockerfile configurations, at 7 minutes and 48 seconds. (Behind only the Alpine Linux-based image for Ruby 2.5.3.)
And it produces the third-smallest image in terms of disk space, at 827 MB. (Again, behind only the two Alpine Linux-based images.)
It still uses a larger base image than Alpine, though, at 179 MB for ruby-2.5.3-slim
, vs 94.4 MB for 2.3.7-alpine3.7
or 45.5MB for 2.5.3-alpine3.7
. So it presumably takes a bit longer to download on slow or intermittent networks, or uses a bit more of a limited data plan.
I would say the slim (debian-based) image is fine, especially with the improved Dockerfile in update-Dockerfile
, but the Alpine image would be somewhat better for faster build speed, and for lower network usage. As long as it doesn't cause issues of some kind, and so far I haven't seen anything come up.
That said, Debian is still more familiar than Alpine, and I would find it more reassuring to work with. So there is that trade-off.
Edit: I re-ran the builds with a little more consistent approach. All the data are updated in the charts.
Scope / difficulty
Just need to update the
Dockerfile
. Some discussion beforehand for consensus would be great.Impact
Would make
docker-compose build
run faster, and maybe make things easier to maintain; Should help the Docker config be more readable and easier to work with. Makes dependencies more obvious and more apparent what things are for what purpose.Rationale
I realized while working on a branch that makes Vagrant usable (again, I'm not sure why I can't let go of Vagrant 🤷) that we can simplify the Docker script. A lot of
apt-get update
andapt-get install
in the script can be removed, now that we have the nodejs, phantomjs, and yarn install scripts that install most or all of those packages regardless.I also noticed @btyy77c's branch over at https://github.com/btyy77c/refugerestrooms/tree/dockerAlpine, that shows how much neater the script can get. I think we might want to ask for some of those things as a Pull Request, or get the okay to re-implement some of those changes. (Would want to give credit in the commit messages.)
Proposal
I think we should try some simplified
Dockerfile
s and discuss which is the best direction to go.OR just make a pull request using some progress or improvements from the aforementioned branches:
How to actually do this:
Dockerfile
. See branches that are linked above for ideas.Dockerfile
very often, so I don't think that's a big issue.Dockerfile
as a pull request.OR