[Docker] Improve image size by fixing cleanup layer
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