Skip to content

feat: add Docker Compose setup for local development#278

Open
kiloconnect[bot] wants to merge 12 commits intomainfrom
feat/docker-compose-dev
Open

feat: add Docker Compose setup for local development#278
kiloconnect[bot] wants to merge 12 commits intomainfrom
feat/docker-compose-dev

Conversation

@kiloconnect
Copy link
Contributor

@kiloconnect kiloconnect bot commented Feb 17, 2026

Summary

Adds a Docker Compose-based local development setup so developers can start the entire stack (Next.js backend + all Cloudflare Workers) with a single command instead of opening ~6 separate terminals.

Changes

  • dev/Dockerfile.dev — Shared dev image (Node 22 + pnpm + wrangler + bun, all pinned)
  • dev/docker-compose.dev.yml — Orchestrates all 17 services (PostgreSQL + Next.js + 15 workers) with profile support
  • dev/dev.sh — Startup script with preflight checks
  • DOCKER_DEV.md — Full documentation (prerequisites, quick start, port map, troubleshooting)
  • Makefile — Convenience targets (make dev-docker, make dev-docker-core, etc.)

Usage

# Start everything
./dev/dev.sh

# Or use profiles
./dev/dev.sh --profile core      # PostgreSQL + Next.js only
./dev/dev.sh --profile agents    # PostgreSQL + cloud agents
./dev/dev.sh --profile workers   # PostgreSQL + all CF workers

# Or use Make
make dev-docker

Port Map

Service Port
Next.js backend 3000
cloud-agent 8788
cloud-agent-next 8794
cloudflare-ai-attribution 8787
cloudflare-app-builder 8790
cloudflare-auto-fix-infra 8796
cloudflare-auto-triage-infra 8791
cloudflare-code-review-infra 8789
cloudflare-db-proxy 8797
cloudflare-deploy-builder 8798
cloudflare-deploy-dispatcher 8799
cloudflare-session-ingest 8800
cloudflare-o11y 8801
cloudflare-webhook-agent-ingest 8793
cloudflare-git-token-service 8802
kiloclaw 8795

Notes

  • Uses explicit ports: mappings for macOS (Docker Desktop) compatibility
  • Wrangler and bun versions are pinned for reproducibility
  • No existing files were modified — this is fully additive
  • Existing dev/docker-compose.yml (PostgreSQL-only) continues to work standalone

Built for Igor by Kilo for Slack

Built for Evgeny Shurakov by Kilo for Slack

@kiloconnect
Copy link
Contributor Author

kiloconnect bot commented Feb 17, 2026

Code Review Summary

Status: 1 Issue Found | Recommendation: Address before merge

Overview

Severity Count
CRITICAL 0
WARNING 1
SUGGESTION 0
Issue Details (click to expand)

WARNING

File Line Issue
DOCKER_DEV.md 127 .dev.vars connection URLs with localhost will break in Docker — entrypoint only patches wrangler.jsonc, not .dev.vars. Secrets like API_URL=http://localhost:3000 in cloudflare-code-review-infra/.dev.vars override the patched config and point to the container itself instead of the nextjs service.
Files Reviewed (5 files)
  • DOCKER_DEV.md - 1 issue
  • dev/Dockerfile.dev - 0 issues
  • dev/dev.sh - 0 issues
  • dev/docker-compose.dev.yml - 0 issues
  • dev/docker-wrangler-entrypoint.sh - 0 issues
  • Makefile - 0 issues

Fix these issues in Kilo Cloud

@iscekic iscekic requested a review from eshurakov February 17, 2026 14:37
- DOCKER_DEV.md: document that network_mode: host is Linux-only
- Dockerfile.dev: pin wrangler to 4.61.1 for reproducibility
- Dockerfile.dev: pin bun to v1.2.5 for reproducibility
- docker-compose.dev.yml: fix postgres volume path to /var/lib/postgresql/data
- docker-compose.dev.yml: remove pnpm install from nextjs container command
…bility

