Skip to content

Conversation

EtienneM
Copy link
Member

@EtienneM EtienneM commented Dec 27, 2022

I went through the PECL download statistics (https://pecl.php.net/package-stats.php) and tested a bunch of the packages from there. The PHP info is here: https://biniou.osc-fr1.scalingo.io/. Some of these packages are really old so I didn't tested them. I tried to find some packages that are still maintained:

Fix #249

@EtienneM EtienneM self-assigned this Dec 27, 2022
@EtienneM EtienneM force-pushed the fix/249/pecl_extensions branch 24 times, most recently from a0a3461 to 34e3873 Compare December 28, 2022 12:49
lib/composer Outdated
install_pecl_extension $ext "$ext_version" "$CACHE_DIR" | indent
fi

# TODO I don't think this instruction should be executed for all extensions
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I still have a question about this instruction. But the question also stands for the script version on master.. Do you know its purpose?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is more a question for @Soulou right ?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should try to remove it and see if all extensions we're officially supporting in our doc are building as expected.

I assume that some extensions will fail, since it requires external libs that we are packaging.

My guts feeling on this is that:

  • All extensions which are not pre-packaged by us currently which do not require another external library should enter this new standard process
  • All extensions which are installed automatically should keep being maintained.
    • But installing redis and mongodb doesn't really make sense it's not used that often, I would stop installing them automatically
    • APCU is a automatic code compilation caching optimization, we should keep installing it by default.
  • All extensions which are pre-packaged by us should keep using fetch_package, so we need to identify them:

[ KEEP] https://github.com/Scalingo/php-buildpack/blob/master/support/ext/amqp → PECL extension requiring external lib, we must keep supporting it

[KEEP] https://github.com/Scalingo/php-buildpack/blob/master/support/ext/apcu → PECL only, but should be automatically installed, so let's keep it fast by prebuilding it

[DROP] https://github.com/Scalingo/php-buildpack/blob/master/support/ext/apfd → PECL only, drop pre-packaging

[KEEP] https://github.com/Scalingo/php-buildpack/blob/master/support/ext/blackfire → Third party lib, we need to keep it

[DROP] https://github.com/Scalingo/php-buildpack/blob/master/support/ext/ds → PECL only, drop pre-packaging

[KEEP] https://github.com/Scalingo/php-buildpack/blob/master/support/ext/event → Requiring webp lib

[KEEP] https://github.com/Scalingo/php-buildpack/blob/master/support/ext/igbinary → Non PECL

[DROP] https://github.com/Scalingo/php-buildpack/blob/master/support/ext/imagick → PECL only

[KEEP] https://github.com/Scalingo/php-buildpack/blob/master/support/ext/lua → Requiring installation of LUA

[DROP] https://github.com/Scalingo/php-buildpack/blob/master/support/ext/mcrypt → PECL only

[KEEP] https://github.com/Scalingo/php-buildpack/blob/master/support/ext/memcached → External lib

[KEEP] https://github.com/Scalingo/php-buildpack/blob/master/support/ext/mongodb → External lib

[KEEP] https://github.com/Scalingo/php-buildpack/blob/master/support/ext/redis → External lib

@EtienneM is my analysis clear, does it match your point of view?

lib/pecl Outdated

pushd ${extension_name}-${version} > /dev/null
/app/vendor/php/bin/phpize > /dev/null
./configure --with-php-config=/app/vendor/php/bin/php-config --with-${extension_name}=${build_dir}/.apt/usr > /dev/null
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The problem is that the option --with-${extension_name} is not always useful, or may be named differently. How could we make this configurable? Via an environment variable?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think there's more: some extensions use the extension=whatever.so directive while some others use the zend_extension=whatever.so.

For now I planned to use a (rather uglyish) case statement to handle all this. But I wanted to discuss it also.

That was before the decision to first have infosec have a look at it.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no way to know if an extension need the zen_extension or the extension directive from PECL (i.e. xdebug needs a zen_extension directive but nothing is mentionned on the pecl repository). I think defining env variables to configure the --with-${extension_name} and the extension / zen_extension directives could be a solution to this

@Frzk
Copy link
Contributor

Frzk commented Jan 6, 2023

The fact that some extensions are really old has been raised in the original issue and it was agreed that we wouldn't care about it.

Yet, infosec was supposed to review all of them and give us a go.

@Frzk
Copy link
Contributor

Frzk commented Jan 6, 2023

We should also handle the case where there is something like this in the composer.json file:

{
  "require": {
    "ext-mongodb": "*",
    "ext-imagick": "*",
    ...
  }
}

The * meaning latest which is available here: https://pecl.php.net/get/$extension_name

@Frzk
Copy link
Contributor

Frzk commented Jan 6, 2023

FYI, support for the amqp extension has been added a few months ago through this script: https://github.com/Scalingo/php-buildpack/blob/master/support/ext/amqp

We'll have to decide if we rely on the apt-buildpack or on custom instructions to handle the dependencies of such extensions :)

@Soulou
Copy link
Member

Soulou commented Jan 27, 2023

└> git push bp master  
Enumerating objects: 5, done.
Counting objects: 100% (5/5), done.
Delta compression using up to 8 threads
Compressing objects: 100% (3/3), done.
Writing objects: 100% (3/3), 1.08 KiB | 1.08 MiB/s, done.
Total 3 (delta 1), reused 0 (delta 0), pack-reused 0

Your deployment has been queued and is going to start…
<-- Start deployment of test-bp-pecl -->
Fetching source code
Fetching deployment cache
-----> Cloning custom buildpack: https://github.com/Scalingo/php-buildpack#fix/249/pecl_extensions
-----> Bundling Nginx 1.22.1
Checksums match. Fetching from cache.
-----> Bundling PHP 8.1.13
Checksums match. Fetching from cache.
-----> Bundling platform default extensions
apcu
Checksums match. Fetching from cache.
phpredis
Checksums match. Fetching from cache.
mongodb
Checksums match. Fetching from cache.
-----> Vendoring Composer 2.5.1
Checksums match. Fetching Composer from cache.
-----> Bundling additional extensions
Installing PHP extension: amqp
Installing PHP extension: apfd
Installing PHP extension: calendar
Installing PECL extension ds version 1.4.0
Installing PHP extension: event
Installing PHP extension: ftp
Installing PHP extension: gmp
Installing PHP extension: igbinary
Installing PHP extension: imagick
Installing PHP extension: imap
Installing PHP extension: memcached
Installing dependencies for oci8: libaio-dev
Installing PECL extension oci8 version 3.2.1
Checksums match. Fetching from cache.
Installing PHP extension: sodium
Checksums match. Fetching from cache.
Installing PHP extension: tidy
-----> Installing application dependencies with Composer
No composer.lock file present. Updating dependencies to latest instead of installing from lock file. See https://getcomposer.org/install for more information.
Loading composer repositories with package information
Updating dependencies
Nothing to modify in lock file
Writing lock file
Installing dependencies from lock file
Nothing to install, update or remove
Generating optimized autoload files
-----> Setting up default configuration
-----> Vendoring binaries into slug

-----> cron.json detected, creating cron tasks
 Build complete, shipping your container...
 Waiting for your application to boot... 
<-- [URL] -->

@Soulou Soulou requested a review from SCedricThomas January 27, 2023 14:07
@Soulou
Copy link
Member

Soulou commented Jan 27, 2023

Screenshot from 2023-01-27 15-07-58

@Soulou
Copy link
Member

Soulou commented Jan 27, 2023

Tested with

scalingo-22 PHP 8.1 / 8.2
scalingo-20 PHP 7.4/8.0/8.1/8.2

All with success

@Soulou Soulou marked this pull request as ready for review January 27, 2023 14:48
Copy link
Contributor

@SCedricThomas SCedricThomas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If it is working with OCI8 LGTM

Copy link
Member Author

@EtienneM EtienneM left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I understand correctly, we have some kind of extra support for oci8 as it has been request by a CST customer, am I right? Other people would need to use the apt buildpack?

fetch_package "$base_url" "${engine}-${version}" "$location"
}

