# Dockerfile for mentatd: Datomic-compatible HTTP daemon for pg_mentat # # Build context must be the repository root: # docker build -f docker/Dockerfile.mentatd -t mentatd . # # Multi-stage build: # 1. builder -- compiles mentatd release binary # 2. runtime -- minimal Debian image with only the binary # ============================================================================= # Stage 1: Build the mentatd binary # ============================================================================= FROM rust:1.88-bookworm AS builder RUN apt-get update && apt-get install -y --no-install-recommends \ pkg-config libssl-dev \ && rm -rf /var/lib/apt/lists/* COPY . /build/pg_mentat WORKDIR /build/pg_mentat # Build only the mentatd binary in release mode. # Exclude pg_mentat (requires pgrx + PG headers) from the default workspace build. RUN cargo build --release --bin mentatd # ============================================================================= # Stage 2: Runtime image -- small footprint with only the binary # ============================================================================= FROM debian:bookworm-slim RUN apt-get update && apt-get install -y --no-install-recommends \ ca-certificates libssl3 \ && rm -rf /var/lib/apt/lists/* RUN groupadd --system mentatd && useradd --system --gid mentatd mentatd COPY --from=builder /build/pg_mentat/target/release/mentatd /usr/local/bin/mentatd USER mentatd EXPOSE 8080 HEALTHCHECK --interval=10s --timeout=5s --start-period=10s --retries=3 \ CMD ["sh", "-c", "exec 3<>/dev/tcp/localhost/8080 && echo -e 'GET /health HTTP/1.1\\r\\nHost: localhost\\r\\n\\r\\n' >&3 && head -1 <&3 | grep -q '200 OK'"] ENTRYPOINT ["mentatd"]