thecodingmachine / docker-images-php

A set of PHP Docker images
MIT License
768 stars 137 forks source link

Add libvips #365

Open uuf6429 opened 1 year ago

uuf6429 commented 1 year ago

I'm using libvips inside PHP over ext-ffi. The docker image already supports enabling FFI, however of course libvips is missing.

At the moment I'm enabling it with the following inside my docker-compose file:

    environment:
      STARTUP_COMMAND_1: sudo apt-get update && sudo apt-get install -y libvips

..but it would be nicer to have it by default in the 'fat' image.


For some context on the whole story, check https://stackoverflow.com/q/76416455/314056.

mistraloz commented 1 year ago

I can't take your request for instance but i keep it in the enchancement list for instance. Also, probably we will not implement custom extention (like libvips) for the fat images (we have to limit the size of the images). But we may imagine another command instead of "startup_command" (something like "init_command" to be run only at the first boot of the container).

PS: Personally, I looked for several options for image comparison and fell back on OpenCV through a python wrapper (not perfect for maintainability but very efficient : the only complexity is to save the image in filesystem, so i got some delay related and i had to implement lof of cache feature to limit that). I'm very curious about libvips capabilities.

uuf6429 commented 1 year ago

But we may imagine another command instead of "startup_command" (something like "init_command" to be run only at the first boot of the container).

The biggest problem (which is also totally not your fault) is that either way installation through apt-get is relatively slow because we always need to update(the indexes) first, and then there's also extra package dependencies. I've also had trouble in the past with apt-get in pipelines - from time to time their update services breaks (for a whole day, for example), causing us to be stuck until it's fixed.

In cases like this, the best solution is either a pre-built image or custom docker image. (I'm not trying to convince you, just stating the facts.)

Personally, I looked for several options for image comparison and fell back on OpenCV through a python wrapper

I was considering taking that approach by building a native php library in rust connecting to OpenCV. But in either case there are a lot of dependencies: rust+php-dev+opencv or php+python+opencv - plus, apparently opencv is quite heavy on dependencies itself (I had some minor trouble installing it in brew).

On the other hand, libvips was easier to set up: installing libvips, installing composer package, ensuring php has ffi enabled, done. Additionally, the code I got from their forum almost worked perfectly the first try and it felt incredibly fast.

That's just my personal experience.

keep it in the enchancement list for instance.

Fine with me! 👍