adoptium / installer

Installer scripts for Eclipse Temurin binaries
Apache License 2.0
144 stars 71 forks source link

Why is debian apt install so much larger than the JDK release binary? #940

Open dtanner opened 1 week ago

dtanner commented 1 week ago

Inspecting eclipse-temurin:17.0.11_9-jdk-jammy for example, the size of the layer that installs the JDK is 281 MB. This technique downloads the release binary.

I'm switching my FROM to be a different base image, so I originally wrote my Dockerfile to use apt to install the JDK, using the debian instructions, like this:

RUN wget -qO - https://packages.adoptium.net/artifactory/api/gpg/key/public | gpg --dearmor | tee /etc/apt/trusted.gpg.d/adoptium.gpg > /dev/null && \
    chmod o+r /etc/apt/trusted.gpg.d/adoptium.gpg && \
    echo "deb https://packages.adoptium.net/artifactory/deb $(awk -F= '/^VERSION_CODENAME/{print$2}' /etc/os-release) main" | tee /etc/apt/sources.list.d/adoptium.list && \
    apt-get update && \
    apt-get install -y temurin-${TEMURIN_TAG} && \
    apt-get clean

The issue is that this style adds 353 MB of space (an extra 72 MB). Is there a better way to use apt to install the JDK that will result in a layer size closer to the binary download style? Or would I need to switch to downloading the binary like the eclipse-temurin image does?

Thanks for any advice.

sxa commented 1 week ago

Good question. I don't think anyone on the team is investigated that but I expect it's pulling in a larger set of prerequisite packages form the system package repositories than our images have. For example you're probably getting at least the X11 (GUI) packages that are typically not required in a container (and aren't in our images). Related: https://github.com/adoptium/installer/issues/917

Also bear in mind that depending on your use case, if space is an issue then using a jlinked runtime to reduce the size further may also be appropriate (but again that would not be for use with our dpkg install).