frankenphp icon indicating copy to clipboard operation
frankenphp copied to clipboard

Docs: Why is Debian Recommended for Docker?

Open MarkusJLechner opened this issue 1 year ago • 6 comments

https://frankenphp.dev/docs/docker/

FrankenPHP Docker images are based on official PHP images. Debian and Alpine Linux variants are provided for popular architectures. Debian variants are recommended.

The headline states that Debian is recommended. Documentation should provide clarification rather than just statements; therefore, an explanation or reference supporting this recommendation should be included.

MarkusJLechner avatar Jul 26 '24 09:07 MarkusJLechner

That is a bit strange - as far as I'm aware, alpine is by far the most common in docker images. It would indeed be useful to know why debian is recommended instead.

nickchomey avatar Jul 26 '24 13:07 nickchomey

My 2¢ and why I don't recommend musl/alpine in production:

Multiple reasons, mostly due to musl implementation details breaking something in Go/PHP. Also, fwiw, the 'official php' images are managed by the community and aren't maintained by php, nor does PHP have any unit tests running on alpine (https://github.com/php/php-src/actions/runs/10094146717 for example).

Secondly, if you search the PHP issues, musl bugs are fixed rather quickly, but only once they are reported. There isn't any proactive hunting for those bugs.

And finally, many libraries (like openssl, for example) have to disable a bunch of failing tests for musl.

OH, and I almost forgot to mention the DNS shenanigans that happen on alpine php... if you haven't run into the "internet disappearing bug" yet, it's super confusing and was the straw that broke our back at work; when we moved to debian-only.

Personally, I wouldn't recommend it for production systems, just to shave a few dozen megabytes off an image size. If you absolutely need those megabytes, then go for it.

withinboredom avatar Jul 26 '24 20:07 withinboredom

It's also worth noting that this probably won't always be the case. Rereading that it sounds like doom-and-gloom, but it isn't that bad. It works most of the time, but when it doesn't work, it can be very frustrating.

withinboredom avatar Jul 26 '24 20:07 withinboredom

https://github.com/dunglas/frankenphp/issues/940

https://x.com/dunglas/status/1765738034782142699

sneycampos avatar Jul 29 '24 20:07 sneycampos

Thanks @sneycampos for the link. For those who don't have access to X, I'll post the comments here:

  • Q: Is that FrankenPHP related, or do you recommend the Debian images for PHP even without FrankenPHP? A: I recommend Debian with and without FrankenPHP! - @dunglas

  • Q: Do you have any performance numbers for using glibc? A: No, but musl can prevent enabling the JIT: https://github.com/dunglas/symfony-docker/issues/555 - @dunglas

  • Interesting. I also had issues with iconv on the Alpine distribution.

The mentioned issue https://github.com/dunglas/symfony-docker/issues/555 mostly explains why the documentation recommends Debian. The performance issue discussed on Stack Overflow may also be relevant to some users. @withinboredom's comment is also valuable.

Updating the docs or mentioning this issue could help others who encounter the same question why Debian is preferred. Since it's clear to me, I wouldn't mind closing this issue.

MarkusJLechner avatar Jul 30 '24 08:07 MarkusJLechner

A docs PR would be very welcome!

dunglas avatar Jul 30 '24 08:07 dunglas

just to shave a few dozen megabytes off an image size

  • 160Mb for Alpine dunglas/frankenphp:php8-alpine
  • 589MB for Debian dunglas/frankenphp:php8-bookworm

slightly more than "a few dozen" mega bytes, almost half a Gb! (429MB) difference - gulp

PhilETaylor avatar Dec 21 '24 01:12 PhilETaylor

(429MB) difference - gulp

That's 3 extra seconds to download on a gbit connection, and you only have to download it once. On a 10gbit connection, that's less than half a second. Like I said, if you need that less space due to running on edge devices like a pi, then that is what you optimize for.

withinboredom avatar Dec 21 '24 09:12 withinboredom

Not everyone has access to a 10gbit ... sure data centers might, but developers on the end of dialup might not, Developer experience counts too. I think sometimes we are so privileged with home/office internet speed in Europe/USA that we forget the rest of the world exists. And I say that as someone who lives on the island of Jersey, where we have the second fastest internet in the world, with fibre to the desk, but then when travelling (like today) Im on a hotel 2mbps connection...

And @sneycampos down thumbing me for stating the factual sizes of images from this project is just lame. I did not create the images, I just quoted their published sizes.

Anyway this is all off topic. The fact is using Debian is recommended for many good reasons, the trade-off is larger image sizes. Reducing Docker image sizes is crucial for streamlining development workflows, speeding up builds, and minimizing deployment times, all while saving valuable storage space. These are just the facts.

PhilETaylor avatar Dec 21 '24 15:12 PhilETaylor

The main blocker for recommending Alpine images in production is https://github.com/php/php-src/issues/13648. Laravel and many other tools use this function on the hot path.

Any help fixing this is very welcome.

dunglas avatar Dec 21 '24 16:12 dunglas