Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simplify and streamline the Dockerfile #509

Closed
DeeDeeG opened this issue Oct 8, 2018 · 3 comments · Fixed by #586
Closed

Simplify and streamline the Dockerfile #509

DeeDeeG opened this issue Oct 8, 2018 · 3 comments · Fixed by #586

Comments

@DeeDeeG
Copy link
Contributor

DeeDeeG commented Oct 8, 2018

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

  • Same as above, but start with the pull request and discuss and potentially make changes from there.
@DeeDeeG
Copy link
Contributor Author

DeeDeeG commented Oct 8, 2018

Speed comparison (docker-compose build on Ubuntu):

  • After downloading the ruby 2.3.7base image, our develop branch built in 6 minutes (and 0 seconds) on my computer. @81bd2d0

Compared to...


* (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.)

@DeeDeeG
Copy link
Contributor Author

DeeDeeG commented Oct 8, 2018

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
Copy link
Contributor Author

DeeDeeG commented Jan 5, 2019

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant