From 7d1ef60f6fb812bac7840e002bca0a26ab28a475 Mon Sep 17 00:00:00 2001 From: Sergey <93754860+slaid098@users.noreply.github.com> Date: Sun, 2 Aug 2026 03:49:31 +0300 Subject: [PATCH] fix(docker): install docker-cli and fix DOCKER_HOST hostname (#223) * fix(docker): install docker-ce-cli and compose plugin in image * fix(docker): point DOCKER_HOST to resolvable dind service alias * test(docker): cover docker-ce-cli install and dind DOCKER_HOST fix --------- Co-authored-by: opencode-agent --- Dockerfile | 9 +++++- docker-compose.yml | 2 +- tests/test_docker_compose.py | 33 +++++++++++++++++++ tests/test_dockerfile.py | 63 ++++++++++++++++++++++++++++++++++++ 4 files changed, 105 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 7d1e77a..78db5f0 100644 --- a/Dockerfile +++ b/Dockerfile @@ -11,13 +11,20 @@ RUN apt-get update && apt-get install -y --no-install-recommends \ g++ \ chromium \ gnupg \ - docker.io \ ffmpeg \ ripgrep \ && rm -rf /var/lib/apt/lists/* RUN curl -LsSf https://astral.sh/uv/install.sh | UV_INSTALL_DIR=/usr/local/bin sh +RUN mkdir -p -m 0755 /etc/apt/keyrings \ + && curl -fsSL https://download.docker.com/linux/debian/gpg -o /etc/apt/keyrings/docker.asc \ + && chmod a+r /etc/apt/keyrings/docker.asc \ + && echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/debian trixie stable" | tee /etc/apt/sources.list.d/docker.list > /dev/null \ + && apt-get update \ + && apt-get install -y --no-install-recommends docker-ce-cli docker-compose-plugin \ + && rm -rf /var/lib/apt/lists/* + RUN mkdir -p -m 0755 /etc/apt/keyrings \ && curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg | gpg --dearmor -o /etc/apt/keyrings/githubcli-archive-keyring.gpg \ && chmod go+r /etc/apt/keyrings/githubcli-archive-keyring.gpg \ diff --git a/docker-compose.yml b/docker-compose.yml index 3fcd70a..355e71f 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -29,7 +29,7 @@ services: env_file: - .env environment: - - DOCKER_HOST=tcp://docker-dind:2375 + - DOCKER_HOST=tcp://dind:2375 - OPENCODE_CONFIG_DIR=/root/.config/opencode - OPENCODE_MEMORY_DIR=/root/.local/share/opencode/opencode-memory - DOCKER_CONTAINER=true diff --git a/tests/test_docker_compose.py b/tests/test_docker_compose.py index 58cf29a..fd55ed9 100644 --- a/tests/test_docker_compose.py +++ b/tests/test_docker_compose.py @@ -242,6 +242,39 @@ def test_dind_limits_unchanged(): assert "pids: 512" in dind_block +# ── DOCKER_HOST points to a resolvable name (issue #222 — fix unresolvable host) + + +def test_docker_host_uses_resolvable_name(): + """opencode ``DOCKER_HOST`` points to the dind service alias ``dind``. + + The compose service is named ``dind`` (``container_name: + opencode-docker-dind``). DNS inside the ``opencode_network`` resolves the + service name, so ``tcp://dind:2375`` works; the old ``tcp://docker-dind`` + referenced no existing name and never resolved. + """ + content = _compose_text() + assert "DOCKER_HOST=tcp://dind:2375" in content, ( + "docker-compose.yml opencode DOCKER_HOST must point to `tcp://dind:2375` " + "(compose service alias) — the old `docker-dind` name does not resolve " + "in opencode_network (issue #222)" + ) + + +def test_docker_host_old_name_removed(): + """Raw text check: ``docker-dind`` hostname is absent from DOCKER_HOST. + + The old ``tcp://docker-dind:2375`` referenced neither the compose service + name (``dind``) nor the container name (``opencode-docker-dind``) and + never resolved inside ``opencode_network``. + """ + content = _compose_text() + assert "DOCKER_HOST=tcp://docker-dind:2375" not in content, ( + "docker-compose.yml must not retain the unresolvable `docker-dind` " + "hostname in DOCKER_HOST (issue #222)" + ) + + if __name__ == "__main__": import pytest diff --git a/tests/test_dockerfile.py b/tests/test_dockerfile.py index a61729a..1bfa77c 100644 --- a/tests/test_dockerfile.py +++ b/tests/test_dockerfile.py @@ -112,6 +112,69 @@ def test_single_npm_install_line_has_kept_packages(): ) +# ── docker CLI install (issue #222 — docker-ce-cli + compose plugin) ───────── + + +def test_docker_io_removed_from_apt_install(): + """Dockerfile does NOT install the ``docker.io`` Debian metapackage. + + The ``docker.io`` package on trixie ships ``dockerd`` + ``docker-proxy`` + + ``docker-init`` but NOT the ``docker`` CLI binary. The opencode container + delegates to the external DinD service, so running a local daemon is dead + weight — only the CLI is needed. ``docker-ce-cli`` (official Docker APT + repo) provides ``/usr/bin/docker`` and matches DinD 29.6.2 (API 1.55). + """ + content = _dockerfile_text() + assert "docker.io" not in content, ( + "Dockerfile must NOT install `docker.io` — trixie ships no `docker` " + "CLI binary, only the daemon; install `docker-ce-cli` instead (issue #222)" + ) + + +def test_docker_ce_cli_installed(): + """Dockerfile installs ``docker-ce-cli`` from the official Docker APT repo. + + Provides ``/usr/bin/docker`` and matches DinD 29.6.2 (API 1.55). The + Debian ``docker.io`` package does NOT ship the CLI on trixie. + """ + content = _dockerfile_text() + assert "docker-ce-cli" in content, ( + "Dockerfile must install `docker-ce-cli` so `which docker` resolves to " + "/usr/bin/docker and `docker version` reaches the DinD server (issue #222)" + ) + + +def test_docker_compose_plugin_installed(): + """Dockerfile installs ``docker-compose-plugin`` (Compose v2 subcommand). + + The old Python ``docker-compose`` (v1) is NOT compatible. ``docker + compose`` (subcommand) requires the plugin, bundled with the official + Docker APT repo alongside ``docker-ce-cli``. + """ + content = _dockerfile_text() + assert "docker-compose-plugin" in content, ( + "Dockerfile must install `docker-compose-plugin` so `docker compose " + "version` prints v2.x (issue #222)" + ) + + +def test_docker_apt_repo_added(): + """Dockerfile adds the official Docker APT repository (``download.docker.com``). + + ``docker-ce-cli`` / ``docker-compose-plugin`` are not in the Debian + trixie default repos — the official Docker repo is required to match the + DinD version (29.6.2, API 1.55). + """ + content = _dockerfile_text() + assert "download.docker.com/linux/debian" in content, ( + "Dockerfile must add the official Docker APT repo (download.docker.com) " + "to install docker-ce-cli matching DinD 29.6.2 (issue #222)" + ) + assert "triex" not in content.replace("trixie", ""), ( + "Dockerfile Docker APT repo must target the trixie suite (matches base image)" + ) + + if __name__ == "__main__": import pytest