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

feat: reduce image size further #639

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft

Conversation

dhaustein
Copy link
Contributor

@dhaustein dhaustein commented Jan 4, 2024

Reduces the size of the resulting image to around 400 MB.

  • Uses multi-stage build process.
  • Python dependencies are packaged into one venv.
  • Java JRE is created custom, only keeping the modules Drools needs.
  • Both the venv and the JRE are copied to the second stage of the build based on stream9-minimal image to reduce the size even further.

Comparison with the original image:

$  buildah build --no-cache --tag localhost/ansible-rulebook:slim -f Dockerfile

$  podman images --format "table {{.Repository}}:{{.Tag}} {{.Size}}" | rg ansible-rulebook
31128877f949  localhost/ansible-rulebook:slim                  323 MB
5cbebc6a4a9b  localhost/ansible-rulebook:latest                702 MB

Note: When built with podman, the image size will be ~100 MB larger for some reason (despite buildah being used internally in podman-build), even with compression forced on.

Reduces the size of the resulting image to around 400 MB.
Uses multi-stage build process. Python dependencies are packaged into one venv. Java JRE is created custom, only keeping the modules Drools needs.
Both the venv and the JRE are copied to the second stage of the build based on stream9-minimal image to reduce the size even further.
@dhaustein dhaustein self-assigned this Jan 4, 2024
Dockerfile Outdated Show resolved Hide resolved
@dhaustein dhaustein requested a review from a team January 4, 2024 16:11
@dhaustein
Copy link
Contributor Author

dhaustein commented Jan 4, 2024

TODO

@dhaustein
Copy link
Contributor Author

@Alex-Izquierdo I remember you wanted to use python dependencies defined in the requirements file(s) instead of hard-coding them in the Dockerfile. I will want to move onto that in a future PR. Didn't want to mix that into this already big change.

Dockerfile Outdated Show resolved Hide resolved
@mkanoor
Copy link
Contributor

mkanoor commented Jan 8, 2024

@dhaustein I think we should also ensure that all the source plugins that we ship in ansible.eda collection work with the slim image and all dependencies are satisfied.

@dhaustein
Copy link
Contributor Author

@dhaustein I think we should also ensure that all the source plugins that we ship in ansible.eda collection work with the slim image and all dependencies are satisfied.

@mkanoor I don't understand what you mean 100% but do you simply mean that I should test the new image with the EDA test suite from https://github.com/ansible/eda-qa/ ?

@mkanoor
Copy link
Contributor

mkanoor commented Jan 9, 2024

@dhaustein I think we should also ensure that all the source plugins that we ship in ansible.eda collection work with the slim image and all dependencies are satisfied.

@mkanoor I don't understand what you mean 100% but do you simply mean that I should test the new image with the EDA test suite from https://github.com/ansible/eda-qa/ ?

@dhaustein @ttuffin Currently there are 15 source plugins that we support in ansible.eda collection, I am not sure if QE has tests that cover each and every source plugin that we have. Each of these plugins have dependencies on other python packages, which is defined in the collection requirements. Our DE that we built should support these 15 source plugins, if there is a package that is missing then the rulebook using our official ansible.eda collection source will fail. At the least I am thinking that we should have some basic tests for each of these source plugins. To test the sources we would need access to other cloud providers and I am not sure if that integration test is happening.

@dhaustein
Copy link
Contributor Author

@mkanoor Testing it with every plugin is a rather tall order and I am not sure the EDA test suite covers everything. But I will see what I can do.

@dhaustein
Copy link
Contributor Author

dhaustein commented Jan 10, 2024

@ansible/eda-maintainers Following up on the discussion from #638 what is the purpose of the image?

Is it a runtime image that provides decision environment + CLI or is it a dev image that others can extend and built upon? I don't think I can make it both while maintaining small size.

@ttuffin
Copy link
Contributor

ttuffin commented Jan 10, 2024

@mkanoor Testing it with every plugin is a rather tall order and I am not sure the EDA test suite covers everything. But I will see what I can do.

@mkanoor @dhaustein we have integration tests in the collection repository for this purpose, and a workflow that installs the dependencies and runs the tests. That said, we only have coverage for four of the source plugins so we definitely need to look at increasing the coverage there.

@ttuffin
Copy link
Contributor

ttuffin commented Jan 10, 2024

@dhaustein first and foremost it is a base DE + CLI, and since it's used in our CI pipelines we want to keep it as small as possible. Allowing for extensibility comes second to that, imo.

@Alex-Izquierdo
Copy link
Contributor

Hi @dhaustein the image is the base DE, which implicitly serves as an execution environment for the CLI. This makes it ideal for CI use, particularly for the eda-server. It's not intended for development purposes but rather for general usage. I believe that focusing on size, a reasonable requirement for a production-ready image, doesn't conflict with the goal of extensibility. Users can always build their own images if they have more complex or specific needs.

Regarding the tests for our plugins in the collection I don't think that the API test suite is the right place for it. All the plugins there should have integration tests with ansible-rulebook and the source repo is probably the ideal place for it, eventually we could use them to test this image as @mkanoor suggested. I don't think he is proposing a blocker for this PR, I think he just wants to make sure that the collection integrates well with the image or the CLI. We could just do a manual check for now, but I think it is an interesting milestone for later iterations. I believe we already have a ticket in our internal Jira for it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants