Skald is a generic story-writer. The database is the product; the binary is the tooling. Everything story-specific lives in rows, not in code. cwho's monorepo + binary-per-role pattern transplanted to this domain. What this commit ships: - Cargo workspace (resolver=3, edition 2024): skald-core (lib) + skald (bin) - Migration 0001: stories, characters, canon_facts, chapters, chapter_summaries, passages (vector(1536)), generation_runs, audit_findings, tags. pgvector + pg_trgm extensions. ivfflat index deferred until we have data (post-import the first ~1k passages and add the index). - skald-core::ingest — markdown parser for the cwho/coast-down shape: '# Title' → '## Chapter N — date' headings → '# Continuity Bible' section with character roster (real + fictional sub-sections) + setting / mystery / historical / liberty / hook sub-sections. Decomposed into structured rows; original bullet body preserved in key_facts/body fields for fidelity. 6 unit tests cover the shape. - skald-core::db — Postgres connection pool + migration runner. - skald-core::models — row types via sqlx::FromRow. - skald binary — clap CLI: 'serve' (http + migrations) and 'import-markdown' (one-shot ingest). - Dockerfile — multi-stage: rust:1.95-bookworm builder, pgvector/ pgvector:pg17 runtime, tini under PID 1, custom entrypoint.sh that boots embedded postgres then execs skald serve. - compose.yml — singleton container, postgres data in volume, story corpus mounted read-only at /seed. Decisions locked 2026-05-13: 1. DB in same container 'till we have a real working tool' (cobb) 2. postgres+pgvector (NOT sqlite) — keeps semantic-search story 3. Network-not-socket connection (postgresql://localhost:5432) from day one so future split is config-only, not code-rewrite Not yet wired: - Web UI - clawdforge calls (gen → cleanup → canon-audit pipeline) - Embedding pass - TTS sidecar
59 lines
2.2 KiB
Docker
59 lines
2.2 KiB
Docker
# Multi-stage build for skald.
|
|
#
|
|
# Stage 1: compile the rust binary against rust:1-bookworm.
|
|
# Stage 2: pgvector/pgvector:pg17 (debian-bookworm postgres with
|
|
# pgvector preinstalled) + tini + the skald binary.
|
|
#
|
|
# v0.1 ships postgres inside the same container ("singleton till we
|
|
# have a real working tool"). When we extract the DB out, swap the
|
|
# runtime base to debian:bookworm-slim, drop entrypoint.sh, point
|
|
# DATABASE_URL at the external pg.
|
|
#
|
|
# Build context is the workspace root:
|
|
# docker build -t skald:latest .
|
|
|
|
# ─── builder ──────────────────────────────────────────────────────
|
|
FROM rust:1.95-bookworm AS builder
|
|
WORKDIR /build
|
|
|
|
# Cache the dependency graph: copy manifests first, fetch + build
|
|
# stubs, THEN drop in real sources.
|
|
COPY Cargo.toml Cargo.lock ./
|
|
COPY skald-core/Cargo.toml skald-core/Cargo.toml
|
|
COPY skald/Cargo.toml skald/Cargo.toml
|
|
COPY migrations migrations
|
|
|
|
RUN mkdir -p skald-core/src skald/src \
|
|
&& echo 'pub fn placeholder() {}' > skald-core/src/lib.rs \
|
|
&& echo 'fn main() {}' > skald/src/main.rs \
|
|
&& cargo build --release -p skald \
|
|
&& rm -rf skald-core/src skald/src
|
|
|
|
COPY skald-core skald-core
|
|
COPY skald skald
|
|
|
|
RUN touch skald-core/src/lib.rs skald/src/main.rs \
|
|
&& cargo build --release -p skald
|
|
|
|
# ─── runtime ──────────────────────────────────────────────────────
|
|
FROM pgvector/pgvector:pg17 AS runtime
|
|
|
|
# tini for sane signal handling / zombie reaping under PID 1.
|
|
RUN apt-get update \
|
|
&& apt-get install -y --no-install-recommends tini ca-certificates \
|
|
&& rm -rf /var/lib/apt/lists/*
|
|
|
|
COPY --from=builder /build/target/release/skald /usr/local/bin/skald
|
|
COPY --from=builder /build/migrations /var/lib/skald/migrations
|
|
COPY entrypoint.sh /usr/local/bin/skald-entrypoint.sh
|
|
RUN chmod +x /usr/local/bin/skald-entrypoint.sh
|
|
|
|
ENV RUST_LOG=info \
|
|
SKALD_LISTEN=0.0.0.0:7780 \
|
|
POSTGRES_USER=skald \
|
|
POSTGRES_DB=skald
|
|
|
|
EXPOSE 7780
|
|
|
|
ENTRYPOINT ["/usr/bin/tini", "--", "/usr/local/bin/skald-entrypoint.sh"]
|
|
CMD ["serve"]
|