Skip to content

Commit f753238

Browse files
committed
fix(shell): make isolated controller fallback self-contained
1 parent c06a9e9 commit f753238

5 files changed

Lines changed: 34 additions & 2 deletions

File tree

docker-compose.api.isolated.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
services:
22
api:
3+
privileged: ${DOCKER_GIT_CONTROLLER_PRIVILEGED:-true}
34
environment:
45
DOCKER_GIT_PROJECT_DOCKER_HOST: ${DOCKER_GIT_PROJECT_DOCKER_HOST:-tcp://host.docker.internal:2375}
56
volumes: !override

docker-compose.isolated.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
services:
22
api:
3+
privileged: ${DOCKER_GIT_CONTROLLER_PRIVILEGED:-true}
34
environment:
45
DOCKER_GIT_PROJECT_DOCKER_HOST: ${DOCKER_GIT_PROJECT_DOCKER_HOST:-tcp://host.docker.internal:2375}
56
volumes: !override

packages/api/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ Optional env:
8181
- `DOCKER_GIT_API_PORT` (default: `3334`)
8282
- `DOCKER_GIT_DOCKER_RUNTIME` (default: `host`; set to `isolated` as an optional fallback to use an embedded controller daemon)
8383
- `DOCKER_GIT_CONTROLLER_DOCKER_HOST` (default: `unix:///var/run/docker.sock`; socket path inside the controller)
84-
- `DOCKER_GIT_CONTROLLER_PRIVILEGED` (default: `false`; set to `true` only when using `DOCKER_GIT_DOCKER_RUNTIME=isolated`)
84+
- `DOCKER_GIT_CONTROLLER_PRIVILEGED` (default: `false` in host mode; isolated overlays default it to `true` for the embedded Docker daemon)
8585
- `DOCKER_GIT_DOCKERD_TCP_HOST` (default: `tcp://0.0.0.0:2375`; reachable only inside Docker networks unless explicitly published)
8686
- `DOCKER_GIT_DOCKERD_DEFAULT_CGROUPNS_MODE` (default: `host`; keeps nested project containers compatible with cgroup v2 DinD)
8787
- `DOCKER_GIT_PROJECT_DOCKER_HOST` (default: empty in host mode; isolated mode defaults to `tcp://host.docker.internal:2375`)

packages/app/tests/docker-git/controller-resource-limits.test.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,12 @@ describe("controller compose resource limits", () => {
6969
"DOCKER_GIT_PROJECT_DOCKER_HOST: ${DOCKER_GIT_PROJECT_DOCKER_HOST:-tcp://host.docker.internal:2375}"
7070
)
7171
}))
72+
73+
it.effect("enables privileged controller mode for the embedded Docker daemon", () =>
74+
Effect.gen(function*(_) {
75+
const contents = yield* _(readComposeFile(composeFile))
76+
expect(contents).toContain("privileged: ${DOCKER_GIT_CONTROLLER_PRIVILEGED:-true}")
77+
}))
7278
})
7379
}
7480
})

scripts/e2e/_lib.sh

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -417,7 +417,31 @@ dg_project_ssh_to_container() {
417417
shift 2
418418

419419
if ! dg_has_project_docker_access; then
420-
"$local_ssh_command" "$@"
420+
local local_ssh_exit=0
421+
if "$local_ssh_command" "$@"; then
422+
return 0
423+
else
424+
local_ssh_exit=$?
425+
fi
426+
427+
if [[ "$local_ssh_exit" != "255" ]]; then
428+
return "$local_ssh_exit"
429+
fi
430+
431+
local local_container_ip
432+
local_container_ip="$(dg_project_container_ip "$container")"
433+
if [[ -z "$local_container_ip" ]]; then
434+
return "$local_ssh_exit"
435+
fi
436+
437+
local local_identity_arg=""
438+
local_identity_arg="$(dg_find_ssh_identity_arg "$@" || true)"
439+
local local_rewritten=()
440+
while IFS= read -r -d '' arg; do
441+
local_rewritten+=("$arg")
442+
done < <(dg_rewrite_ssh_args_for_project_container "$local_container_ip" "$local_identity_arg" "$@")
443+
444+
"$local_ssh_command" "${local_rewritten[@]}"
421445
return
422446
fi
423447

0 commit comments

Comments
 (0)