Skip to content

Commit 0f3cf9c

Browse files
committed
refactor(docker): simplify daemon architecture with direct asyncio server
- replace complex multiprocessing.Listener with asyncio-based Unix socket server - remove entrypoint wrapper and gosu dependency in favor of direct daemon execution - implement JSON-RPC 2.0 protocol instead of msgspec + msgpack binary protocol - add file watching capabilities with watchdog for auto-recompile on changes - update Dockerfile to run daemon directly with simplified dependencies - modify docker-compose to use restart policy instead of supervisor pattern - add comprehensive documentation for simplified daemon design - update README with new usage patterns and simplified architecture overview
1 parent 4f5a21b commit 0f3cf9c

11 files changed

Lines changed: 1887 additions & 109 deletions

File tree

docker/Dockerfile

Lines changed: 25 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,48 @@
1-
# Single-stage image with cache-friendly layer ordering.
1+
# vectorless-code — Simplified Docker image for daemon-based architecture.
22
#
3-
# Stable layers (reuse across releases):
4-
# 1. apt install gosu + create vcc user
5-
# 2. install uv
6-
# 3. writable-path setup (mkdir /var/vectorless_code, chown to vcc)
7-
#
8-
# Per-release layers (invalidate when the source tree changes):
9-
# 4. COPY . /vcc-src — build context
10-
# 5. `uv pip install "vectorless-code"` — installs package + deps
11-
#
12-
# Uses glibc-based slim image — vectorless ships pre-built Rust wheels.
3+
# The daemon now manages its own lifecycle (file watching, auto-restart),
4+
# so Docker just needs to start it and keep the container running.
5+
136
FROM python:3.12-slim
147

