feat(project): unique COMPOSE_PROJECT_NAME in .env for Docker volumes#1252
Conversation
Docker Compose was deriving the project name from the directory basename, so deleting and recreating a same-named folder (or two projects sharing a basename) reused stale named volumes and skipped the install wizard. - Scaffold --docker writes COMPOSE_PROJECT_NAME=sw-<basename>-<hex> to host .env - Non-docker create still leaves .env empty - flexmigrator.MigrateEnv preserves COMPOSE_PROJECT_NAME in the new .env - Migration wizard ensuring Docker sets the variable when missing - Existing stacks with a name already set are left untouched Closes shopware#1251
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #1252 +/- ##
==========================================
+ Coverage 53.63% 53.70% +0.06%
==========================================
Files 303 304 +1
Lines 23325 23390 +65
==========================================
+ Hits 12511 12562 +51
- Misses 10787 10801 +14
Partials 27 27
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull request overview
This PR addresses Docker Compose named-volume collisions by introducing a unique, stable COMPOSE_PROJECT_NAME written to the host-side project .env for Docker-based Shopware projects. This prevents reusing stale volumes when a project directory is recreated with the same basename, avoiding false-positive “installed” detection and skipped install wizards.
Changes:
- Scaffold Docker projects with a unique
COMPOSE_PROJECT_NAME=sw-<basename>-<6hex>in.env; keep.envempty for non-Docker scaffolds. - Preserve
COMPOSE_PROJECT_NAMEduring flex env splitting (.env→.env.local) by re-writing it into the new.env. - Ensure
COMPOSE_PROJECT_NAMEis present when saving the devtui migration wizard configuration (without overwriting existing values).
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| internal/shop/project_scaffold.go | Writes initial .env content via EnvFileContent, enabling unique Compose names for Docker scaffolds. |
| internal/shop/project_scaffold_test.go | Adds assertions for Docker vs non-Docker .env behavior and uniqueness across same-basename scaffolds. |
| internal/shop/compose_project_name.go | Introduces generation/extraction/ensure helpers for COMPOSE_PROJECT_NAME in host .env. |
| internal/shop/compose_project_name_test.go | Adds unit tests for name generation, .env content, extraction, and ensuring behavior. |
| internal/flexmigrator/env.go | Preserves COMPOSE_PROJECT_NAME in .env when splitting .env into .env.local. |
| internal/flexmigrator/env_test.go | Adds coverage ensuring COMPOSE_PROJECT_NAME survives flex env migration. |
| internal/devtui/model_update.go | Ensures .env has a Compose project name during migration wizard save flow. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Summary
Implements #1251.
Docker Compose was using the directory basename as the project name, so named volumes (
db-data, …) collided when a project folder was deleted and recreated with the same name (or two trees shared a basename). That madesystem:is-installedsucceed against stale DB data and skip the install wizard.Changes
project create --dockerCOMPOSE_PROJECT_NAME=sw-<basename>-<6hex>to host.env(not.env.local).envstays emptyflexmigrator.MigrateEnvCOMPOSE_PROJECT_NAMEin the new empty.envwhen splitting flex envEnsureComposeProjectNameif missingCompose still runs with
Dir = projectRoot(devtui/compose.go) and picks up.envautomatically — no-p/ composename:key required.Tests
go test ./internal/shop/ ./internal/flexmigrator/ ./internal/devtui/ -run Migration…Checklist
project create --dockerwrites unique name to.env