Repository navigation
build: the images install the extension flake's build, through docker-bake.hcl - #24
Merged
Merged
Conversation
… docker-bake.hcl docker/Dockerfile no longer compiles the extension: every target installs restate.so for its PHP from the restate-extension context (docker/extension/install.sh). docker-bake.hcl builds each target per PHP minor and variant, and gives it the flake's module of the same PHP minor, thread safety and variant: built by extension/Dockerfile (Nix in a container), or with RESTATE_PHP_IMAGE_EXTENSION=host by the host's Nix, which CI uses to download it from restate-php.cachix.org. bin/build-image.sh is the one entry point for the recipes and workflows. Each PHP minor has base stages of its own (php-cli-8.5, frankenphp-8.5, php-fpm-8.5), which Dependabot updates and bake picks by name. RESTATE_PHP_TEST_PHP_VERSION chooses the suites' PHP minor, replacing the base image overrides. docs/decisions/0044-extension-modules-in-the-images.md has the decision and the measurements.
…ker inputs layer 0.3.0 passes the PHP headers and libclang through a setup hook instead of env, so a module's inputDerivation includes them (sagikazarmark/ext-php-rs.nix#9). moduleInputs is now the modules' inputDerivations instead of their drvAttrs. nixpkgs is unchanged; every module derivation changes once.
…ns and mkExtensionInputs The flake's matrix is buildRustPhpExtensions (sagikazarmark/ext-php-rs.nix#12), packages.pie the release variant through collectExtensions, and the Docker inputs layer mkExtensionInputs, which leaves the source out. The outputs are renamed to match: legacyPackages.extensions.<php>.<nts|zts>.<target>.<variant> and extension-inputs. extension/Dockerfile's inputs layer copies only what the flake evaluates them from, so .cargo/ and core/Cargo.toml no longer invalidate it.
An eachSystem helper builds packages, legacyPackages, checks and formatter from one function of the system, merged with the overlay (the one output that isn't per system, and the one that needs rustPhpPlatform as a function of the package set). The platform, the extension matrix, the PHP with the extension and FrankenPHP are evaluated once per system instead of once per output, and checks no longer read them back through self.packages. Every derivation is unchanged.
phps is the per-system list of PHP packages instead of attribute names every caller looked up in pkgs. The .phpt checks are keyed php84, … from each PHP's version, as buildRustPhpExtensions keys the extensions. Every derivation is unchanged.
extension/Dockerfile copies with COPY --parents and builds to nix build's default result link. The flake drops its description and the rust-overlay comment, and notes a TODO on following nixpkgs unstable.
…er/quickstart One file shared the stages that compiled the extension; with none left, each server's images go in its own directory, next to its configuration, with only its own base stages and one BASE_IMAGE argument. docker-bake.hcl's targets, tags and contexts are unchanged. bin/conformance-upstream-local.sh asks bake whether a target exists instead of grepping docker/Dockerfile, and Dependabot watches docker/*.
…tall script Each target copies restate.so from the restate-extension context and moves it into its PHP's extension_dir, which depends on the PHP version and thread safety, then enables it with docker-php-ext-enable (php-fpm: docker/fpm/php.ini) and checks that it loads. A missing context fails the COPY; a module for another PHP fails the load check. docker/extension/install.sh and its bind mounts are gone.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
The Docker images of the integration, load, soak, upstream and quickstart suites compiled the extension themselves, with rustup and Cargo cache mounts, while the PIE archives and Nix users' builds came from the extension flake. That's two builds of the same module to maintain, and CI's image jobs compiled it from scratch on every run.
Since #23, restate-php.cachix.org has the flake's builds for both CPUs, the debug and diagnostics builds the suites use included. With this PR the images install the flake's build instead of compiling their own, and CI downloads it.
Development keeps
just extension build(plain Cargo, incremental). An image build after a Rust change compiles the extension in about 30 s.docs/decisions/0044-extension-modules-in-the-images.md has the decision and the measurements.
What
docker/frankenphp/,docker/fpm/,docker/quickstart/. Each targetCOPY --fromsrestate.soout of arestate-extensioncontext into its PHP'sextension_dirand checks that it loads.docker/Dockerfile, its Rust stages anddocker/extension/build.share gone.docker-bake.hclbuilds them. Targets are<target>-<minor>-<variant>, e.g.frankenphp-extension-84-debug. Each image's context is the extension build of the same PHP minor, thread safety and variant, so the two can't disagree. PHP 8.6's official images are ZTS only, so their images get the ZTS build.extension/Dockerfile(the default): Nix in a container, cross-compiling. Its first layer fetches everything the builds need except the source (~1 GiB, kept until a lock file or the toolchain changes). It needs onlyextension/, so it goes with the split to ext-restate.RESTATE_PHP_IMAGE_EXTENSION=host: the host's Nix, handed to bake asEXTENSION_DIR. Every image-building workflow sets this, so runners download the build from Cachix and never build that layer.bin/build-image.sh [--php <minor>] [--variant <variant>] <target> <tag>is how the recipes, scripts and workflows build an image.frankenphp-8.5, …), which Dependabot updates; bake picks them by name.RESTATE_PHP_TEST_PHP_VERSIONreplacesRESTATE_PHP_TEST_FRANKENPHP_BASE_IMAGEandRESTATE_PHP_TEST_FPM_BASE_IMAGE.ci.yaml's hand-bumped FrankenPHP tags are gone.legacyPackages.extensions.<php>.<nts|zts>.<target>.<variant>(buildRustPhpExtensions) andextension-inputs(mkExtensionInputs);packages.pieis the release variant.eachSystem), andphpsis a list of packages. I checked every derivation (328 of them, overlay included) against the previous structure: unchanged.tests/justfile,tests/load/(the compose file no longer builds the endpoint),bin/conformance-upstream-local.sh(which asks bake whether a target exists),upstream.yaml(plain Nix and Cachix on the runner), the other workflows,dependabot.yaml(/docker/*,/extension).docker/README.md,TESTING.md,extension/README.md.Tested locally
just test integration frankenphpandnginx-fpm(--filter 'BasicServiceTest|ServingTest') pass.COPY(/restate.so: no such file or directory). An NTS image given a ZTS build fails its load check with PHP'sundefined symbolwarning.extension-inputsin place, the extension stage builds only the extension and fetches nothing.just lintandnix flake check --all-systems --no-build.Not verified
docker buildx bake, sobin/build-image.shdoesn't work with it (documented in 0044 andTESTING.md).Upstream issues filed along the way: sagikazarmark/ext-php-rs.nix#7 (compiled dependencies in their own derivation, not on our path), #9, #11 and #12 (fixed in 0.3.0 and 0.4.0).