63 lines
2.4 KiB
Docker
63 lines
2.4 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. The vendored clawdforge SDK
|
|
# needs its own manifest + source available during the cache layer
|
|
# (path dep — Cargo resolves it at workspace load time, not at
|
|
# crate-compile time).
|
|
COPY Cargo.toml Cargo.lock ./
|
|
COPY skald-core/Cargo.toml skald-core/Cargo.toml
|
|
COPY skald/Cargo.toml skald/Cargo.toml
|
|
COPY vendor vendor
|
|
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"]
|