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

Slimmer image #11

Merged
merged 2 commits into from
Apr 1, 2015
Merged

Slimmer image #11

merged 2 commits into from
Apr 1, 2015

Conversation

md5
Copy link
Contributor

@md5 md5 commented Mar 8, 2015

I was interested in trying out the odoo image today and found that it weighs in at almost a gigabyte!

I went through the Dockerfile and the resulting image and made a few changes that resulted in the image dropping from 914+ megabytes to svelte 750 megabytes (ahem):

REPOSITORY          TAG                 IMAGE ID            CREATED             VIRTUAL SIZE
odoo                diet                0ec6ca044a82        18 minutes ago      750.2 MB
odoo                latest              003d65c3385f        3 days ago          914.5 MB

Much of the remaining bulk is coming from the two deb packages that get installed, wkhtmltox and odoo.

In the case of wkhtmltox, it's a 121 megabyte package and contains these three beasts:

  3124 38760 -rwxr-xr-x   1 root     root     39689480 Feb 27 14:49 ./usr/local/bin/wkhtmltoimage
  3126 38844 -rwxr-xr-x   1 root     root     39773192 Feb 27 14:49 ./usr/local/bin/wkhtmltopdf
  3127 43980 -rwxr-xr-x   1 root     root     45034680 Feb 27 14:49 ./usr/local/lib/libwkhtmltox.so.0.12.1

Since you guys appear to be using only the wkhtmltopdf binary itself and it is not dynamically linked to libwkhtmltox.so.0.12.1, perhaps it would be possible to cut out another 80 megabytes by just including or building the static binary you need in this image.

The odoo package itself seems to get most of its 293 megabytes from the fact that a whole bunch of addons are included, along with all of their *.po translations. Not sure if you guys have more targeted *.deb packages available, but it would be nice to take an approach where there is an odoo metapackage that pulls in a bunch of smaller odoo-* packages to allow for a smaller installation based on the Debian packages.

@cecton
Copy link
Contributor

cecton commented Mar 16, 2015

This PR looks great to me too @aab-odoo . Thanks @md5

@cecton
Copy link
Contributor

cecton commented Mar 17, 2015

Since you guys appear to be using only the wkhtmltopdf binary itself and it is not dynamically linked to libwkhtmltox.so.0.12.1, perhaps it would be possible to cut out another 80 megabytes by just including or building the static binary you need in this image.

I'm sure @JKE-be could do that for us, despite he looks mean on his picture

@cecton
Copy link
Contributor

cecton commented Mar 17, 2015

The odoo package itself seems to get most of its 293 megabytes from the fact that a whole bunch of addons are included, along with all of their .po translations. Not sure if you guys have more targeted *.deb packages available, but it would be nice to take an approach where there is an odoo metapackage that pulls in a bunch of smaller odoo- packages to allow for a smaller installation based on the Debian packages.

To me it's a great idea but we cannot make this decision. Maybe @antonylesuisse could allow it.

@cecton
Copy link
Contributor

cecton commented Mar 17, 2015

I went through the Dockerfile and the resulting image and made a few changes that resulted in the image dropping from 914+ megabytes to svelte 750 megabytes (ahem)

I'm a bit scared that the not installed packages may be useful to Odoo in some way. Could you provide us a diff of the list of the installed packages? Thanks

@md5
Copy link
Contributor Author

md5 commented Mar 17, 2015

Sure. I should have some time later today to do that.

@md5
Copy link
Contributor Author

md5 commented Mar 17, 2015

I ended up just doing it now 👍

https://gist.github.com/md5/1435dbd8b617ab89bc1d

@md5
Copy link
Contributor Author

md5 commented Mar 17, 2015

Pulling in build-essential as a "recommends" is one of the big culprits.

I've seen confusion in the past about what build-essential actually is in Debian, so I'll quote the docs:

If you do not plan to build Debian packages, you don't need this package. Starting with dpkg (>= 1.14.18) this package is required for building Debian packages.

This package contains an informational list of packages which are considered essential for building Debian packages. This package also depends on the packages on that list, to make it easy to have the build-essential packages installed.

@md5
Copy link
Contributor Author

md5 commented Mar 17, 2015

BTW, I just rebased and force-pushed. Please have a look at that diff at your leisure.

@md5
Copy link
Contributor Author

md5 commented Mar 17, 2015

Also, let me know about whether npm is a runtime dependency or is just needed to install lessc. If it's only needed in some circumstances, I'd leave it up to derived images to add it permanently.

@antonylesuisse
Copy link

LGTM, @sle-odoo does debian node-less works or do we need npm ?

aab commit to 8 please.

@sle-odoo
Copy link
Contributor

Hi,
We can rely on the Debian package node-less and remove the manual install of npm, less, less-plugin-clean-css and (hopefully) the symbolic link between /usr/bin/nodejs /usr/bin/node.

About splitting the Debian package in multiple lighter packages, in my opinion it's not a good idea. It was the case before (openerp-server, openerp-addons, openerp-web, ...) and was annoying to maintain. The current approach is good and minimize the differences between the way we develop on Odoo and the way we deploy it. Plus, it allow to fully use Odoo offline. Maybe we should create a package that will only use the apps platform to download the addons, but it's not on the to-do list right now.

