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

docker: reduce ubi8 images size by using ubi8-minimal as base #12797

Merged
merged 2 commits into from
Apr 12, 2023

Conversation

jvidalallende
Copy link
Contributor

@jvidalallende jvidalallende commented Feb 13, 2023

This PR changes the base image from ubi-8 to ubi8-minimal, which has smaller size and a simpler package manager. By using this base image and properly cleaning caches, the final image size has been shrinked to about 65% of its original size, from 630MB to 400MB (note that comparison is done with ubi-8 building version 46eb7c8808 and ubi8-minimal building latest HEAD as of submitting this PR).

REPOSITORY     TAG                          IMAGE ID       CREATED          SIZE
frr            ubi8-minimal-cf2960e0df      b3c14b578f4d   15 minutes ago   400MB
frr            ubi-8-46eb7c8808             155a09c339b3   42 minutes ago   630MB

The ubi8-minimal Dockerfile also uses packages built from RHEL, as opposed to the previous ubi-8 Dockerfile which used packages built for CentOS.

@NetDEF-CI
Copy link
Collaborator

NetDEF-CI commented Feb 13, 2023

Continuous Integration Result: SUCCESSFUL

Continuous Integration Result: SUCCESSFUL

Congratulations, this patch passed basic tests

Tested-by: NetDEF / OpenSourceRouting.org CI System

CI System Testrun URL: https://ci1.netdef.org/browse/FRR-PULLREQ2-9643/

This is a comment from an automated CI system.
For questions and feedback in regards to this CI system, please feel free to email
Martin Winter - mwinter (at) opensourcerouting.org.

@qlyoung
Copy link
Member

qlyoung commented Feb 14, 2023

Thank you for the PR. Out of curiosity, are you using this image? If so, what for?

@jvidalallende
Copy link
Contributor Author

Thank you for the PR. Out of curiosity, are you using this image? If so, what for?

Hi! I'm part of the IBM team, perhaps you know some of my peers @rampxxxx @lynnemorrison .

We're using these images in our project, and found out that ubi8-minimal is a great fit as base image due to their small footprint but good curated set of default packages, including the microdnf package manager.

@ton31337
Copy link
Member

Why not use our maintained docker image built on top of Alpine?

@jvidalallende
Copy link
Contributor Author

Why not use our maintained docker image built on top of Alpine?

We have several services that we base on ubi8-minimal, and keep moving forward the base image as security fixes are released for them. Keeping the same base image simplifies our operations.

Also, we sometimes have private paches that we test before they get to upstream, or we base them just on stable versions (while upstream moves them to master), so we prefer to build our own image.

@qlyoung
Copy link
Member

qlyoung commented Feb 17, 2023

Thank for the info! The purpose of my questions is to find out who's using what images for what purpose. I'm not sure I fully understand a couple points in your response:

We have several services that we base on ubi8-minimal, and keep moving forward the base image as security fixes are released for them. Keeping the same base image simplifies our operations.

I understand this to mean that you have containers that you maintain that uses ubi8-minimal as a base image, and when the ubi8-minimal base image updates, you update your containers to use the updated base image. Correct? So when you say "Keeping the same base image simplifies our operations" you're referring to your experience with images that your team maintains. Or do you mean you have images that use the FRR images being modified here as a base image?

Also, we sometimes have private paches that we test before they get to upstream, or we base them just on stable versions (while upstream moves them to master), so we prefer to build our own image.

This part lost me - you're speaking of your experience with the images your team maintains, right? And saying that based on your good experience with ubi8-minimal in your team, you think it's a good fit for the images being modified in this PR?

I know this is a lot of questions but personally I'm not sure where these ubi8 images came from in the first place, and as I concern myself mostly with maintaining the docker images for this project these days, I'm gathering info.

@jvidalallende
Copy link
Contributor Author

I know this is a lot of questions but personally I'm not sure where these ubi8 images came from in the first place, and as I concern myself mostly with maintaining the docker images for this project these days, I'm gathering info.

No problem, that is fair and maybe I did not explain myself clearly.

I understand this to mean that you have containers that you maintain that uses ubi8-minimal as a base image, and when the ubi8-minimal base image updates, you update your containers to use the updated base image. Correct? So when you say "Keeping the same base image simplifies our operations" you're referring to your experience with images that your team maintains. Or do you mean you have images that use the FRR images being modified here as a base image?

