Skip to content

Improve Docker build times by compiling PHP extensions in parallel - #315

Merged
clue merged 3 commits into
clue:mainfrom
clue-labs:parallel-build
Oct 29, 2026
Merged

clue merged 3 commits into
clue:mainfrom
clue-labs:parallel-build

Conversation

@clue

@clue clue commented Oct 29, 2026 •

Copy link
Copy Markdown
Owner

This changeset improves the Docker build times for our recommended Dockerfile by compiling the recommended ext-ev and ext-sockets extensions in parallel build stages instead of a single sequential RUN step. The build toolchain is also narrowed from twelve packages to five and named .phpize-deps, which is the name docker-php-ext-install looks for before installing and purging all ten $PHPIZE_DEPS itself.

build before after
production image on a 16-core workstation 21.0s 11.1s
production image on a CI runner 29s 23s

The workstation row is medians of five cold builds per variant, alternating between the two so host load cancels out, with base images pulled beforehand. Spreads were under half a second. The CI row is the Docker job's docker build step across real runs, 10 before spanning 26-41s and 5 after spanning 15-25s.

Along the way this drops the # syntax=docker/dockerfile:1 directive from both Dockerfile instructions, as nothing in them needs the external frontend and fetching it costs a serial registry round-trip on every build.

The resulting image is a strict subset of the previous one: the duplicate libev package is gone, as PECL's ev bundles and static-links its own copy and never linked the system one, along with the /tmp/pear build leftovers the old single-stage build shipped. ext-ev itself is unchanged, and the Dockerfile in our integration tests keeps following the documentation as before.

Builds on top of #297, #207, #156, #149, #136 and https://github.com/clue-engineering/gisthook/pull/129 (private)

@clue clue added the documentation Improvements or additions to documentation label Oct 29, 2026
@clue clue added this to the v0.18.0 milestone Oct 29, 2026
@clue
clue requested a balanced review from Copilot October 29, 2026 10:00

Copilot AI 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.

🟢 Approval recommended

No active review issues are recorded for the production Docker build changes.

No open issues 🎉

What changed in this PR

This PR speeds up the recommended production Docker build by separating dependency installation and PHP extension compilation into parallel stages, while keeping the integration Dockerfile aligned with the documentation.

Changes:

  • Build ext-ev and ext-sockets in separate stages using a smaller shared toolchain.
  • Copy compiled extensions into the runtime image without carrying over build tools or temporary files.
  • Remove the external Dockerfile syntax directive from both documented examples and integration Dockerfiles.
File Description
tests/​integration/​Dockerfile-production Mirrors the parallel extension builds and streamlined production image.
tests/​integration/​Dockerfile-basics Removes the external syntax directive.
docs/​best-practices/​deployment.md Documents the parallel production build and updates both Dockerfile examples.

Review effort: Balanced

@clue
clue merged commit 256e00d into clue:main Oct 29, 2026
75 checks passed
@clue
clue deleted the parallel-build branch October 29, 2026 10:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants