openlibrary icon indicating copy to clipboard operation
openlibrary copied to clipboard

Use --no-install-recommends in dockerfiles

Open cdrini opened this issue 7 years ago • 6 comments

Anywhere we use apt-get install in our Dockerfiles, we should also add --no-install-recommends. According to https://ubuntu.com/blog/we-reduced-our-docker-images-by-60-with-no-install-recommends this creates smaller images which build faster. Note:

It is important to keep in mind that doing this could result in some missing libraries in your projects which you may have to add back explicitly, but this will ultimately give you more control in the dependencies in your project.

cdrini avatar Nov 19 '19 23:11 cdrini

Hey @guyjeangilles, It seems like a good fix. Can I work on it?

Kaushl2208 avatar Feb 11 '20 19:02 Kaushl2208

Go for it @Kaushl2208! :)

mekarpeles avatar Feb 12 '20 21:02 mekarpeles

If someone wants to try adding these tags and build new images + see if anything breaks, that would be a great fist step

mekarpeles avatar Jan 03 '23 20:01 mekarpeles

I realized I forgot to share my write up of trying this out on the two apt-get lines in docker/Dockerfile.olbase that currently lack --no-install-recommends. How embarrassing!

The short of it is that the savings were fairly modest.

Results of adding --no-install-recommends the first apt-get line (line 17 of Dockrefile.olbase)

Sizes

  • Before: <missing> 3 weeks ago /bin/sh -c apt-get -qq update && apt-get ins… 727MB
  • After : 5dcd206fa807 29 minutes ago /bin/sh -c apt-get -qq update && apt-get ins… 624MB

Site status

  • It seems to work.
  • Webpack appears to compile things properly. (docker-compose run --rm web npm run watch)
  • I can search for a book (Flatland), find it, and look at the entry.
  • I can also mark it as 'Want to Read', visit my reading log, see it, and find it there with a search for "flat*", etc.

Results of adding --no-install-recommends the apt-get install -y nodejs line (line 39 of Dockrefile.olbase)

Sizes

  • Before: <missing> 3 weeks ago /bin/sh -c apt-get update && apt-get install… 10.6MB
  • After : <missing> 7 minutes ago /bin/sh -c apt-get update && apt-get -y inst… 10.1MB

Site status

  • It seems to work.
  • Webpack appears to compile things properly. (docker-compose run --rm web npm run watch)
  • I can search for a book (Flatland), find it, and look at the entry.
  • I can also mark it as 'Want to Read', visit my reading log, see it, and find it there with a search for "flat*", etc.

APT packages

I also tried using the 'no-x' version of vim and emacs:

  • Without -nox on the editors: 606MB
  • With -nox 543MB

Total savings, including use of -nox versions of the editors: 166MB.

@mekarpeles

scottbarnes avatar Feb 11 '23 02:02 scottbarnes

can i work on this issue

Skyee90 avatar Mar 08 '26 16:03 Skyee90

Hi @scottbarnes @cdrini I’d like to pick up #2656. I’ll grep all Dockerfiles for apt-get install, add --no-install-recommends where missing, then build the dev/base images locally and share logs + a homepage screenshot as in RayBB’s note on #11904. OK to proceed?

modi02 avatar Mar 24 '26 00:03 modi02