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

Huge image size #771

Open
welcoMattic opened this issue Mar 27, 2025 · 4 comments
Open

Huge image size #771

welcoMattic opened this issue Mar 27, 2025 · 4 comments

Comments

@welcoMattic
Copy link

I'm using symfony-docker to craft a new Symfony app, a basic one. I was suprised to see the size of the Docker image just after initiate the Symfony app: 864MB

Image

I'm using this base image: dunglas/frankenphp:1.4.4-php8.4, which is sized to 187.07 MB for linux/arm64 arch.

I'd need help to investigate to find the root cause of this inflate of the image and find ways to fix it, especially for the frankenphp_prod target.

cc @dunglas

@7-zete-7
Copy link
Contributor

Hi @welcoMattic!

You can try using the dive utility to determine at what step generates such image size?

@welcoMattic
Copy link
Author

After using dive to explore the layers of the image, here is the ouput:

Image

It looks like ~300MB come from this instruction:

RUN /bin/sh -c set -eux;     apt-get update;     apt-get install -y --no-install-recommends $PHPIZE_DEPS         ca-certificates         curl         xz-utils     ;     rm -rf /var/lib/apt /lists/* # buildkit

But it sized to 96.81 MB in Docker Hub (https://hub.docker.com/layers/dunglas/frankenphp/1-php8.3/images/sha256-e76ed20d7f9461e99d88985512dbb8b04a9332c8d2d4218dcf5a9fabbcf3f519 see layer 4)

@7-zete-7
Copy link
Contributor

<...>

It looks like ~300MB come from this instruction:

RUN /bin/sh -c set -eux;     apt-get update;     apt-get install -y --no-install-recommends $PHPIZE_DEPS         ca-certificates         curl         xz-utils     ;     rm -rf /var/lib/apt /lists/* # buildkit

But it sized to 96.81 MB in Docker Hub <...>

This difference in size between Docker Hub and dive data is due to the fact that Docker Hub shows the size of the compressed image (and its layers), while dive shows the size by file system.

However, this image only shows the layers of the dunglas/frankenphp image. Based on this information, it is difficult to say where the additional ~650MB comes from.

@welcoMattic
Copy link
Author

Yes, we realize the compression size on Hub side with @dunglas this afternoon.

However, I achieved to reduce the size by ~100MB by adding 2 stages for PHP extensions installation (base and dev).

We also realize that ~400MB stuff is due to the PHP base image and gcc installation.

I think the only way to get rid of that is to start FROM scratch and copy all the necessary compiled stuff. As docker team is not ok to remove gcc from their image.

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

No branches or pull requests

2 participants