Right, I refer to the images that we maintain, which are based on this very same Dockerfile. The Dockerfile takes the ubi8-minimal version as input, and builds on latest if it is not defined. We ususally prefer to pin versions of all our dependencies.

We have our private fork of FRR, which is quite close to upstream. Actually, now we are updating to use FRR 8.4.2 and the delta with upstream, except for some stuff to use our internal infrastructure, is just this PR. We build our FRR images, which are subsequently used as base images for another service.

Apart from this component, there are other services in our product that are also packaged as containers, and all of them use the same base image, this is why I meant by "simplifying our operations" when updating the base image.

Also, we sometimes have private paches that we test before they get to upstream, or we base them just on stable versions (while upstream moves them to master), so we prefer to build our own image.

This part lost me - you're speaking of your experience with the images your team maintains, right? And saying that based on your good experience with ubi8-minimal in your team, you think it's a good fit for the images being modified in this PR?

You are again on the right track, I am speaking about our own images, but they use this very same Dockerfile, verbatim. Initially we used ubi-8, but after looking on better optimizing the size of the images while keeping ease of use, we found out that ubi8-minimal was a better fit, providing smaller images while also having a nice and handy package manager.

We have been using ubi8-minimal images for some time (along with FRR 8.2.2). When we started the process to update to 8.4.2, we discovered that they did not properly build due to the requirement for librtr >= 0.8.0, so we modified them. And then comparing to what had been contributed, we saw that the ubi8-minimal patches had not been upstreamed, hence this PR.

I hope that I clarified your points now, if you have any further doubt don't hesitate on asking ;)

The builder for docker images based on ubi-8 images is broken, and it
generates docker images that are heavy and contain more artifacts than
they need to.

It also installs RPM packages from CentOS that, although seem to be
compatible with ubi-8, may diverge at some point (remember that CentOS
now does not track RHEL closely).

Signed-off-by: Juan Vidal Allende <juan.vidal1@ibm.com>
Docker image based on ubi8-minimal are smaller in size than previous
ones built with ubi8 as base. Also, due to proper cleanup of caches, the
final image is about 400MB in size (down from ~630MB using the older
ubi8 builder).

This Dockerfile also uses packages built for RHEL (instead of CentOS),
and updates dependencies so that it can compile latest FRR versions.

Signed-off-by: Juan Vidal Allende <juan.vidal1@ibm.com>
@jvidalallende jvidalallende force-pushed the ubi8_minimal_dockerfile branch from cf2960e to b964031 Compare February 20, 2023 11:21
@NetDEF-CI
Copy link
Collaborator

Continuous Integration Result: SUCCESSFUL

Congratulations, this patch passed basic tests

Tested-by: NetDEF / OpenSourceRouting.org CI System

CI System Testrun URL: https://ci1.netdef.org/browse/FRR-PULLREQ2-9787/

This is a comment from an automated CI system.
For questions and feedback in regards to this CI system, please feel free to email
Martin Winter - mwinter (at) opensourcerouting.org.

@jvidalallende jvidalallende changed the title docker: fix ubi-8 images and take ubi8-minimal as base docker: reduce ubi8 images size by using ubi8-minimal as base Feb 22, 2023
@jvidalallende
Copy link
Contributor Author

@qlyoung do you have any further questions or comments regarding this PR?

Is there anything that I can do to push it forward?

@jvidalallende
Copy link
Contributor Author

@qlyoung @ton31337 Is there anything that I can do to move this PR forward?

I would appreciate any feedback if there is anything to improve about it...

@qlyoung
Copy link
Member

qlyoung commented Apr 12, 2023

@jvidalallende Apologies for the delay here, I forgot to check in on this one.

@qlyoung qlyoung merged commit 9213d69 into FRRouting:master Apr 12, 2023
@qlyoung
Copy link
Member

qlyoung commented Apr 12, 2023

Sincerely apologize for the 2 month delay. I have all my Github notifications off otherwise I get way too many emails. It should never take this long. Thank you for the patch.

@jvidalallende
Copy link
Contributor Author

No problem, better late than never! Thanks for going through it!

@jvidalallende jvidalallende deleted the ubi8_minimal_dockerfile branch April 12, 2023 12:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants