ci: Reduce Fedora and Debian image sizes even more

Apply the approach from commit 354fdf2116 (ci: Reduce intermediate
docker layers and final image size, 2023-02-01) to more stages.

Also:

* Use cache (prefetch metadata and packages) to reduce network I/O
  and speedup image build.

* Use `tmpfs` to drop logs produced by the package manager.
24 files changed