fix(docker): set DEER_FLOW_ROOT for log commands (#4658)

* fix(docker): set DEER_FLOW_ROOT for log commands

* fix(docker): set root before restart

* docs(docker): clarify log command
This commit is contained in:
天魔 2026-08-04 22:45:10 +08:00 committed by GitHub
parent 1f792d0f4b
commit 276481371e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 31 additions and 0 deletions

View File

@ -112,6 +112,9 @@ make up / down # Build/stop the production Docker stack (browser at localhost:
make docker-start / docker-stop / docker-logs # Docker development environment
```
Docker log and restart commands resolve `DEER_FLOW_ROOT` from the current
checkout before invoking Compose, matching the start and stop commands.
Run `make help` for the full list.
**Per-module commands drive a single module** (run inside that module):

View File

@ -247,6 +247,7 @@ Use the table below as a practical starting point when choosing how to run DeerF
```bash
make docker-init # Pull sandbox image (only once or when image updates)
make docker-start # Start services (auto-detects sandbox mode from config.yaml)
make docker-logs # View logs
```
`make docker-start` starts `provisioner` only when `config.yaml` uses provisioner mode (`sandbox.use: deerflow.community.aio_sandbox:AioSandboxProvider` with `provisioner_url`).

View File

@ -104,3 +104,19 @@ sandbox:
""".strip()
assert _detect_mode_with_config(config) == "local"
@pytest.mark.parametrize("docker_command", ["logs --gateway", "restart"])
def test_compose_commands_set_deer_flow_root_before_compose(docker_command):
"""Log and restart commands should resolve mounts from the repository root."""
with tempfile.TemporaryDirectory() as tmpdir:
command = f"""
source '{SCRIPT_PATH}'
PROJECT_ROOT='{tmpdir}'
DOCKER_DIR='{tmpdir}'
COMPOSE_CMD=capture_compose
capture_compose() {{ test "${{DEER_FLOW_ROOT:-}}" = "$PROJECT_ROOT"; }}
unset DEER_FLOW_ROOT
{docker_command}
"""
subprocess.check_call([BASH_EXECUTABLE, "-lc", command])

View File

@ -282,6 +282,12 @@ start() {
# View Docker development logs
logs() {
local service=""
# DEER_FLOW_ROOT is referenced in docker-compose-dev.yaml; set it before
# reading logs so Compose does not resolve mounted paths from an empty root.
if [ -z "$DEER_FLOW_ROOT" ]; then
export DEER_FLOW_ROOT="$PROJECT_ROOT"
fi
case "$1" in
--frontend)
@ -333,6 +339,11 @@ stop() {
# Restart Docker development environment
restart() {
# DEER_FLOW_ROOT is referenced in docker-compose-dev.yaml; set it before
# restarting services so Compose resolves mounted paths from this checkout.
if [ -z "$DEER_FLOW_ROOT" ]; then
export DEER_FLOW_ROOT="$PROJECT_ROOT"
fi
echo "========================================"
echo " Restarting DeerFlow Docker Services"
echo "========================================"