About wkhtmltopdf, i suppose @cecton was willing to ping me. We are already using a custom build of the 0.12.1 version to enable support on Debian Jessie so i suppose we could extract from it only what we need if it's really worth it. I'll have a look.

Anyway, removing build-essential in this image is a great news. Thanks for this.

@md5
Copy link
Contributor Author

md5 commented Mar 19, 2015

OK. I pushed a commit to another branch that makes the node-less change: https://github.com/md5/docker-odoo/commit/a9a70ed6fb53e8c0d653c73edb4f6b05a50750b0

I can add it to this branch if you like, but I wanted to ask about less-plugin-clean-css before I did that, since I suspect the node-less package won't install it.

Here's the updated diff: https://gist.github.com/md5/1435dbd8b617ab89bc1d#file-diff-node-less-diff

Regarding whether or not to split into other packages, I definitely hear what your saying about the maintenance burden. Still, I hope you guys are able to somehow provide a slimmer download in the future. Despite the fact that people like to talk about how cheap bandwidth, storage, etc. are, it's still not good to waste them (cf. Jevons paradox). Downloading an extra 150+ megabytes per pull for no good reason adds up to a lot of wasted storage and bandwidth over time.

Edit: I shouldn't say "no good reason", since there is a good reason to have the addons (just not the unused wkhtmltopdf stuff).

@cecton
Copy link
Contributor

cecton commented Mar 19, 2015

@antonylesuisse just for the record:

Total size of the sources: 328MB
Only addons: 284MB
Median size of an addon: 352KB
Arithmetic average size of an: 1.08MB

Maybe we should consider to install nothing but the server and let the server download the addons automatically in ~/.local/Odoo/addons (or apps?).

( @sle-odoo yes actually I was thinking of you but for some reason I chose JKE (O_o) it's okay, I like the idea that a Belmont take care of this situation. Your experience will be of a great help here. Plus, you don't look mean on your picture. )

Best

@md5
Copy link
Contributor Author

md5 commented Mar 19, 2015

I don't have much of an opinion about how exactly you handle the packaging and/or download of addons, but in terms of the Docker image, I could see having an odoo:8.0 and an odoo:8.0-slim image. The slim image would be bare-bones and would expect an experienced integrator to add the necessary addons to achieve the required functionality.

@md5
Copy link
Contributor Author

md5 commented Mar 19, 2015

What do you guys think about merging this PR and dealing with the node-less stuff in a separate PR once the less-plugin-clean-css question is answered? 👍

@md5
Copy link
Contributor Author

md5 commented Mar 31, 2015

Hey guys. Any thoughts about whether this can be merged?

aab-odoo added a commit that referenced this pull request Apr 1, 2015
@aab-odoo aab-odoo merged commit d0cbb42 into odoo:master Apr 1, 2015
@aab-odoo
Copy link
Contributor

aab-odoo commented Apr 1, 2015

Hi.

Thanks for your contribution!

@md5 md5 deleted the slimmer-image branch April 1, 2015 13:28
@md5
Copy link
Contributor Author

md5 commented Apr 1, 2015

Glad to help! 👍

@blaggacao
Copy link

blaggacao commented Jun 5, 2016

Offtopic, sorry, @md5 have you any best practice / tools to distinguish buildtime from runtime dependencies or is it basically "going through the code" and "trial and error"?

Another thing is that a lot of space is wasted on the final py-pyc dichotomy. For most part of odoo core this only reveals itself on runtime and where it hasn't writing-rights to the source directory might slightly slow down the code interpretation. However as to pip modules, they clearly preserve the py files which basically doubles up their spaces. I'm very interested in ways to avoid this. I've seen that pip is denying a compile-distribute option as per open source ethics (ship the code along with the program) but in container times this is just obsolete...

We might continue discuss on this PR until something comes up in the form of a separate PR...

EDIT: with respect to the py-pyc I correct myself: It is only relevant if odoo is deployed via it's sources, don;t know if this is the case for the official debian package, I'm not using it. pip doesn't seem like a culprit here.

@blaggacao
Copy link

blaggacao commented Jun 6, 2016

A command I might share with you:

dpkg-query -W --showformat='${Installed-Size;10}\t${Package}\n' | sort -k1,1n

It shows the installed package sizes in ubuntu... Hunting for culprits.

EDIT:
Something I cannot judge properly on, but maybe someone else can say something about it's legitimacy...
apt-get purge $(dpkg-query -W --showformat='${Package}\n' | grep "\-dev")

@md5
Copy link
Contributor Author

md5 commented Jun 6, 2016

@blaggacao I've just done it through trial-and-error for the most part, but I did run across something interesting the alpine images recently where they scan the installed binaries under /usr/local with scanelf and determine which packages their dependencies are coming from: https://github.com/docker-library/ruby/blob/350b92c0d8324ad70d282539cfb1f5d7f2dd027e/Dockerfile-alpine.template#L57-L73

I imagine something similar could be done under Debian, possible with scanelf (from the pax-utils package) or with ldd.

In general, the *-dev packages are not needed after compilation, but their corresponding library packages usually are.

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

Successfully merging this pull request may close these issues.

6 participants