Skip to content

feat(deploy): enable Docker-in-Docker by default - #61

Merged
zaytcevcom merged 5 commits into
mainfrom
duck/263043/enable-dind
Jul 20, 2026
Merged

feat(deploy): enable Docker-in-Docker by default#61
zaytcevcom merged 5 commits into
mainfrom
duck/263043/enable-dind

Conversation

@zaytcevcom

Copy link
Copy Markdown
Contributor

Summary

The bot's quality gate runs entirely through Docker: Taskfile.yml sets DEV_TOOLS: docker run --rm ... dev-tools and every lint/test/vet/build target shells through it. In deploys the bot container ships the docker CLI but no daemon, so task ci/lint/tests fail with "cannot connect to the Docker daemon". The privileged dind sidecar path already existed in the repo but was gated off by enable_dind: false. This turns it on by default (an isolated daemon — not the host socket), fixes the startup race, and adds buildx to the image.

Changes per acceptance criterion

  • AC1 — dind on by default: enable_dind: true in roles/claude_tg_bot/defaults/main.yml and the example inventory; the comment documents the opt-out for hosts that cannot run a privileged container.
  • AC2 — startup-race fix: the dind service gains a healthcheck (docker info readiness probe) and the bot gains depends_on: { dind: { condition: service_healthy } }, both inside the {% if enable_dind %} guards in the deploy template. The local docker-compose.yml gets the same healthcheck but no bot depends_on (there dind is behind profiles: ["dind"], so a hard dependency would force/break a normal docker compose up).
  • AC3 — buildx: docker-buildx-plugin appended to the existing docker apt install line in adapters/telegram/Dockerfile and adapters/vk/Dockerfile (no new apt source; removes the "legacy builder deprecated" warning, enables BuildKit).
  • AC4 — docs: both .env.example files and README.md note that deploys enable dind by default and the playbook injects DOCKER_HOST automatically.

How it was verified

The Docker-based task gate cannot run in the build environment (no daemon — the very thing this fixes; it is a host gate). Static verification performed:

  • Rendered docker-compose.yml.j2 for enable_dind true and false and validated each with docker compose config: true → dind service + healthcheck + bot depends_on: service_healthy + dind_storage volume; false → none of them (opt-out renders clean).
  • Local docker-compose.yml validated in default and --profile dind modes: bot has no depends_on, profiles: ["dind"] intact, healthcheck present.
  • Zero Go files touched.

Pre-PR review

One critic round on the local diff → APPROVE, risk low (clean round, zero blockers/majors). Confirmed: guards correct on both branches, docker info is a valid readiness probe for docker:27-dind with sane timings (10s/5s/5/30s), no host-socket exposure or isolation drop.

Residual risks — needs a human eyeball

  • Not run live: dind actually coming up healthy and the bot waiting correctly is a host/deploy check that could not run here. Confirm once on a real deploy that dind goes healthy within ~80s and the bot connects to tcp://dind:2375.
  • Host reboot: depends_on: service_healthy is honored by compose up, not by the engine's restart policy after a reboot — the bot may start before dind is healthy again; relies on app-level retry to DOCKER_HOST.
  • Fail-closed: on a host where dind cannot become healthy (privileged blocked, storage/kernel), the bot will not start — by design; such hosts must set enable_dind: false.
  • Stale translations: the 7 localized READMEs still describe dind as an optional --profile dind sidecar (out of this PR's scope; sync in a follow-up if desired).

zaytcevcom and others added 5 commits July 16, 2026 00:03
Turn the Docker-in-Docker sidecar on by default so the deployed team can run
its dockerized quality gate (task ci/lint/tests) out of the box. Flip the role
default and the example inventory to enable_dind: true; hosts that cannot run a
privileged container opt out by setting it to false.
With dind on by default the bot could start before the dind daemon accepted
connections and fail its first task ci with "cannot connect to the Docker
daemon". Add a healthcheck to the dind service (docker info probe) and, in the
deploy template, make the bot depend_on dind with condition: service_healthy.
Both the dind block and the bot's depends_on stay inside the enable_dind guard,
so an enable_dind: false render yields a bot with no dind dependency. The local
compose file gets the same healthcheck but no depends_on, since its dind service
is profile-gated and a hard dependency would force the profile on a plain up.
Install docker-buildx-plugin alongside the existing docker CLI so image builds
run through BuildKit instead of the deprecated legacy builder (removes the
"legacy builder is deprecated" warning). Uses the Docker apt repo already
configured in the same layer; no new source is added.
Update the DOCKER_HOST notes in both .env.example files and the README dind
bullet: deploys now enable dind by default and the playbook injects DOCKER_HOST
automatically, so the manual DOCKER_HOST line is only for local/custom setups.
The vk adapter has no Ansible deploy and bundles no dind compose profile, so the comment copied from the telegram adapter ("Ansible deploys enable dind by default" / "docker compose --profile dind") did not apply here. Describe vk's actual setup: the image ships the docker CLI + buildx, and DOCKER_HOST must point at a Docker daemon the operator provides.
@zaytcevcom
zaytcevcom merged commit 2070eb9 into main Jul 20, 2026
4 checks passed
@zaytcevcom
zaytcevcom deleted the duck/263043/enable-dind branch July 20, 2026 19:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant