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

Reduce klipper docker image size #44

Closed
derlaft opened this issue Nov 30, 2022 · 1 comment
Closed

Reduce klipper docker image size #44

derlaft opened this issue Nov 30, 2022 · 1 comment

Comments

@derlaft
Copy link

derlaft commented Nov 30, 2022

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:

RUN git clone ${REPO} klipper \
&& cd klipper \
&& git checkout ${VERSION}

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:

COPY --from=build /opt/klipper ./klipper
COPY --from=build /opt/venv ./venv
RUN mkdir -p printer_data/run printer_data/gcodes printer_data/logs printer_data/config
RUN groupadd klipper --gid 1000 \
&& useradd klipper --uid 1000 --gid klipper \
&& usermod klipper --append --groups dialout \
&& chown -R klipper:klipper /opt/*

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
Copy link
Owner

mkuf commented Dec 1, 2022

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 c43891d and will be part of Release v1.3.0

-Markus

@mkuf mkuf closed this as completed Dec 1, 2022
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

No branches or pull requests

2 participants