-
Notifications
You must be signed in to change notification settings - Fork 5.9k
Smaller docker image for production? #4112
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
Comments
I feel like this was discussed once but I can't remember what we said 🤔 Do you remember? @code-asher @jawnsy It would be nice to see if we can optimize the size though. I haven't done that before, but would be curious to learn/help! |
I also feel like we might have talked about it but I do not recall any
specifics.
The reason we have the image we have now is because it is a familiar
environment for developers (Ubuntu with all the stuff you would expect
like curl).
Maybe what we can do is have a minimal image with code-server then
extend that to make our main image and you can choose which to
use. Unless we want to use something like Alpine for the smaller image
in which case it would need to be separate.
|
Related: #2488 |
I looked into this a little bit, and according to the Dive CI tool, we currently waste about 200MB due to adding some release package files that are subsequently deleted:
Unfortunately, There's some third-party commands like docker-squash that might be able to do this, but I don't think we'd want to introduce a tool like that to our build process. Also, since the image is 915MB, reducing it by 230MB still results in a ~680MB image. Other options are to look into UBI Micro or UBI Minimal images to have a smaller footprint, but these images are also much less usable from a development perspective due to fewer dependencies available. @nmaaiken Can you provide more detail on your use case, and why a smaller image helps for you? We could certainly consider adding an additional image type, but this entails some long-term maintenance cost on our end, since we have to keep building that image |
@jawnsy sorry for the delay on my side. |
Even though switching to alpine as a base would be great there's no real need to go this far. Switching to debian-slim as a base would give you almost the same base as ubuntu but it's much smaller. EDIT: I've checked ubuntu images now and they look also small so that is not the case. For some reason I remember them being much larger. |
There is at least one quick win I already successfully built locally. Replacing this:
with:
What this does is downloading only the relevant .deb file, install it, and remove it in the same Docker By the way: I hardcoded the version of code-server, but this could just as easily be an In general my tip would be to use as little separate |
I noticed this issue as well, and came up with a slightly different version of @PeterBennink's proposed fix: #5068 Instead of downloading the .deb package from Github during the build, I retained the current approach of copying the packages from the Also, it's worth noting that excluding these files causes a disproportionate reduction in the compressed size of the image, since .deb files are relatively incompressible. |
Hello,
is it possible to create a smaller docker image for production purposes?
I would be happy to make a contribution.
The text was updated successfully, but these errors were encountered: