-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
71 lines (56 loc) · 2.56 KB
/
Dockerfile
File metadata and controls
71 lines (56 loc) · 2.56 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# Stage 1: Build
FROM rust:1.94-bookworm AS builder
WORKDIR /app
# Copy workspace manifests
COPY Cargo.toml Cargo.lock ./
COPY packages/python/Cargo.toml packages/python/Cargo.toml
# Stub out sources so cargo fetch resolves with just manifests
RUN mkdir -p src packages/python/src benches && \
echo 'fn main() {}' > src/main.rs && \
echo '' > src/lib.rs && \
echo 'fn main() {}' > benches/chunking.rs && \
printf 'use pyo3::prelude::*;\n#[pymodule]\nfn cognigraph_chunker(_py: Python, _m: &Bound<PyModule>) -> PyResult<()> { Ok(()) }' \
> packages/python/src/lib.rs && \
cargo fetch
# Copy real source (overwrites stubs)
COPY src/ src/
COPY benches/ benches/
RUN cargo build --release --package cognigraph-chunker --bin cognigraph-chunker
# Download ONNX Runtime shared library for linux-x64
ARG ORT_VERSION=1.22.0
ADD https://github.com/microsoft/onnxruntime/releases/download/v${ORT_VERSION}/onnxruntime-linux-x64-${ORT_VERSION}.tgz /tmp/ort.tgz
RUN tar -xzf /tmp/ort.tgz -C /tmp && \
mkdir -p /opt/onnxruntime && \
cp /tmp/onnxruntime-linux-x64-${ORT_VERSION}/lib/libonnxruntime.so* /opt/onnxruntime/
# Stage 2: Runtime
FROM debian:bookworm-slim
RUN apt-get update && \
apt-get install -y --no-install-recommends ca-certificates curl && \
rm -rf /var/lib/apt/lists/*
COPY --from=builder /app/target/release/cognigraph-chunker /usr/local/bin/cognigraph-chunker
COPY --from=builder /opt/onnxruntime/ /usr/local/lib/
RUN ldconfig
# Optional: bundle ONNX models for local embeddings
# COPY models/ /app/models/
# Railway, Render, Fly.io inject PORT env var
ENV PORT=3000
EXPOSE ${PORT}
# Environment variables for runtime configuration:
# PORT - server port (default: 3000)
# API_KEY - Bearer token for authentication
# NO_AUTH - set to "1" to disable auth
# CORS_ORIGINS - comma-separated allowed origins
# OPENAI_API_KEY - for OpenAI embedding provider
# CLOUDFLARE_AUTH_TOKEN - for Cloudflare Workers AI embedding provider
# CLOUDFLARE_ACCOUNT_ID - Cloudflare account ID
# CLOUDFLARE_AI_GATEWAY - Cloudflare AI Gateway name (optional)
# ORT_DYLIB_PATH - path to libonnxruntime.so (default: system lib path)
HEALTHCHECK --interval=30s --timeout=5s --start-period=5s --retries=3 \
CMD curl -f http://localhost:${PORT}/api/v1/health || exit 1
ENTRYPOINT ["sh", "-c", \
"exec cognigraph-chunker serve \
--host 0.0.0.0 \
--port ${PORT} \
${API_KEY:+--api-key \"$API_KEY\"} \
${NO_AUTH:+--no-auth} \
${CORS_ORIGINS:+--cors-origin \"$CORS_ORIGINS\"}"]