- Replace network_mode: host with explicit ports: mappings (host networking
  is Linux-only and doesn't work on Docker Desktop for macOS)
- Add --ip 0.0.0.0 to wrangler dev commands so services bind to all
  interfaces inside the container (required for port forwarding)
- Add extra_hosts for host.docker.internal resolution
- Update DOCKER_DEV.md: remove ss command (Linux-only), use lsof only,
  update architecture section to reflect ports-based approach
- Change prerequisite from Docker 20.10+ to Docker Desktop 4.x+
- Add dev/docker-wrangler-entrypoint.sh that patches wrangler.jsonc at
  startup, replacing localhost references with Docker service names
  (e.g., localhost:3000 → nextjs:3000, localhost:5432 → postgres:5432)
- Override Next.js env vars (POSTGRES_URL, CLOUD_AGENT_API_URL,
  WEBHOOK_AGENT_URL) in docker-compose to use Docker service names
- Add networking documentation to DOCKER_DEV.md explaining how
  inter-service communication works on the bridge network
- Workers now use the entrypoint script instead of raw pnpm dev,
  which also handles predev scripts (e.g., cloud-agent wrapper build)

All services share the default Docker Compose bridge network and reach
each other by service name via Docker DNS. No network_mode: host needed,
so this works on both macOS (Docker Desktop) and Linux.
- Pin node base image to 22.14.0-slim for reproducibility
- Pin pgvector/pgvector to 0.8.0-pg18 for consistent local-dev behavior
- Add argument validation in docker-wrangler-entrypoint.sh
- Fix repo name in Makefile header (kilocode-backend → Kilo-Org/cloud)
- Update Docker prerequisite wording to cover Linux (Docker Engine)
- Add pnpm preflight check in dev.sh, drop --frozen-lockfile for local dev
- Use exec-form command for nextjs service (proper PID1 signal handling)
…to loopback

- DOCKER_DEV.md: fix env_file reference to match actual ../.env path in compose
- docker-compose.dev.yml: bind postgres port to 127.0.0.1 to prevent network exposure on Linux
Co-authored-by: kiloconnect[bot] <240665456+kiloconnect[bot]@users.noreply.github.com>
Co-authored-by: kiloconnect[bot] <240665456+kiloconnect[bot]@users.noreply.github.com>
@kiloconnect
Copy link
Contributor Author

kiloconnect bot commented Feb 17, 2026

Fixed the cross-profile dependency issue: added cloud-agent to the workers profile (profiles: ["agents", "workers", "all"]) so the dependency is explicit. Also updated DOCKER_DEV.md to reflect that workers includes cloud-agent.

… exposure

All 14 remaining worker services now use 127.0.0.1:PORT:PORT port
mappings, matching postgres, nextjs, and cloud-agent. This prevents
accidental exposure on all network interfaces on Linux Docker Engine.
Workers that use container-backed Durable Objects (cloud-agent,
cloud-agent-next, cloudflare-app-builder, cloudflare-deploy-builder)
need Docker to spawn sandbox containers via Wrangler. Since these
workers already run inside Docker, they can't use Docker natively.

Mount /var/run/docker.sock into these 4 services so Wrangler can
talk to the host Docker daemon to create sibling containers.

⚠️  This grants the container full control over the host's Docker
daemon — acceptable for local dev, never for production.

Also documents the requirement and security trade-off in DOCKER_DEV.md.
# kiloclaw
```

> **Note:** You do NOT need to change `localhost` references in `.dev.vars` files for Docker — the entrypoint script handles URL rewriting automatically via the wrangler.jsonc patching.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[WARNING]: .dev.vars connection URLs with localhost will break in Docker — entrypoint only patches wrangler.jsonc

This note says .dev.vars localhost references don't need changing, but that's only true for CORS-style values (e.g., WS_ALLOWED_ORIGINS). Connection URLs like API_URL=http://localhost:3000 in cloudflare-code-review-infra/.dev.vars will break because:

  1. The entrypoint script only patches wrangler.jsonc, not .dev.vars
  2. Wrangler's .dev.vars secrets override wrangler.jsonc vars for the same key
  3. Inside the container, localhost:3000 points to the container itself, not the nextjs service

Consider either:

  • Updating this note to clarify that connection URLs in .dev.vars (like API_URL) do need to be changed to use Docker service names
  • Or extending docker-wrangler-entrypoint.sh to also patch .dev.vars files

@eshurakov eshurakov self-assigned this Feb 18, 2026
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.

2 participants