drush icon indicating copy to clipboard operation
drush copied to clipboard

Minimize drush 8 phar size package

Open andypost opened this issue 2 years ago • 11 comments

Size could be minimized to ~25% I used to exclude files compose install --no-dev and then cleaned filed from drush.phar via php -dphar.readonly=0 /usr/bin/phar delete -f drush.phar -e $file script

Describe the solution you'd like Guess box packaging could exclude the same files and make next release smaller

$ ls -la drush*
-rw-r--r--    1 1000     1000       4697837 Oct  9 07:45 drush.phar
-rw-r--r--    1 1000     1000       6426331 Oct  9 03:09 drush.phar.bak

$ ls -lah drush*
-rw-r--r--    1 1000     1000        4.5M Oct  9 07:45 drush.phar
-rw-r--r--    1 1000     1000        6.1M Oct  9 03:09 drush.phar.bak

Describe alternatives you've considered Gonna polish script to drush8-minifier

Additional context Just used to try minimize docker container image and found that drush could be smaller

using php -dphar.readonly=0 $PHAR compress -c auto -f $DRUSH can make release compressed (gzip/bz) and it will be -rw-r--r-- 1 1000 1000 1.3M Oct 9 09:29 drush.phar

andypost avatar Oct 09 '21 09:10 andypost

Sounds like a good idea.

greg-1-anderson avatar Oct 09 '21 20:10 greg-1-anderson

@greg-1-anderson here's quick example It cuts > 26%

And if gzip used via phar ir makes x5 smaller, at least it greatly saves disk and a bit of carbon)

https://github.com/andypost/drush8-repacker

andypost avatar Oct 09 '21 23:10 andypost

It just needs to pass -d phar.readonly=0 to php

andypost avatar Oct 09 '21 23:10 andypost

Still not sure which kind of autoloader to use to optimize classloader

andypost avatar Oct 09 '21 23:10 andypost

https://github.com/box-project/box/blob/master/doc/configuration.md#excluding-dev-files-exclude-dev-files has setting to remove dev-files, also docs/examples are useless inside phar

andypost avatar Oct 10 '21 15:10 andypost

The option to reduce the PHAR size is using compactors. https://github.com/box-project/box/blob/master/doc/configuration.md#compactors-compactors

Chi-teck avatar Oct 14 '21 16:10 Chi-teck

Thank you, I will redo patch for config

andypost avatar Oct 14 '21 23:10 andypost

Somehow https://github.com/box-project/box/blob/master/doc/configuration.md#excluding-dev-files-exclude-dev-files is not enough to remove all dev dependencies

@Chi-teck is it ok to enable GZ compression? As I see php requires zlib (it can't be build without it) so this option looks safe /cc @greg-1-anderson

andypost avatar Oct 15 '21 02:10 andypost

I find dump-autoload useful too

andypost avatar Oct 15 '21 02:10 andypost

is it ok to enable GZ compression?

I don't know.

Chi-teck avatar Oct 15 '21 10:10 Chi-teck

I think it could be closed, maybe dump-autoload could be added but it needs to measure

andypost avatar Jan 28 '22 14:01 andypost