buildah icon indicating copy to clipboard operation
buildah copied to clipboard

Reduce official buildah image size

Open isker opened this issue 5 months ago • 11 comments

λ docker image ls
REPOSITORY                       TAG       IMAGE ID       CREATED        SIZE
quay.io/buildah/stable           latest    26b3a6ab9362   14 hours ago   723MB
moby/buildkit                    latest    5946db68d29a   4 days ago     168MB
gcr.io/kaniko-project/executor   latest    967a3ff3beaa   2 weeks ago    66.4MB

The official buildah image hosted at https://quay.io/repository/buildah/stable is quite large, especially when compared to competitors. I took a quick look at the image, and, among other things, it includes a full distribution of python 3.12. The root filesystem is also ~160MB smaller than the image, which indicates that the image is being wastefully layered (BuildKit's root FS is only ~4MB smaller).

I think it ought to be possible for the image to be as small as BuildKit's, given that they notionally have a similar set of artifacts (go binary + qemu + ?).

As far as I can tell, there is no other officially supported way to pin to a fixed version of buildah than using this image. Distro packages will change over time, and the project offers no binary releases. So, the size of the image is unfortunate if you desire to "just use version X". In my case, I'd like to use buildah in a containerized CI environment.

isker avatar Feb 05 '24 06:02 isker

I tried to take a pass at this and was not able to get much in the way of results.

I switched to fedora-minimal to reduce the base image size, but the fedora buildah package somehow has a transitive dependency on python3, which seems wrong to me (debian manages to not have one), so there was not much actual gain to be had. The only viable option I can see within the confines of this project is to not update every installed package in the base image during the build. This results in a substantial improvement:

after                                       latest          4d80801ea0e6   6 seconds ago        583MB
before                                      latest          4a11898ab8ea   About a minute ago   728MB

isker avatar Feb 16 '24 04:02 isker

The Containerfile needs to use dnf for the installation which requires python3.

Open a PR to move the image to fedora-minamal, that should be easy to get in.

rhatdan avatar Feb 20 '24 18:02 rhatdan

I see. One wrinkle with the minimal image is that it only had dnf5 available. I am not aware of its significance but it seemed to be a drop in replacement as far as I could tell?

isker avatar Feb 20 '24 18:02 isker

Sounds good, open a PR and we can get this merged. Similar PR for podman would be appreciated.

rhatdan avatar Feb 20 '24 20:02 rhatdan

We could also look at eliminating languages and timezones if they are added.

rhatdan avatar Feb 20 '24 20:02 rhatdan

This looks like resolved.

flouthoc avatar Feb 21 '24 18:02 flouthoc

I disagree that it’s resolved, but it is beyond my ability as a casual contributor to improve it further.

isker avatar Feb 21 '24 18:02 isker

@isker My bad, just reopened this.

flouthoc avatar Feb 21 '24 19:02 flouthoc

A friendly reminder that this issue had no activity for 30 days.

github-actions[bot] avatar Mar 24 '24 00:03 github-actions[bot]

The image size is still an ugly.

cevich avatar Mar 25 '24 18:03 cevich

A friendly reminder that this issue had no activity for 30 days.

github-actions[bot] avatar Apr 25 '24 00:04 github-actions[bot]