Skip to content

Add support for Wolfi-based images#1287

Draft
toabctl wants to merge 1 commit into
mlocati:masterfrom
toabctl:add-wolfi-support
Draft

Add support for Wolfi-based images#1287
toabctl wants to merge 1 commit into
mlocati:masterfrom
toabctl:add-wolfi-support

Conversation

@toabctl
Copy link
Copy Markdown

@toabctl toabctl commented May 5, 2026

Summary

Add support for Wolfi — an apk-based, rolling-release distribution maintained by Chainguard whose container images live under cgr.dev/.... Wolfi mostly follows alpine's upstream-source package naming, with a handful of well-known divergences this PR handles explicitly.

Strategy

For each EXT@alpine) block, decide what its wolfi twin should look like:

  1. Shared package names → POSIX | alternation. When alpine and wolfi use the same package names for an extension's deps (~67 of the existing entries: gd, redis, intl, opcache, mbstring, pdo_mysql, …), collapse to:

    EXT@alpine | EXT@wolfi)
        <shared body>
        ;;
    
  2. Different package names → separate EXT@wolfi) block with renames. Wolfi has the same library under a different name for ~15 deps:

    alpine wolfi
    enchant, enchant-dev enchant2, enchant2-dev
    geos, geos-dev geos-3.14, geos-3.14-dev
    imagemagick, imagemagick-dev imagemagick-7, imagemagick-7-dev
    judy, judy-dev libjudy, libjudy-dev
    lapack liblapack
    libbz2 libbz2-1
    libmemcached-libs libmemcached
    libsasl cyrus-sasl-libs
    lz4-libs liblz4-1
    maven maven-3.9
    openjdk8 openjdk-8-default-jdk
    postgresql-dev, postgresql-libs postgresql-17-dev, libpq-17
    python3, python3-dev python-3.13, python-3.13-dev
    vips, vips-dev libvips, libvips-dev
    zstd-libs libzstd1
  3. alpine-musl-only deps → silently dropped from wolfi twin. libexecinfo, libintl, bsd-compat-headers are needed only on alpine because of musl libc; glibc-based wolfi has equivalents built into libc. libvpx/libvpx-dev are only used by gd's PHP <= 5.6 path which isn't supported on wolfi anyway.

  4. No wolfi equivalent → no twin emitted. A few libs simply aren't packaged in wolfi: aspell-*, cassandra-cpp-driver, c-client, imap-dev, lua5.1-*, recode, tidyhtml. The corresponding extensions (pspell, cassandra, imap, luasandbox, recode, tidy) remain alpine-only — install-php-extensions will fail on wolfi for those, with the same "package not found" error pattern as any genuinely-missing dep.

setDistro() is unchanged — wolfi sets ID=wolfi in /etc/os-release and the rest of the script's distro-keyed lookups now have wolfi patterns.

Top-level switches

case "$DISTRO" in alpine) ... (apk update, simulate, virtual phpize-deps cleanup) and case "$DISTRO_VERSION" in alpine@*) ... (openssl variant, $PHPIZE_DEPS, icu-data) use plain alternation — their bodies don't reference per-extension package names.

Testing

Manually verified end-to-end on a Wolfi-based PHP image:

  • install-php-extensions gd redis resolves the right deps via apk on Wolfi (using the renamed names where applicable), runs phpize/configure/make against ZTS PHP, produces /usr/lib/php/modules/{gd,redis}.so with tsrm_get_ls_cache and tsrm_mutex_* references (ZTS-compatible).
  • extension=gd and extension=redis registered in $PHP_INI_DIR/conf.d/.
  • The runtime ZTS interpreter loads both extensions; imagecreatetruecolor/imagepng produces a valid PNG, and new Redis() instantiates correctly.
  • Both the bundled-source path (gd) and PECL path (redis) verified.

CI integration is not included in this PR — happy to add a wolfi build matrix entry if you'd like, just want to flag it as a separate question since it'd require deciding which Wolfi base image to test against.

Out of scope

  • No changes to existing alpine/debian behavior — every alpine pattern still matches.
  • Extensions whose deps aren't packaged in wolfi (pspell, cassandra, imap, luasandbox, recode, tidy) remain alpine-only.

Filed as a draft to invite feedback on the rename mappings and CI integration approach.

@toabctl toabctl force-pushed the add-wolfi-support branch from 1886717 to 8f9c382 Compare May 5, 2026 14:11
Wolfi (https://wolfi.dev) is an apk-based, rolling-release distribution
maintained by Chainguard. Its package names mostly follow alpine's
upstream-source naming, with a handful of well-known divergences this
patch handles explicitly.

Strategy:

  - Where alpine and wolfi share package names (~67 of the existing
    EXT@alpine entries), use POSIX `|` alternation:
        EXT@alpine | EXT@wolfi)
            <shared body>
            ;;
  - Where wolfi uses a different package name (e.g. enchant→enchant2,
    imagemagick→imagemagick-7, postgresql-libs→libpq-17, libsasl→
    cyrus-sasl-libs, vips→libvips), emit a separate EXT@wolfi case
    with the renamed packages.
  - For deps that are alpine-musl-only (libexecinfo, libintl,
    bsd-compat-headers) or only used on PHP <= 5.6 (libvpx), drop them
    from the wolfi twin — they're not needed on glibc-based wolfi.
  - For extensions whose deps simply aren't packaged in wolfi (cassandra,
    enchant<8.0, imap, luasandbox, pspell, recode, tidy), no wolfi twin
    is emitted; those extensions remain alpine-only.

Top-level `case "$DISTRO" in alpine) ...` and `case "$DISTRO_VERSION" in
alpine@*) ...` switches use alternation since their bodies don't
reference per-extension package names.

`setDistro()` is unchanged — wolfi sets `ID=wolfi` in /etc/os-release
and the rest of the script's distro-keyed lookups now have wolfi
patterns to match.

README updated to list Wolfi alongside Debian and Alpine.
@toabctl toabctl force-pushed the add-wolfi-support branch from 8f9c382 to eb36adb Compare May 5, 2026 14:44
@mlocati
Copy link
Copy Markdown
Owner

mlocati commented May 5, 2026

I won't accept this (but of course you can fork this project and do whatever you like: it's a MIT peoject)

@toabctl
Copy link
Copy Markdown
Author

toabctl commented May 5, 2026

I won't accept this (but of course you can fork this project and do whatever you like: it's a MIT peoject)

@mlocati why not? anything I can fix to get this accepted?

@mlocati
Copy link
Copy Markdown
Owner

mlocati commented May 5, 2026

Because there's a ton of custom images out there, this script is already rather complex, and some tests may already take 1 hour.

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.

2 participants