Skip to content

Make extension installation and enablement modular #41

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

weierophinney
Copy link
Member

This patch accomplishes three (related) things.

First, it now adds the mods-available directory to the container.

Second, it creates a "mods-install" directory with installation scripts for manually adding/compiling extensions, moving the previous one for installing swoole to the directory, and splitting out the one from the Dockerfile for enabling sqlsrv. Each script also moves the appropriate mods-available INI to the appropriate PHP version configuration directories. The Dockerfile now loops through the mods-install scripts, executing each, in a single build step.

Third, it splits out the logic for enabling extensions from the entrypoint script to a new /scripts/extensions.sh script. This will allow us to gradually add routines specific to enabling modules without convoluting the logic of the entrypoint further. It also makes it easier to see the logic specific to each extension, as each is encapsulated in a single function.

- Rename "scripts" directory to "mods-install"
- Add "install_sqlsrv.sh" script mimicing previous behavior in Dockerfile
- Copy over mods-install and mods-available directories to container
- Run every script in the mods-install/ directory

Signed-off-by: Matthew Weier O'Phinney <[email protected]>
- splits the section on extension enablement from the entrypoint script to a separate script
- call the extension enablement script from the entrypoint

Signed-off-by: Matthew Weier O'Phinney <[email protected]>
@weierophinney weierophinney added this to the 1.9.0 milestone May 26, 2021
local __result=$1
local PHP=$2
local EXTENSIONS=${@:3}
if [[ ! ${PHP} =~ (7.3|7.4|8.0) ]];then
Copy link
Member

Choose a reason for hiding this comment

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

I wonder if it would be possible to detect php versions automatically. adding 8.1 should not require us to change multiple files.

Copy link
Member Author

Choose a reason for hiding this comment

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

We need to do this manually. Extensions may or may not be updated to a particular ABI, so if we automatically enable for a new version, we may actually have errors when building the container due to extension compilation failure.

Consider this: MS only provides the sqlsrv binaries on Ubuntu 20.04 for 7.3, 7.4, and 8.0; we don't know if/when they'll have them available for 8.1. What if we build the day that 8.1 releases, and then this attempts to enable the extension for 8.1?

Similarly, many third-party extensions like Swoole take a few days to a few months to update. Automatically updating that list can lead to errors.

- Declare arrays
- Cast arrays to strings properly
- Double quote variables when passing as arguments

Signed-off-by: Matthew Weier O'Phinney <[email protected]>
Instead of checking for empty string.

Signed-off-by: Matthew Weier O'Phinney <[email protected]>
- Defines "match_in_array" function, which matches a needle against each other argument
- Strip whitespace from `$result` on completion of extension enablement; if empty, we cast the extension list to whitespace, and other wise use the value.

Signed-off-by: Matthew Weier O'Phinney <[email protected]>
@weierophinney
Copy link
Member Author

I've built locally and tested against the mezzio-swoole repo. Additionally, I've tested passing:

  • no extensions (phpunit fails, due to no swoole extension enabled!)
  • just swoole specified (success; no attempt to run apt or phpenmod)
  • swoole + one other extension (success - all extensions enabled)
  • swoole + more than one other extension (success - all extensions enabled)

@weierophinney weierophinney merged commit 971f183 into laminas:1.9.x May 26, 2021
@weierophinney weierophinney deleted the feature/extension-modularity branch May 26, 2021 20:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants