Skip to content

Give each checkout its own wp-env containers - #1131

Merged
donnchawp merged 1 commit into
trunkfrom
fix/wp-env-per-checkout
Dec 1, 2026
Merged

donnchawp merged 1 commit into
trunkfrom
fix/wp-env-per-checkout

Conversation

@donnchawp

Copy link
Copy Markdown
Contributor

The Makefile set COMPOSE_PROJECT_NAME=wp-super-cache on every wp-env call, so every checkout of the repo drove the same Docker containers. A review of the same setup in syntaxhighlighter (Automattic/syntaxhighlighter#322) caught it.

  • make up in a git worktree recreated the shared containers with the worktree's files mounted, and make destroy in either checkout deleted the other's database.
  • Plain npx wp-env commands, without the variable, couldn't see the containers that make started.

This drops the override, so wp-env names the containers after the checkout, which is its default. The .wp-env.json mapping already puts the plugin at wp-content/plugins/wp-super-cache, so the hardcoded paths in the Makefile still work from a worktree.

Before you pull this

Your existing containers are under the old wp-super-cache project name, and make won't see them after this. They keep running on 8888, so make up will fail on the port until you stop them:

COMPOSE_PROJECT_NAME=wp-super-cache npx wp-env stop

The new environment starts with a fresh database. If you want to keep the old site's content, export it with COMPOSE_PROJECT_NAME=wp-super-cache npx wp-env run cli wp db export first, then run COMPOSE_PROJECT_NAME=wp-super-cache npx wp-env destroy when you're done with it.

Testing

I ran WP_ENV_PORT=8894 WP_ENV_TESTS_PORT=8895 make test-integration in a worktree while the main checkout's site was running. The worktree got its own containers, all 53 integration tests passed, and the main checkout's containers were left alone.

The Makefile forced COMPOSE_PROJECT_NAME=wp-super-cache, so every checkout
and worktree drove the same containers. make up in a worktree recreated them
with the worktree's mounts, make destroy in one deleted the other's database,
and plain wp-env commands couldn't see the containers make started. Let
wp-env name the project after the checkout instead.
@donnchawp
donnchawp merged commit 7bce672 into trunk Dec 1, 2026
8 checks passed
@donnchawp
donnchawp deleted the fix/wp-env-per-checkout branch December 1, 2026 17:04
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.

1 participant