8+
# Install runtime dependencies
159
RUN apt-get update \
16-
&& apt-get install -y --no-install-recommends gosu \
10+
&& apt-get install -y --no-install-recommends \
11+
gcc \
12+
g++ \
13+
git \
1714
&& rm -rf /var/lib/apt/lists/* \
1815
&& groupadd -g 1000 vcc \
1916
&& useradd -u 1000 -g 1000 -m vcc
2017

18+
# Install uv for fast package installation
2119
RUN pip install --quiet uv
2220

23-
# Writable paths the daemon needs, pre-chowned to vcc.
21+
# Create runtime directory for daemon socket
2422
RUN mkdir -p /var/vectorless_code \
2523
&& chown -R vcc:vcc /var/vectorless_code
2624

2725
WORKDIR /workspace
2826

29-
# Runtime defaults — all overridable at `docker run -e ...` time.
27+
# Runtime environment variables
3028
ENV VECTORLESS_CODE_DIR=/workspace/.vectorless_code \
3129
VECTORLESS_CODE_RUNTIME_DIR=/var/vectorless_code \
32-
VECTORLESS_CODE_DAEMON_SUPERVISED=1
33-
34-
COPY docker/entrypoint.sh /entrypoint.sh
35-
RUN chmod +x /entrypoint.sh
36-
ENTRYPOINT ["/entrypoint.sh"]
30+
VECTORLESS_DAEMON_SUPERVISED=1 \
31+
PYTHONUNBUFFERED=1
3732

38-
# ─── Per-release layer (last so only this one invalidates per release) ─────
39-
#
40-
# Default (PyPI flow): install vectorless-code from PyPI.
41-
# Release workflow / local tests override with:
42-
# --build-arg VCC_INSTALL_SPEC=/vcc-src
43-
# to install from the source tree.
33+
# Install vectorless-code
34+
# Build mount for editable installs (faster iteration during dev)
35+
# Production builds override with:
36+
# --build-arg VCC_INSTALL_SPEC=vectorless-code
4437
ARG VCC_INSTALL_SPEC=""
4538
RUN --mount=type=bind,source=.,target=/vcc-src,rw=true \
4639
if [ -z "$VCC_INSTALL_SPEC" ]; then \
47-
VCC_INSTALL_SPEC="vectorless-code"; \
40+
VCC_INSTALL_SPEC="/vcc-src[dev]"; \
4841
fi; \
4942
uv pip install --system "${VCC_INSTALL_SPEC}"
43+
44+
# Switch to vcc user
45+
USER vcc
46+
47+
# Default: run the daemon (it will manage itself)
48+
CMD ["python", "-m", "vectorless_code.daemon.server"]

docker/README.md

Lines changed: 32 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,19 @@ docker compose up -d
1313
# Linux (aligns file ownership with your host user)
1414
PUID=$(id -u) PGID=$(id -g) docker compose up -d
1515

16-
# Then use the CLI normally
16+
# The daemon starts automatically and watches for file changes
17+
# Use the CLI from your host (if vcc is installed) or inside the container:
1718
docker compose exec vectorless-code vcc init
18-
docker compose exec vectorless-code vcc compile
19-
docker compose exec vectorless-code vcc ask "how does authentication work?"
19+
docker compose exec vectorless-code vcc status
2020
```
2121

22-
## Architecture
22+
## Simplified Architecture
2323

24-
The container runs a **supervised daemon** that:
25-
- Keeps the container alive across daemon restarts
26-
- Auto-restarts when settings change
27-
- Gracefully handles `docker stop` via SIGTERM forwarding
24+
The container runs the **daemon directly**:
25+
- No entrypoint wrapper needed
26+
- Daemon manages its own lifecycle
27+
- File watching for auto-recompile
28+
- Auto-restart on settings changes
2829

2930
## Environment Variables
3031

@@ -33,7 +34,7 @@ The container runs a **supervised daemon** that:
3334
| `VECTORLESS_HOST_PATH_MAPPING` | Map container paths to host paths | `/workspace=$HOME` |
3435
| `VECTORLESS_CODE_DIR` | Project config directory | `/workspace/.vectorless_code` |
3536
| `VECTORLESS_CODE_RUNTIME_DIR` | Daemon runtime directory | `/var/vectorless_code` |
36-
| `VECTORLESS_CODE_DAEMON_SUPERVISED` | Enable supervised mode | `1` |
37+
| `VECTORLESS_DAEMON_SUPERVISED` | Enable supervised mode | `1` |
3738
| `PUID` | Host user ID (Linux only) | - |
3839
| `PGID` | Host group ID (Linux only) | - |
3940
| `VCC_HOST_WORKSPACE` | Path to mount as workspace | `$HOME` |
@@ -43,22 +44,35 @@ The container runs a **supervised daemon** that:
4344
- `/workspace` — Your codebase (bind mount)
4445
- `/var/vectorless_code` — Daemon runtime data (named volume)
4546

46-
## Daemon Management
47+
## Usage Examples
4748

4849
```bash
49-
# Check daemon status
50-
docker compose exec vectorless-code vcc daemon status
51-
52-
# Restart daemon
53-
docker compose exec vectorless-code vcc daemon restart
50+
# From inside the container
51+
docker compose exec vectorless-code vcc status
52+
docker compose exec vectorless-code vcc ask "how does authentication work?"
5453

55-
# Stop container (stops daemon)
56-
docker compose down
54+
# From host (if vcc is installed and daemon is exposed)
55+
vcc --daemon-addr /var/vectorless_code/daemon.sock status
5756
```
5857

5958
## Notes
6059

6160
- The daemon runs as the `vcc` user (UID 1000)
6261
- On Linux, use `PUID`/`PGID` to match your host user for file permissions
6362
- Cache is stored in `.vectorless_code/` within your workspace
64-
- The container auto-restarts the daemon on settings changes
63+
- The daemon automatically recompiles when source files change
64+
- Restart policy: `unless-stopped` (use `docker compose stop` to stop)
65+
66+
## Pushing to Registry
67+
68+
```bash
69+
# Tag for your registry
70+
docker tag vcc:latest ztgx/vectorless-code:latest
71+
72+
# Push to Docker Hub
73+
docker push ztgx/vectorless-code:latest
74+
75+
# With version tag
76+
docker tag vcc:latest ztgx/vectorless-code:0.1.1
77+
docker push ztgx/vectorless-code:0.1.1
78+
```

docker/docker-compose.yml

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,7 @@
1-
# vectorless-code — Docker Compose quickstart.
1+
# vectorless-code — Docker Compose for simplified daemon architecture.
22
#
3-
# # macOS / Windows
4-
# docker compose up -d
5-
#
6-
# # Linux (aligns file ownership with your host user)
7-
# PUID=$(id -u) PGID=$(id -g) docker compose up -d
8-
#
9-
# By default your home directory is mounted into the container as the
10-
# workspace. Set VCC_HOST_WORKSPACE=/path/to/code to mount a narrower
11-
# directory instead.
3+
# The daemon now runs directly without an entrypoint wrapper.
4+
# It manages its own lifecycle including file watching and auto-reindex.
125

136
services:
147
vectorless-code:
@@ -21,14 +14,13 @@ services:
2114
- ${VCC_HOST_WORKSPACE:-${HOME}}:/workspace
2215
- vectorless-data:/var/vectorless_code
2316
environment:
24-
# Makes CLI and MCP output show your real paths
25-
# (e.g. `/Users/you/myproject/...`) instead of container paths
26-
# (e.g. `/workspace/myproject/...`).
17+
# Path mapping for host path display in results
2718
VECTORLESS_HOST_PATH_MAPPING: /workspace=${VCC_HOST_WORKSPACE:-${HOME}}
28-
# Linux only: set these so files written to your workspace are owned by
29-
# you rather than root. Not needed on macOS / Windows — leave empty.
19+
# Linux only: set these so files are owned by you
3020
PUID: ${PUID:-}
3121
PGID: ${PGID:-}
22+
# Restart policy: restart unless manually stopped
23+
restart: unless-stopped
3224

3325
volumes:
3426
vectorless-data:

docker/entrypoint.sh

Lines changed: 0 additions & 50 deletions
This file was deleted.

0 commit comments

Comments
 (0)