ddev / ddev

Docker-based local PHP+Node.js web development environments
https://ddev.com
Apache License 2.0
2.49k stars 589 forks source link

Trim a little fat off of ddev-webserver (locale) #5984

Open rfay opened 3 months ago

rfay commented 3 months ago

Is there an existing issue for this?

Is your feature request related to a problem?

ddev-webserver is large.

We can sometimes get rid of some of it.

The locale collection is particularly large when you use one of the docker image inspectors. We can probably use a lot less locales, or add needed locales as additional layers.

Describe your solution

Inspect the image and see if we can limit locales or other fat

Describe alternatives

No response

Additional context

No response

GuySartorelli commented 3 months ago

I wonder if there's a clean way to declare required locales as (either global or project) config, and pull in those locales as layers based on that?

rfay commented 3 months ago

We install the locales-all package, which results in 236MB uncompressed. I'm not sure why we install locales-all.

Although there are a number of tools around for studying these things, the easiest technique for me was to use tar.

docker save ddev/ddev-webserver:<tag> >~/tmp/ddev-webserver.tar
cd ~/tmp/ddev-webserver.tar
tar -xf ddev-webserver.tar
# Find the biggest blob
# Untar the biggest blob
# Examine the contents of the untarred blob for size using a filesystem explorer like OmniDiskSweeper or whatever

Other options include

rfay commented 3 months ago

locales-all was added in

I think it's clear we can't just remove it. And it would be a breaking change to change how locales are configured and used. But we could do it, would just have to provide completely new configuration, which might not be a bad thing. But it's not a quick fat-trimming exercise.

rfay commented 3 months ago

It's been a few years since I tried docker-slim (now slimtoolkit/slim), but I just tried it against the ddev-webserver. It reduced the size by 5x. But, like the last time I tried it, the image was then unusable. For example, during the build process we use groupadd in one of the extra layers. But... it had been removed by slim.

rfay commented 3 months ago

One thing I'm absolutely going to do: Write an FAQ about ddev-webserver size in the docs, explaining why it's big (because it's for developers, providing what they need). Probably add a tip-of-the-day about it. I definitely think the size needs to be viewed in terms of its value.

tyler36 commented 3 months ago

This would make a great developer training session; how to identify bloat and how to remove it.

rfay commented 3 months ago

I don't think we'll get to this in this release cycle, but it's a worthy piece of work and I've added it to the contributor training list.