RefugeRestrooms / refugerestrooms

REFUGE restrooms indexes and maps safe restroom locations for trans, intersex, and gender nonconforming individuals.
http://www.refugerestrooms.org
GNU Affero General Public License v3.0
894 stars 261 forks source link

Simplify and streamline the Dockerfile #509

Closed DeeDeeG closed 5 years ago

DeeDeeG commented 6 years ago

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 and apt-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 Dockerfiles 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:

OR

DeeDeeG commented 6 years ago

Speed comparison (docker-compose build on Ubuntu):

Compared to...

DeeDeeG commented 6 years ago

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)
DeeDeeG commented 5 years ago

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.