Skip to content

Build swoole from source without stdext to unblock JIT#71

Merged
loks0n merged 3 commits intomainfrom
swoole-build
May 3, 2026
Merged

Build swoole from source without stdext to unblock JIT#71
loks0n merged 3 commits intomainfrom
swoole-build

Conversation

@loks0n
Copy link
Copy Markdown
Member

@loks0n loks0n commented May 3, 2026

Summary

  • Swap base image from phpswoole/swoole:6.2.0-php8.5-alpine to php:8.5-alpine (pinned by digest) and build swoole 6.2.0 from source without --enable-swoole-stdext. stdext registers user opcode handlers that opcache's JIT compatibility check rejects, silently forcing JIT off in downstream images. This change lets downstream re-enable JIT.
  • Swoole configure flags: drop --enable-swoole-ftp and --with-swoole-ssh2; add --enable-openssl/--with-openssl-dir=/usr and --enable-cares.
  • Bundled cleanup: parallel make -j"$(nproc)", /artifacts pattern eliminates PHP_BUILD_DATE coupling, drop apk upgrade (undermined digest pin), drop dead $TZ//etc/localtime lines, comment/style cleanup.

Test plan

  • docker build --target final -t appwrite/base:swoole-test . succeeds
  • php -r 'echo SWOOLE_VERSION;'6.2.0
  • nm -D swoole.so | grep stdext_minit → empty (stdext absent)
  • php -d opcache.enable_cli=1 -d opcache.jit=tracing -d opcache.jit_buffer_size=64M -r 'var_dump(opcache_get_status()["jit"]["enabled"]);'bool(true) (in final stage)
  • php --ri swoole confirms openssl => OpenSSL 3.5.6, c-ares => 1.34.6 are linked; no ftp/ssh2
  • Downstream image enables opcache + JIT and confirms boot-time logs show JIT active
  • CI tests (tests.yaml, tests-xdebug.yaml) pass against the rebuilt image

🤖 Generated with Claude Code

Swap base image from phpswoole/swoole (which forces --enable-swoole-stdext)
to php:8.5-alpine pinned by digest, and build swoole 6.2.0 in-tree without
stdext. stdext registers user opcode handlers (ZEND_INIT_METHOD_CALL etc.)
that opcache's JIT compatibility check rejects, forcing JIT off in
downstream images — this lets downstream re-enable JIT.

Swoole configure flags: drop --enable-swoole-ftp and --with-swoole-ssh2;
add --enable-openssl/--with-openssl-dir=/usr and --enable-cares.

Other changes bundled in:

- /artifacts pattern in each builder stage replaces hardcoded PHP_BUILD_DATE
  paths, so the Dockerfile no longer needs to know PHP's module-API date.
- Parallel make: make -j"\$(nproc)" everywhere, MAKEFLAGS for pecl,
  -j for docker-php-ext-install. Builds 4-8x faster on multi-core CI.
- Drop apk upgrade in both stages — undermines the digest pin. CVEs are
  patched by bumping the base digest deliberately.
- Drop dead $TZ/etc/localtime lines (TZ was never set, symlink was broken).
- docker-php-ext-install sockets moved to compile stage (build-time prereq
  for swoole; previously rebuilt in core-extensions).
- Comment + style cleanup across builder stages.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@greptile-apps
Copy link
Copy Markdown

greptile-apps Bot commented May 3, 2026

Greptile Summary

This PR swaps the pre-built phpswoole/swoole base for a digest-pinned php:8.5-alpine and compiles Swoole 6.2.0 from source omitting --enable-swoole-stdext, which allows downstream images to enable OPcache JIT. It also introduces a clean /artifacts multi-stage pattern, parallel make -j$(nproc) builds across all extension stages, and adds openssl + c-ares Swoole features while dropping ftp/ssh2.

Confidence Score: 5/5

Safe to merge; the Dockerfile refactor is well-structured with no logic errors, and the only finding is a P2 test-coverage gap for the new Swoole compile flags.

No P0 or P1 issues found. Runtime dependency chain for the newly-compiled Swoole (OpenSSL via base image, c-ares and brotli/zstd via explicit apk installs) is complete. Extension load ordering (sockets before swoole) is correct alphabetically. The /artifacts glob pattern has no naming collisions across stages. The single P2 comment is a test-coverage suggestion that doesn't affect correctness.

No files require special attention.

Important Files Changed

Filename Overview
Dockerfile Replaces pre-built phpswoole base with php:8.5-alpine (digest-pinned), builds Swoole 6.2.0 from source without --enable-swoole-stdext, and introduces a clean /artifacts multi-stage copy pattern with parallel make; no logic errors found
tests.yaml Bumps expected PHP version from 8.5.4 to 8.5.5 to match the newly pinned digest; no issues

Reviews (3): Last reviewed commit: "Bump container-structure PHP assertion t..." | Re-trigger Greptile

Comment thread Dockerfile
Comment thread Dockerfile
loks0n and others added 2 commits May 3, 2026 17:24
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
php:8.5-alpine ships 8.5.5; the old phpswoole base was on 8.5.4.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@loks0n loks0n merged commit ef0a066 into main May 3, 2026
11 checks passed
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.

1 participant