[Docker] Improve image size by fixing cleanup layer #717

Open
opened 2022-08-06 16:02:42 +02:00 by nik · 4 comments
Owner

As detected by dive thanks to @debdolph, our Docker image is far too big. This happens because our cleanup step, which should uninstall build dependencies, does not work as expected due to the layered structure of the OCI container image.

The files are marked as deleted in the new layer, but the old layer containing the build dependencies is still part of the image.

There are two ways how this can be fixed:

  • Re-order the build to cleanup in the same step as installing the dependencies
  • Adding a fginal step that is based on another step before installign build dependencies, copying all relevant files from there
As detected by [dive](https://github.com/wagoodman/dive) thanks to @debdolph, our Docker image is far too big. This happens because our cleanup step, which should uninstall build dependencies, does not work as expected due to the layered structure of the OCI container image. The files are marked as deleted in the new layer, but the old layer containing the build dependencies is still part of the image. There are two ways how this can be fixed: * Re-order the build to cleanup in the same step as installing the dependencies * Adding a fginal step that is based on another step before installign build dependencies, copying all relevant files from there
Author
Owner

assigned to @nik

assigned to @nik
Author
Owner

created branch 717-docker-improve-image-size-by-fixing-cleanup-layer to address this issue

created branch [`717-docker-improve-image-size-by-fixing-cleanup-layer`](/AlekSIS/official/AlekSIS-Core/-/compare/master...717-docker-improve-image-size-by-fixing-cleanup-layer) to address this issue
Author
Owner

mentioned in merge request !2716

mentioned in merge request !2716
Author
Owner

The third option seems to be "just use BuildKit", which appears to be able to optimise away deleted files.

The third option seems to be "just use BuildKit", which appears to be able to optimise away deleted files.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
aleksis/AlekSIS-Core#717
No description provided.