Files
code_of_conquest_dnd/docker-compose.yml
Phillip Tarrant 004bd53a39 fix(api): let the Dockerized proxy reach a host-run Ollama
After the prompts fix, /dm/narrate reached the model call and failed with
ConnectError: Connection refused — the container's localhost is not the
host, so the default OLLAMA_BASE_URL=http://localhost:11434 hit nothing.
Ollama runs on the host (M1's venv smoke reached it because uvicorn ran on
the host too; the container never had a route).

Add extra_hosts host.docker.internal:host-gateway so the container can
reach the host, and document using http://host.docker.internal:11434 in
.env.example. Verified a container reaches host Ollama's /api/tags (200).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-10 11:07:44 -05:00

31 lines
1.2 KiB
YAML

# Local dev — run the proxy in Docker with live reload.
# docker compose up --build
# Build context is the repo root so docs/schemas is available to the image.
# Ollama runs on the homelab (charter §4), not here — point OLLAMA_BASE_URL at it.
services:
api:
build:
context: .
dockerfile: api/Dockerfile
ports:
- "8000:8000"
env_file:
- path: ./api/.env
required: false
environment:
PORT: 8000
# Reach a host-run Ollama from inside the container. On Linux, localhost in
# the container is the container itself, so OLLAMA_BASE_URL must be
# http://host.docker.internal:11434 (set in api/.env); this maps that name
# to the Docker host. Harmless when Ollama is on the homelab instead.
extra_hosts:
- "host.docker.internal:host-gateway"
# Mount source + prompts + schemas so edits are live without a rebuild.
# Prompts are source code (§16) — editing a prompt should reload like code.
volumes:
- ./api/app:/app/app:ro
- ./api/prompts:/app/prompts:ro
- ./docs/schemas:/app/schemas:ro
command: >
uvicorn app.main:app --host 0.0.0.0 --port 8000 --reload