fix(project): support running shopware-cli inside the docker dev container#1100
Open
bdgraue (bdgraue) wants to merge 2 commits into
Open
fix(project): support running shopware-cli inside the docker dev container#1100bdgraue (bdgraue) wants to merge 2 commits into
bdgraue (bdgraue) wants to merge 2 commits into
Conversation
… inside a container When shopware-cli itself runs inside a container (e.g. the docker-dev image, which ships the CLI but no docker binary), a type:docker environment cannot `docker compose exec` into anything: the first executor command fails with "docker: not found". Detect this case (container marker present, docker CLI absent) and fall back to local execution, since the container is itself the target environment. A host without docker keeps the DockerExecutor so it still fails with a clear error instead of silently running on the host. Refs shopware#1096 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Inside a container shopware-cli runs as the mapped host UID, which has no passwd entry, so HOME resolves to / and child tools fail with EACCES (npm cache /.npm, composer ~/.composer). Redirect HOME to a writable temp dir once at startup when it is unset or not writable, so every child process (executor npm/ composer/console and the verifier's direct npm/node calls) inherits it. Linux only; a no-op when HOME is already writable, so normal host usage is unchanged. Refs shopware#1096 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Member
|
Could you provide maybe an example shopware project or give access to an private one. I would like to further understand the setup 👀 |
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.
Follow-up to #1097, which made
project create --docker/project devwork for any host UID by running the containers as the calling user. This PR covers the remaining case: runningshopware-cliitself inside the dev container (directly, via an alias such asdocker compose exec web shopware-cli ..., or when the CLI is shipped in theghcr.io/shopware/docker-devimage).Problem
Two issues surface when the CLI runs inside the container:
docker-devimage ships nodockerCLI, but atype: dockerenvironment unconditionally builds aDockerExecutor. The first executor command (project storefront-buildrunsfeature:dump) then fails withdocker: not found— before any build step.HOMEresolves to/. npm (~/.npm) and composer (~/.composer) then fail withEACCES(e.g.mkdir /.npm).Changes
internal/executor/factory.go— atype: dockerenvironment falls back to local execution when running inside a container that has no docker CLI (detected via/.dockerenv//run/.containerenv+dockernot onPATH). The container is the target environment, so commands run locally. A host without docker keeps theDockerExecutor, so it still fails with a clear error instead of silently running on the host; a container with docker (dind) is unaffected.internal/system/home_linux.go+cmd/root.go— at startup, whenHOMEis unset or not writable, it is redirected to a writable temp dir, so every child process (the executor's npm/composer/console and the verifier's direct npm/node calls, which all inherit the process env) can write its caches. The writability check usesaccess(2)(no probe file is written, so shell completion stays side-effect free). Linux only; a no-op whenHOMEis already writable, so normal host and macOS/Windows usage is unchanged.Resulting behaviour
exec,HOME=/tmpfrom #1097)exec)Testing
EnsureWritableHome(keeps a writable HOME, redirects when unset/unwritable).gofmt,go vet,go build(linux/windows/darwin),golangci-lint run ./...andgo test ./...all pass.ghcr.io/shopware/docker-devimage as UID 1001: the CLI resolves to local execution (exec: php bin/console ..., nodocker: not found), redirectsHOMEto/tmp, and a realnpm installsucceeds.Refs #1096
🤖 Generated with Claude Code