chialab/docker-php

Bundle UNZIP package

Closed this issue · 6 comments

Hi, the most common way to install project nowadays is through composer, that for most of the distribution uses unzip to unpack the dependencies.

At the time of writing if fact I'm forced to do this everytime:

apt-get update && apt-get install -y unzip

May we bundle unzip natively in these docker images?

Hi @Slamdunk! First of all, I'd like to thank you for your interest in this project and the time you're taking to contribute to it.

Could you please provide a little more context? Which image tag are you using? Can you attach a sample composer.json and the command you're launching to this issue?

We actually have a couple of projects that are built on top of this image and install dependencies through Composer, yet never had the issue you described. Here is a sample Dockerfile: https://github.com/bedita/bedita/blob/4-cactus/Dockerfile

Maybe it's the fact that we're not launching Composer with --prefer-dist? 🤔

I'm sorry, unzip is not mandatory because in case isn't present, composer falls back to ZipArchive:

https://github.com/composer/composer/blob/ef46a8afa4f5d845befbc7be832432c4b30d6313/src/Composer/Downloader/ZipDownloader.php#L50-L57

But it is the preferred way because using system binaries is way faster than PHP functions.

Maybe we could try a performance benchmark between with and without the unzip package.

Oh, ok. I didn't know about this automatic fallback, so I assumed that everything was working normally. 😂

I'll be pushing a new branch shortly with the unzip package added as a runtime dependency… or if you wish to open a Pull Request, that would be very appreciated! We'll be then able to compare pros and cons of having an image with a larger footprint vs a quicker installation of packages.

Another option I'm thinking of is to install unzip only on chialab/php-dev images. Since chialab/php are meant for production[citation needed], benefits of having unzip binary would be seen only during the one-time installation of packages, thus maybe it's not quite worth it. On the other hand, chialab/php-dev are more likely to be used in local environments, thus the benefits of native binaries would be more sensible.

Sounds reasonable. Tomorrow I'll do some benchmark and in case I'll open a PR on dev.

Uau, on my systems disabling unzip module an benchamrking installation with everything else disabled (time composer.phar install --no-custom-installers --no-autoloader --no-scripts --no-suggest) gives me better performances 😮

I would never expect this, so I'm closing this issue. Sorry for opening an issue before testing 😳

Don't worry, it's totally ok! I learned something new, and I agree that benchmark results are rather counter-intuitive. 🙃I'll take some time to run benchmarks on an EC2 instance in the afternoon and to try to confirm your benchmark results.