test(docker): cover docker-ce-cli install and dind DOCKER_HOST fix

This commit is contained in:
opencode-agent 2026-08-02 00:46:04 +00:00
parent b80cf97787
commit 3493854649
2 changed files with 96 additions and 0 deletions

View file

@ -242,6 +242,39 @@ def test_dind_limits_unchanged():
assert "pids: 512" in dind_block 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__": if __name__ == "__main__":
import pytest import pytest

View file

@ -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__": if __name__ == "__main__":
import pytest import pytest