chore(api): bundle canon log schemas into image; repo-root build context

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-07-09 12:45:49 -05:00
parent 6d5510773a
commit 4ab0e564ef
3 changed files with 26 additions and 8 deletions

14
.dockerignore Normal file
View File

@@ -0,0 +1,14 @@
.git
.claude
client
content
docs/*
!docs/schemas
**/__pycache__
**/*.py[cod]
.venv
venv
**/.pytest_cache
api/tests
api/.env
api/.env.*

View File

@@ -1,8 +1,7 @@
# /api — FastAPI proxy (charter §4). Docker-based for parity across # /api — FastAPI proxy (charter §4). Build context is the repo root so the
# dev / homelab VPS / fly.io. # canon log schemas (/docs/schemas) are bundled into the image.
FROM python:3.12-slim FROM python:3.12-slim
# Faster, quieter Python in containers.
ENV PYTHONUNBUFFERED=1 \ ENV PYTHONUNBUFFERED=1 \
PYTHONDONTWRITEBYTECODE=1 \ PYTHONDONTWRITEBYTECODE=1 \
PIP_NO_CACHE_DIR=1 PIP_NO_CACHE_DIR=1
@@ -10,11 +9,12 @@ ENV PYTHONUNBUFFERED=1 \
WORKDIR /app WORKDIR /app
# Install deps first so the layer caches when only app code changes. # Install deps first so the layer caches when only app code changes.
COPY requirements.txt . COPY api/requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt RUN pip install --no-cache-dir -r requirements.txt
# App code. # App code + the schema contract (single source of truth in docs/schemas).
COPY app ./app COPY api/app ./app
COPY docs/schemas ./schemas
# Run as non-root. # Run as non-root.
RUN useradd --create-home --uid 1000 appuser RUN useradd --create-home --uid 1000 appuser

View File

@@ -1,17 +1,21 @@
# Local dev — run the proxy in Docker with live reload. # Local dev — run the proxy in Docker with live reload.
# docker compose up --build # 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. # Ollama runs on the homelab (charter §4), not here — point OLLAMA_BASE_URL at it.
services: services:
api: api:
build: ./api build:
context: .
dockerfile: api/Dockerfile
ports: ports:
- "8000:8000" - "8000:8000"
env_file: env_file:
- ./api/.env - ./api/.env
environment: environment:
PORT: 8000 PORT: 8000
# Mount source + reload so edits are live without a rebuild. # Mount source + schemas so edits are live without a rebuild.
volumes: volumes:
- ./api/app:/app/app:ro - ./api/app:/app/app:ro
- ./docs/schemas:/app/schemas:ro
command: > command: >
uvicorn app.main:app --host 0.0.0.0 --port 8000 --reload uvicorn app.main:app --host 0.0.0.0 --port 8000 --reload