-
Notifications
You must be signed in to change notification settings - Fork 314
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
ORT Docker image size - is it possible to make it smaller? #3230
Comments
When analyzing Android projects, unfortunately yes. While the Android plugin for Gradle is able to bootstrap several SDK components, the basic SDK needs to be installed even if just querying the dependencies of an Android project. But that said, the stock But I agree there still is general room for improvement. I was thinking about using Alpine as a base image also for the final image, or look into ways to dynamically install the Android SDK only when Android projects are analyzed. |
OK, I get it. Thank you for the explanation |
Let's keep this open to track the ideas for still reducing the size that I mentioned before. |
@sschuberth We are currently investigating implementing bootstrapping for Pub/Flutter, because according to research by @zhernovs the Flutter installation takes about 2GB of data in the Docker image. This would make the analyzer slower for Pub/Flutter projects of course, but they are relatively rare and users who heavily rely on those could still make their own Docker file that includes Flutter. Any objections to that approach? |
No objections. Just a question: As you know I was planning to remove bootstrapping for scanners. Would some of that logic still be valuable to keep in this context? |
Here are some particular numbers related to this topic: At the moment I did research uncompressed image from this Dockerfile weighs 3.91 GB. The biggest part of it is flutter: 1.5 GB. Built-in flutter/.pub-cache is 481 MB. So bootstrapping flutter will reduce docker image by almost 2 times. Compressed default image in gitlab registry: 1.78 GiB Time to start docker executor with default image: 1:29 Time to download, unpack, prepare flutter on resulting image: 01:16 For future, the second tool by size that might be optimized/bootstrapped is go (327 MB). Base image (adoptopenjdk:11-jre-hotspot-bionic 229 MB) could be replaced with something lighter (as an option adoptopenjdk/openjdk11:alpine-jre 149 MB), but this requires complete rewriting of Dockerfile if new image is based on Alpine (currently on Ubuntu). |
Maybe this also is yet another topic where Buildpacks as already mentioned here could help, also see https://github.com/paketo-buildpacks/gradle. |
Note to myself: To reduce the Docker image size we might want to take a look at https://github.com/docker-slim/docker-slim. |
Build ORT with Java 17 LTS to benefit from newer bytecode optimizations [1] and to get rid of the bogus "illegal reflective access" warning triggered by Retrofit which caused a lot of confusion [2]. While "Alpine is not in a supported release by OpenJDK" [3], eclipse-temurin [4] (which supersedes the deprecated adoptopenjdk [5]) does offer an Alpine image [6]. However, prefer to use the slightly larger "17-jdk-focal" image instead as that JDK image can also be easily used to *run* ORT in order to supersede #4178, so building and running ORT share the same image. At a later point, the effort to use "eclipse-temurin:17-jdk-alpine" for running (and building) ORT could be undertaken in order to reduce the Docker image size (see #3230). But installing all required tools and building ScanCode on Alpine could become difficult. [1]: #4912 [2]: https://github.com/oss-review-toolkit/ort/search?q=%22illegal+reflective+access%22&type=issues [3]: https://hub.docker.com/_/openjdk [4]: https://hub.docker.com/_/eclipse-temurin [5]: https://hub.docker.com/_/adoptopenjdk [6]: https://blog.adoptium.net/2021/09/eclipse-temurin-17-available/ Signed-off-by: Sebastian Schuberth <sebastian.schuberth@bosch.io>
Build ORT with Java 17 LTS to benefit from newer bytecode optimizations [1] and to get rid of the bogus "illegal reflective access" warning triggered by Retrofit which caused a lot of confusion [2]. While "Alpine is not in a supported release by OpenJDK" [3], eclipse-temurin [4] (which supersedes the deprecated adoptopenjdk [5]) does offers both JRE and JDK Alpine images [6]. However, use neither of them and instead prefer to use the slightly larger "17-jdk-focal" image instead as that JDK image can also be easily used to *run* ORT in order to supersede #4178, so building and running ORT share the same image. At a later point, the effort to use "eclipse-temurin:17-jdk-alpine" for running (and building) ORT could be undertaken in order to reduce the Docker image size (see #3230). But installing all required tools and building ScanCode on Alpine could become difficult. [1]: #4912 [2]: https://github.com/oss-review-toolkit/ort/search?q=%22illegal+reflective+access%22&type=issues [3]: https://hub.docker.com/_/openjdk [4]: https://hub.docker.com/_/eclipse-temurin [5]: https://hub.docker.com/_/adoptopenjdk [6]: https://blog.adoptium.net/2021/09/eclipse-temurin-17-available/ Signed-off-by: Sebastian Schuberth <sebastian.schuberth@bosch.io>
Build ORT with Java 17 LTS to benefit from newer bytecode optimizations [1] and to get rid of the bogus "illegal reflective access" warning triggered by Retrofit which caused a lot of confusion [2]. While "Alpine is not in a supported release by OpenJDK" [3], eclipse-temurin [4] (which supersedes the deprecated adoptopenjdk [5]) does offers both JRE and JDK Alpine images [6]. However, use neither of them and instead prefer to use the slightly larger "17-jdk-focal" image instead as that JDK image can also be easily used to *run* ORT in order to supersede #4178, so building and running ORT share the same image. At a later point, the effort to use "eclipse-temurin:17-jdk-alpine" for running (and building) ORT could be undertaken in order to reduce the Docker image size (see #3230). But installing all required tools and building ScanCode on Alpine could become difficult. [1]: #4912 [2]: https://github.com/oss-review-toolkit/ort/search?q=%22illegal+reflective+access%22&type=issues [3]: https://hub.docker.com/_/openjdk [4]: https://hub.docker.com/_/eclipse-temurin [5]: https://hub.docker.com/_/adoptopenjdk [6]: https://blog.adoptium.net/2021/09/eclipse-temurin-17-available/ Signed-off-by: Sebastian Schuberth <sebastian.schuberth@bosch.io>
Hello
Do you think it would be possible to decrease the size of the docker image (max to 2GB) - currently it's over 4GB
The image contains
Android SDK
- is this KIT (and maybe others) necessary for ORT to find the dependencies information?The current size of a docker image has a huge impact on the duration of the scanning proces.
I use this docker image in a gitlab pipeline with a group of shared runners. Each time a user triggers an action to pull the image it takes at least 3-5 minutes to complete the download.
It impacts unnecessarly network and energy consumption.
If it is not possible I could try ti reorganize my use case
The text was updated successfully, but these errors were encountered: