chore(deploy): run archied on the host, keep NATS and agents in Docker

The chat agent's file tools operate on host paths, so the daemon has to
see the host filesystem. It keeps spawning agent containers through the
Docker socket and talking to NATS, so compose still carries the bus and
the network; archied and watchtower leave it.

Pins the network subnet: the daemon hands agent containers its own
nats.url verbatim, so that URL has to work from the host and from inside
a container. The gateway address does; a Docker-assigned subnet would
move it silently when the network is recreated.
This commit is contained in:
sam committed 2026-07-31 02:00:11 +10:00
1 parent fd1abdd6c8
commit 367b89e5ee
2 files changed
+53 -45

No files matched your search

+35
View File
@@ -69,3 +69,38 @@ Restart or stop the service:
systemctl --user restart archied
systemctl --user stop archied
```
---
## 4. Running Alongside the Docker Stack
`archied` on the host still needs NATS and still spawns agent containers, so
`docker compose up -d` keeps running the bus and holds the network the agents
join. Two things bite in this hybrid layout:
**One NATS URL serves two network namespaces.** The daemon hands agent
containers its own `nats.url` verbatim, so `nats://nats:4222` (resolvable only
inside compose) and `nats://127.0.0.1:4222` (the container's own loopback) are
both wrong. Use the compose network's gateway address, which the host and the
containers can both reach:
```toml
[nats]
url = "nats://172.19.0.1:4222"
```
`docker-compose.yml` pins the subnet so that address cannot drift when the
network is recreated.
**`pull_policy` must be `"missing"` against a private registry.** The daemon
calls the Docker API with no registry credentials, so `"always"` gets a 401,
which fails the container pool and exits the daemon. Refresh the agent image
by hand instead:
```bash
docker compose pull agent
```
**Paths.** Under compose the daemon saw bind-mounted paths; on the host it sees
the real ones. In particular `db_path` must point at the database's actual
location, or the daemon starts against an empty one.
+18 -45
View File
@@ -1,8 +1,13 @@
# archie-core stack: daemon, NATS, and agent containers.
# archie-core stack: NATS, plus the agent image the daemon spawns per task.
#
# archied itself runs on the host under systemd, not here -- its chat tools
# operate on host files, which a container cannot reach. See
# deployments/systemd-user-service.md.
#
# Start: docker compose up -d
# Stop: docker compose down
# Logs: docker compose logs -f archied
# Logs: journalctl --user -u archied -f (the daemon)
# docker compose logs -f nats (the bus)
services:
# ── NATS JetStream ────────────────────────────────────────────────
@@ -21,34 +26,6 @@ services:
timeout: 5s
retries: 5
# ── archie daemon ──────────────────────────────────────────────────
archied:
image: git.catlow.cloud/sam/archied:latest
# Single config, mounted from outside the repo. Nothing in the working
# tree is required at runtime: a bind mount whose source is missing is
# created as a directory, and the loader rejects a directory, so a
# repo-root config file would take the daemon down on a fresh clone.
# See deployments/docker-nats-stack.toml for the template.
command: -config /etc/archie/config.toml
extra_hosts:
- "host.docker.internal:host-gateway"
ports:
- "8484:8484" # web dashboard
environment:
- ARCHIE_GITEA_TOKEN
- ARCHIE_GITEA_TOKEN_ARCHIE
- HEYARCHIE_TELEGRAM_BOT_TOKEN
- DEEPSEEK_API_KEY
volumes:
- ${HOME}/.config/archie/config.toml:/etc/archie/config.toml:ro
- /var/lib/archie/work:/var/lib/archie/work
- /var/lib/archie/db:/var/lib/archie
- /var/run/docker.sock:/var/run/docker.sock
depends_on:
nats:
condition: service_healthy
restart: unless-stopped
# ── agent image (built once, spawned per task by the daemon) ───────
# Not a long-running service: the daemon starts agent containers itself
# via the Docker socket. This stanza exists only so the image can be
@@ -72,20 +49,16 @@ services:
dockerfile: Dockerfile
image: git.catlow.cloud/sam/archie-agent:latest
# ── deploy watcher ──────────────────────────────────────────────────
# Polls the registry for new archied/archie-agent images (pushed by
# .gitea/workflows/deploy.yml on merge to main) and restarts the
# containers that changed. Registry auth comes from the host's
# existing `docker login` config, mounted read-only.
watchtower:
image: nickfedor/watchtower
environment:
- DOCKER_CONFIG=/
volumes:
- /var/run/docker.sock:/var/run/docker.sock
- ${HOME}/.docker/config.json:/config.json:ro
command: --interval 60 --cleanup archie-core-archied-1
restart: unless-stopped
volumes:
nats_data:
# The subnet is pinned because the daemon hands agent containers its own
# NATS URL verbatim (daemon.go). Running on the host, that URL has to be one
# both sides can reach: the gateway address works from the host and from any
# container on this network. Letting Docker pick the subnet would silently
# move that address when the network is recreated.
networks:
default:
ipam:
config:
- subnet: 172.19.0.0/16