Use uv venv for embedding, pre-download model in Docker build
- Use /app/venv with uv instead of system python/pip - Pre-download all-MiniLM-L6-v2 model during Docker build Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
fbf636868c
commit
ddbe61818b
@ -8,10 +8,11 @@ RUN npm run build
|
|||||||
|
|
||||||
# Stage 2: Runtime
|
# Stage 2: Runtime
|
||||||
FROM alpine:3.21
|
FROM alpine:3.21
|
||||||
RUN apk add --no-cache ca-certificates curl bash python3 py3-pip
|
RUN apk add --no-cache ca-certificates curl bash
|
||||||
RUN curl -LsSf https://astral.sh/uv/install.sh | sh
|
RUN curl -LsSf https://astral.sh/uv/install.sh | sh
|
||||||
ENV PATH="/root/.local/bin:$PATH"
|
ENV PATH="/root/.local/bin:$PATH"
|
||||||
RUN pip3 install --break-system-packages sentence-transformers
|
RUN uv venv /app/venv && uv pip install --python /app/venv/bin/python sentence-transformers
|
||||||
|
RUN /app/venv/bin/python -c "from sentence_transformers import SentenceTransformer; SentenceTransformer('all-MiniLM-L6-v2')"
|
||||||
RUN mkdir -p /app/data/workspaces
|
RUN mkdir -p /app/data/workspaces
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
COPY target/aarch64-unknown-linux-musl/release/tori .
|
COPY target/aarch64-unknown-linux-musl/release/tori .
|
||||||
|
|||||||
@ -101,7 +101,7 @@ impl KbManager {
|
|||||||
async fn compute_embeddings(texts: &[String]) -> Result<Vec<Vec<f32>>> {
|
async fn compute_embeddings(texts: &[String]) -> Result<Vec<Vec<f32>>> {
|
||||||
let input = serde_json::json!({ "texts": texts });
|
let input = serde_json::json!({ "texts": texts });
|
||||||
|
|
||||||
let mut child = tokio::process::Command::new("python3")
|
let mut child = tokio::process::Command::new("/app/venv/bin/python")
|
||||||
.arg("/app/scripts/embed.py")
|
.arg("/app/scripts/embed.py")
|
||||||
.stdin(Stdio::piped())
|
.stdin(Stdio::piped())
|
||||||
.stdout(Stdio::piped())
|
.stdout(Stdio::piped())
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user