function has_package() {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

best practice: I'm not sure about what this function does. Maybe add a comment or rename it so that it's clearer? If I understand correctly it makes a HEAD request to our object storage to check if the given package exists, which means that we pre-compiled the extension, isn't it?

@guillaume-sc
Copy link

If I understand correctly, we have some kind of extra support for oci8 as it has been request by a CST customer, am I right? Other people would need to use the apt buildpack?

At the time of changing our approach from allow-listing specific extension, to support all extensions from PECL, our Product Management identified a customer lead requiring the availability of OCI8 PHP extension. The work was done to achieve both supporting PECL extensions, and ensuring the specific OCI8 extension would work. I currently lack the knowledge to comment whether this could have been achieved by using the apt buildpack, or not.

@Soulou
Copy link
Member

Soulou commented Feb 2, 2023

If I understand correctly, we have some kind of extra support for oci8 as it has been request by a CST customer, am I right? Other people would need to use the apt buildpack?

Yes you're right

@Soulou Soulou requested a review from Frzk February 2, 2023 09:12
Copy link
Contributor

@Frzk Frzk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM for a first version.
(some comments still need to be addressed IMHO :))

Co-authored-by: Étienne M. <EtienneM@users.noreply.github.com>
@Soulou
Copy link
Member

Soulou commented Feb 3, 2023

