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

Reduce Container Size #52

Merged

Conversation

razo7
Copy link
Member

@razo7 razo7 commented May 30, 2023

Drastically minimize container size (~1GB -> ~210MB):

  1. Cleaning temporary files after installing external packages - by usingclean all (see it also from container best practices-> Clean temporary files)
  2. Build the container in a multi-stage manner to exclude unneeded packages Golang, source files and .git from the final image.

Minimize container size by cleaning temporary files after installing external packages
@openshift-ci openshift-ci bot requested review from clobrano and slintes May 30, 2023 12:43
@slintes
Copy link
Member

slintes commented May 30, 2023

what about using a multi stage container build, so the resulting image doesn't contain Go, source files and .git?

@razo7
Copy link
Member Author

razo7 commented May 30, 2023

what about using a multi stage container build, so the resulting image doesn't contain Go, source files and .git?

That's definitely something I am keen of doing for not only removing the above redundant stuff, but to decrease the enormous size of the image (around 1 GB prior to this PR cleaning).

I haven't done it until now, since I have a problem of using a smaller base image and still be able to find and download the fence-agents-all package. But thinking again about it I think we can still add another base image for the purpose you have mentioned and deal with the fence-agents-all package problem afterwards (in a different PR).

What is the problem? In short I wanted to use UBI base image (or it's variants, such as ubi-minimal ), after building the FAR binary and with UBI try to install fence-agents-all package. Since this package is part of HighAvailability add-on repo, then we need to enable it in UBI so it could find the desired package. Enabling is easy, but having/adding this repo is the problem.

@slintes
Copy link
Member

slintes commented Jun 2, 2023

I haven't done it until now, since I have a problem of using a smaller base image

you can use the same image in both build steps. The final one will just not contain Go and sources / .git. I assume that will save a lot of space already with very low effort. You can look for a smaller base image later.

@razo7 razo7 changed the title Clean Temporary Files to Reduce Container Size Reduce Container Size Jun 4, 2023
@razo7
Copy link
Member Author

razo7 commented Jun 4, 2023

The final one will just not contain Go and sources / .git. I assume that will save a lot of space already with very low effort.

You are right, it did save ~640 MB, and the resulting image is ~210 MB. Still not as minimal as other Medik8s operators, but in a much better place than around 1 GB prior to this PR.

Minimize container size by excluding Golang, source files and .git from the final image
@openshift-ci
Copy link
Contributor

openshift-ci bot commented Jun 5, 2023

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: razo7, slintes

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-merge-robot openshift-merge-robot merged commit 79e62ab into medik8s:main Jun 5, 2023
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.

3 participants