chore: parallel local dev — isolated WP instances per worktree - #128
Closed
dmytrobez wants to merge 177 commits into
Closed
chore: parallel local dev — isolated WP instances per worktree#128dmytrobez wants to merge 177 commits into
dmytrobez wants to merge 177 commits into
Conversation
Went from 26 vulnerabilities (5 moderate, 19 high, 2 critical) to 6 vulnerabilities (1 moderate, 5 high)
✨ feat: add multilang
get_site_url()/get_next_url() hosts are interpolated straight into the preg_match pattern that gates URL rewriting. On sub-path installs the host contains a slash (e.g. "localhost/us"), which is read as the regex delimiter, so PHP parses the remainder as modifiers and emits "preg_match(): Unknown modifier '|'" on every resolved URI field. Wrap both hosts in preg_quote(..., '/') so slashes and other regex-special characters are treated literally.
Infrastructure to run several isolated local WordPress instances in parallel (one per git worktree), so multiple people/agents can work side by side without port, database or container-name conflicts. - docker-compose.yml parameterized via env (PROJECT_CODE, WP_PORT, DB_PORT, WORDPRESS_URL, NEXT_URL); WP_HOME/WP_SITEURL follow the instance URL so a seeded DB works on any port. All vars are defaulted, so the default single-instance workflow is unchanged (:80, :3306, spck). - scripts/create-worktree.sh — detached worktree at ../<repo>-wtN plus a copy-on-write clone of the heavy gitignored dirs, then per-instance setup. - scripts/setup-instance.sh — generates per-instance wordpress/.env, wp-cli.local.yml and next/.env with free-port detection. - wordpress/scripts/db-snapshot.sh / db-seed.sh — copy DB + uploads from another checkout, with URL search-replace. Both refuse to touch a container owned by a different checkout, since PROJECT_CODE falls back to "spck" and every superstack-derived project shares that default. - wordpress/server/mu-plugins/dev-autologin.php — local-only auto-login, gated on DEV_AUTOLOGIN_SECRET (only set by local compose, so it is inert on staging/production). wordpress/.env is no longer tracked: setup-instance.sh writes it per instance, so keeping it in git meant every worktree carried a modified file holding a random auto-login secret. It is replaced by wordpress/.env.example, matching how next/.env is already handled, and docker-compose.yml now defaults THEME_NAME so compose still resolves without an .env file. start-wp.sh loads wordpress/.env when present; the existing compose environment already carries the vars provision.sh reads, so provisioning is unchanged for the default workflow.
dmytrobez
force-pushed
the
chore/parallel-local-dev
branch
from
August 3, 2026 13:30
1d12a4b to
38334a4
Compare
Author
|
Superseded by #129, which targets |
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.
What
Infrastructure to run several isolated local WordPress instances in parallel — one per git worktree — so multiple people (or agents) can work side by side without port / database / container-name conflicts.
wordpress/docker-compose.yml— parameterized via env (PROJECT_CODE,WP_PORT,DB_PORT,WORDPRESS_URL,NEXT_URL,DEV_AUTOLOGIN_SECRET). Each instance gets its own compose project name, ports, DB and containers;WP_HOME/WP_SITEURLfollow the instance URL so a seeded DB works on any port. Every var is defaulted — with no.env, behavior is identical to today (:80,:3306, projectspck).scripts/create-worktree.sh <n> [ref]— creates a detached worktree../<repo>-wt<n>, copy-on-write clones the heavy gitignored dirs (plugins,theme/static,theme/vendors,node_modules), then runs setup.scripts/setup-instance.sh <n>— generates per-instancewordpress/.env,wp-cli.local.yml,next/.envwith free-port detection.wordpress/scripts/db-snapshot.sh/db-seed.sh— export the main DB and seed an instance from it (URL search-replace + uploads rsync).wordpress/server/mu-plugins/dev-autologin.php— local-only auto-login helper.Guide:
docs/parallel-local-dev.md.Usage
Why it's safe on staging/production
DEV_AUTOLOGIN_SECRETis set — which only the localdocker-compose.ymldoes. It can't activate on a real server.wordpress/server/mu-plugins/.docker-compose.yml/start-wp.shchanges are local-dev only and fully backward-compatible (defaulted env), so the standard single-instance workflow is untouched.Provenance & adaptations
This was first built and used on a client project (
tipee.ch#33— ran 3 simultaneous instances / 13 concurrent editor sessions). Ported here to the starter and adapted to superstack conventions, rather than copied verbatim:THEME_NAME/WORDPRESS_PATH/WORDPRESS_ENVcompose env vars, the./uploadspath, and the${THEME_NAME:-superstack}default (the client fork had diverged on these).start-wp.shonly adds the per-instance.envloader — no-epassthrough, since superstack already passes those vars via the composeenvironment:block.db-seed.shuploads rsync targets superstack's./uploads(not the fork's.data/uploads).Status
Draft — not for merge yet. Opening for team review of the approach before it lands in the starter. Two spots worth a reviewer's eye: the
./uploadsseeding path and whether the auto-login mu-plugin belongs in the starter as-is.