@Frzk you're right, I missed some from Étienne :-D

lib/composer Outdated
install_pecl_extension $ext "$ext_version" "$CACHE_DIR" | indent
fi

# TODO I don't think this instruction should be executed for all extensions
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should try to remove it and see if all extensions we're officially supporting in our doc are building as expected.

I assume that some extensions will fail, since it requires external libs that we are packaging.

My guts feeling on this is that:

  • All extensions which are not pre-packaged by us currently which do not require another external library should enter this new standard process
  • All extensions which are installed automatically should keep being maintained.
    • But installing redis and mongodb doesn't really make sense it's not used that often, I would stop installing them automatically
    • APCU is a automatic code compilation caching optimization, we should keep installing it by default.
  • All extensions which are pre-packaged by us should keep using fetch_package, so we need to identify them:

[ KEEP] https://github.com/Scalingo/php-buildpack/blob/master/support/ext/amqp → PECL extension requiring external lib, we must keep supporting it

[KEEP] https://github.com/Scalingo/php-buildpack/blob/master/support/ext/apcu → PECL only, but should be automatically installed, so let's keep it fast by prebuilding it

[DROP] https://github.com/Scalingo/php-buildpack/blob/master/support/ext/apfd → PECL only, drop pre-packaging

[KEEP] https://github.com/Scalingo/php-buildpack/blob/master/support/ext/blackfire → Third party lib, we need to keep it

[DROP] https://github.com/Scalingo/php-buildpack/blob/master/support/ext/ds → PECL only, drop pre-packaging

[KEEP] https://github.com/Scalingo/php-buildpack/blob/master/support/ext/event → Requiring webp lib

[KEEP] https://github.com/Scalingo/php-buildpack/blob/master/support/ext/igbinary → Non PECL

[DROP] https://github.com/Scalingo/php-buildpack/blob/master/support/ext/imagick → PECL only

[KEEP] https://github.com/Scalingo/php-buildpack/blob/master/support/ext/lua → Requiring installation of LUA

[DROP] https://github.com/Scalingo/php-buildpack/blob/master/support/ext/mcrypt → PECL only

[KEEP] https://github.com/Scalingo/php-buildpack/blob/master/support/ext/memcached → External lib

[KEEP] https://github.com/Scalingo/php-buildpack/blob/master/support/ext/mongodb → External lib

[KEEP] https://github.com/Scalingo/php-buildpack/blob/master/support/ext/redis → External lib

@EtienneM is my analysis clear, does it match your point of view?

@Soulou Soulou merged commit 3a3283d into master Feb 3, 2023
@Soulou Soulou deleted the fix/249/pecl_extensions branch February 3, 2023 13:30
This was referenced Sep 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[PECL Extension] Support all PECL extensions

7 participants