Skip to content

feat: build the utopia PHP extension into the image - #28

Open
ArnabChatterjee20k wants to merge 4 commits into
mainfrom
feat/utopia-extension
Open

ArnabChatterjee20k wants to merge 4 commits into
mainfrom
feat/utopia-extension

Conversation

@ArnabChatterjee20k

@ArnabChatterjee20k ArnabChatterjee20k commented Nov 23, 2026 •

Copy link
Copy Markdown

Issue

utopia-php/auth 0.13 gets its password hashes (Argon2, Bcrypt, Scrypt, …) from the utopia PHP extension (ext-utopia), a Rust extension built from the crates in appwrite/appwrite. Services built on utopia-base can't load it: no image ships it. That blocks reusing auth's password checking in those services, starting with the password challenge in utopia-php/abuse that Appwrite Edge will use.

Appwrite and Appwrite Cloud each build the extension in their own Dockerfile. Building it here gives every utopia-base service the same extension from one place.

Solution

  • New utopia stage: fetches only the Rust parts of appwrite/appwrite (Cargo.*, rust-toolchain.toml, .cargo, crates) at a pinned commit, with a sparse checkout and --filter=blob:none (about 6 MB instead of 483 MB), runs cargo build --release --locked -p utopia-extension, and copies utopia.so into the image. rustup takes the toolchain version from the checkout's rust-toolchain.toml, so there's no Rust version to keep in sync here.
  • Pinned like the other extensions: PHP_UTOPIA_VERSION in versions/*.env is 93cadfb0, the commit utopia-php/auth 0.13.0 was released from. Bump it with auth.
  • PHP 8.5 only. On 8.3 the crate doesn't compile (it uses ext-php-rs's is_lazy, 8.4+), and on 8.4 it compiles but doesn't load (it calls zend_undefined_method, which only PHP 8.5's engine exports). So versions/8.3.env and 8.4.env leave PHP_UTOPIA_VERSION empty, the stage builds nothing, and those images are unchanged. auth itself still declares PHP 8.3 support; filed as Packages requiring ext-utopia allow PHP < 8.5, but the extension only loads on PHP 8.5 appwrite/appwrite#15948.
  • Enabled in the final image through conf.d/utopia.ini. The final image already installs libheif and libwebp, which the extension links against, so no runtime packages are added.

Tests

The utopia checks live in tests-utopia.yaml; CI and make test run it on 8.5 only. It checks that the ini enables utopia.so, that php -m lists utopia, and that auth's Argon2 hashes a password, verifies it and rejects a wrong one (checked to fail when given the wrong password). tests.yaml is unchanged.

Built locally for PHP 8.5 (arm64): tests.yaml 23/23 and tests-utopia.yaml 3/3 pass. CI builds and tests every PHP version and architecture.

🤖 Generated with Claude Code

utopia-php/auth 0.13 gets its password hashes from the utopia extension
(ext-utopia), a Rust extension built from appwrite/appwrite's crates, and
services on utopia-base can't load it today. A new stage builds it at a
commit pinned in versions/*.env, like the other extensions; rustup takes
the toolchain from the checkout's rust-toolchain.toml. The final image
already has libheif and libwebp, which it links against.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@appwrite

appwrite Bot commented Nov 23, 2026 •

Copy link
Copy Markdown

Code review

Commit Status Tier Verdict Details
2508f60 Reviewed Reviewed 🟢 S · Ready to merge ✅ Approved View review

The incremental changes address both open findings, and I found no new issues in the updated fetch or Argon2 test.

Adds a pinned Rust build stage for the Utopia PHP extension on PHP 8.5 and installs the shared library with its INI configuration in the final image. PHP 8.3 and 8.4 remain unchanged, while CI and the Makefile run extension checks on PHP 8.5. The checks verify the module loads and Argon2 can hash a password and verify both matching and non-matching passwords.

Latest changes: The new commits use Git's blobless fetch for the sparse Appwrite checkout and replace the Argon2 class-presence check with a hash-and-verification test.

Walkthrough (7)
File Change
.github/workflows/ci.yml Runs the Utopia extension structure tests in PHP 8.5 CI jobs.
Dockerfile Builds the pinned Utopia Rust extension and installs it in the final image; the latest commit adds blobless fetching.
Makefile Runs the Utopia structure checks for PHP 8.5 local tests.
tests-utopia.yaml Checks the Utopia INI and loaded module, then exercises Argon2 hashing and verification.
versions/8.3.env Leaves the Utopia version unset for PHP 8.3.
versions/8.4.env Leaves the Utopia version unset for PHP 8.4.
versions/8.5.env Pins the Appwrite commit used to build the Utopia extension for PHP 8.5.
Fixed since the last review (2)
  • Filter the monorepo fetch to the sparse paths · Dockerfile:181
  • Test actual Argon2 hashing and verification · tests-utopia.yaml:17

Reviewed the commits since 5f2215b

Tip

Comment @appwrite review to re-run, or mention @appwrite with a question.

appwrite[bot]
appwrite Bot previously approved these changes Nov 23, 2026

@appwrite appwrite Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟢 Tier S · Looks good to merge. Summary

The extension's crate needs PHP 8.4 (it calls ext-php-rs's is_lazy, which
exists only for 8.4+), so the PHP 8.3 build failed. 8.3 now leaves
PHP_UTOPIA_VERSION empty and the stage builds nothing; the 8.3 image stays
as before. The utopia checks move to tests-utopia.yaml, which CI and
`make test` run on 8.4+.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
On PHP 8.4 the extension builds but doesn't load: it calls
zend_undefined_method, which only PHP 8.5's engine exports. Build and test
it on 8.5 only; the 8.3 and 8.4 images stay as before.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@ArnabChatterjee20k

Copy link
Copy Markdown
Author

@appwrite review

appwrite[bot]
appwrite Bot previously approved these changes Nov 23, 2026

@appwrite appwrite Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🔵 Tier A · Looks good to merge. Summary

Comment thread Dockerfile Resolved
Comment thread tests-utopia.yaml Resolved
The sparse checkout still fetched every file of the appwrite commit;
--filter=blob:none fetches only the checked-out ones (483 MB to 6 MB, same
files). The structure test now hashes a password and verifies the right and
a wrong one, instead of only checking that the class exists.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@appwrite appwrite Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟢 Tier S · Looks good to merge. Summary

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