-
-
Notifications
You must be signed in to change notification settings - Fork 20
Lazy-install Swoole/OpenSwoole extensions #107
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
Lazy-install Swoole/OpenSwoole extensions #107
Conversation
Instead of shipping them in the container, this patch modifies the workflow to instead detect when swoole or openswoole have been requested within the entrypoint, and then downloads a package for the given extension specific to the current PHP version. The package is extracted, and then `phpenmod` used to enable it. The goal here is to (a) reduce overall container size, (b) reduce build times for this container, and (c) result in faster container startup times. Signed-off-by: Matthew Weier O'Phinney <[email protected]>
…tempting to cast to array Bash's `readarray` will fail if a value is an empty string. As such, we need to test that the value returned from `jq` is not empty before attempting to create an array from it. Additionally, newlines can cause issues, so this adds logic to strip all newlines. Signed-off-by: Matthew Weier O'Phinney <[email protected]>
092e4b9
to
4ed650d
Compare
DRYs up the logic, and allows keeping the original function cleaner and more easily maintained. Signed-off-by: Matthew Weier O'Phinney <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
Note that this is a breaking change though, since we removed swoole.
May want to see which packages depend on it, and may be necessary to bump this to 2.x
? (not sure about it)
It's not removing it; it's just changing when the extension is installed. Even before, you had to indicate you wanted to enable it before it would be present in the runtime. With the change here, the capabilities are present when you need them, if you indicate you need the swoole extension to run a job. Basically, it moves installation to the time that it is enabled, which is exactly the same as it is for other extensions that are installable via apt. |
Also, note that in the description, I indicated that I've tested against mezzio/mezzio-swoole, which was the primary reason we included the extension. Works exactly as expected, and, in fact, the environment is ready to run the job faster than it had been before (I measured around 1-2 seconds faster in my runs locally). |
LGTM then :D 🚢 ? |
@boesing Should I cut the 1.22.0 release, or wait for the other improvements you're working on? I can also just merge now, and have you release when ready... |
Description
This patch modifies how the Swoole and OpenSwoole extensions are installed and enabled, with the goals of:
For some time now, we've been downloading a package that contains pre-built Swoole and OpenSwoole extensions for all PHP versions for which we provide the extension (currently 7.3 - 8.1).
That package is large (> 140MB), and inflates the size of the container needlessly for most CI runs.
I've updated the project that builds the extensions to build and package each extension individually, per PHP version.
This patch no longer installs these extensions by default, but instead moves the installation to when a build has requested the extension(s).
At that time, it retrieves the package for the extension and PHP version, extracts it, and then enables the extension.
I've tested locally, and in doing so, uncovered an issue with how we were unpacking "before_script" and "after_script" values from a job, (both of which were causing the
entrypoint.sh
to fail); I've fixed the issue, and verified that the new approach works by running CI jobs against a checkout of mezzio-swoole, using the following.(Substituting in different PHP versions and each of "swoole" and "openswoole".)
These tests all ran correctly.
I also ran against other repositories that do not use the extension, and these ran normally.