Skip to content

feat(project): unique COMPOSE_PROJECT_NAME in .env for Docker volumes#1252

Merged
Soner (shyim) merged 2 commits into
shopware:mainfrom
roboshyim:feat/unique-compose-project-name
Jul 27, 2026
Merged

feat(project): unique COMPOSE_PROJECT_NAME in .env for Docker volumes#1252
Soner (shyim) merged 2 commits into
shopware:mainfrom
roboshyim:feat/unique-compose-project-name

Conversation

@roboshyim

Copy link
Copy Markdown
Contributor

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 made system:is-installed succeed against stale DB data and skip the install wizard.

Changes

Area Behaviour
project create --docker Writes COMPOSE_PROJECT_NAME=sw-<basename>-<6hex> to host .env (not .env.local)
Non-docker create .env stays empty
Existing projects Unset → basename behaviour (backward compatible); already set → left alone
flexmigrator.MigrateEnv Keeps COMPOSE_PROJECT_NAME in the new empty .env when splitting flex env
Migration wizard → Docker EnsureComposeProjectName if missing

Compose still runs with Dir = projectRoot (devtui/compose.go) and picks up .env automatically — no -p / compose name: key required.

Tests

  • go test ./internal/shop/ ./internal/flexmigrator/ ./internal/devtui/ -run Migration…
  • Scaffold docker vs non-docker, uniqueness of same basename, flex preserve, Ensure* preserve/append

Checklist

  • project create --docker writes unique name to .env
  • Two creates with same folder name get different names
  • Non-docker does not require a project name
  • Tests for scaffold docker vs non-docker
  • Migration wizard path sets name if missing

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-commenter

Codecov Comments Bot (codecov-commenter) commented Jul 24, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 80.00000% with 14 lines in your changes missing coverage. Please review.
✅ Project coverage is 53.70%. Comparing base (3340b47) to head (bcf77fc).

Files with missing lines Patch % Lines
internal/shop/compose_project_name.go 83.33% 8 Missing ⚠️
internal/devtui/model_update.go 20.00% 4 Missing ⚠️
internal/flexmigrator/env.go 92.30% 1 Missing ⚠️
internal/shop/project_scaffold.go 75.00% 1 Missing ⚠️
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              
Flag Coverage Δ
go-test 53.70% <80.00%> (+0.06%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 .env empty for non-Docker scaffolds.
  • Preserve COMPOSE_PROJECT_NAME during flex env splitting (.env.env.local) by re-writing it into the new .env.
  • Ensure COMPOSE_PROJECT_NAME is 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.

Comment thread internal/shop/compose_project_name.go Outdated
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@shyim
Soner (shyim) merged commit d61df56 into shopware:main Jul 27, 2026
3 checks passed
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.

5 participants