mkuf / prind

print in docker - Deploy a containerized Klipper Stack for your 3D Printer
GNU General Public License v3.0
341 stars 83 forks source link

Reduce klipper docker image size #44

Closed derlaft closed 1 year ago

derlaft commented 1 year ago

Hi,

There are a couple of issues making klipper image significantly larger than it should be:

Here you can remove .git folder after git checkout. This saves around 80M:

https://github.com/mkuf/prind/blob/82675ddf80fd1ad8009e407708cbc43c71cf0773/docker/klipper/Dockerfile#L9-L11

Here you can try using COPY --chown instead of a separate COPY and RUN chown. Otherwise all the files are duplicated in a new layer:

https://github.com/mkuf/prind/blob/82675ddf80fd1ad8009e407708cbc43c71cf0773/docker/klipper/Dockerfile#L23-L30

Those two simple changes should result in pull size reduction from ~720M to ~350M (for armv7).

I would have liked to created a platform, but I'm using that to try to run klipper on a machine without docker, so I don't have an easy way to test the changes....

mkuf commented 1 year ago

Hey there, thanks for reaching out.

I did some local builds on arm64 and could achieve these image sizes with your suggestions, this is really great. 😃

Image Size before Size after
klipper 852M 397M
moonraker 328M 269M
ustreamer 112M 98.1M

These changes are Implemented with https://github.com/mkuf/prind/commit/c43891deca7905b3b3ec80a5436d4b75f72fade4 and will be part of Release v1.3.0

-Markus