Pre-install common Python packages in workspace venv and warm Docker cache

Install httpx, fastapi, uvicorn, requests, flask, pydantic, numpy, pandas,
matplotlib, pillow, jinja2, pyyaml and more on workspace creation. Also
pre-warm uv cache in Dockerfile so first project setup is near-instant.
uv's global cache (~/.cache/uv/) is shared across all project venvs.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Fam Zheng 2026-03-02 09:19:48 +00:00
parent 0a8eee0285
commit 728ab2e8fd
2 changed files with 3 additions and 0 deletions

View File

@ -13,6 +13,8 @@ RUN curl -LsSf https://astral.sh/uv/install.sh | sh
ENV PATH="/root/.local/bin:$PATH" ENV PATH="/root/.local/bin:$PATH"
RUN uv venv --python 3.12 /app/venv && uv pip install --python /app/venv/bin/python sentence-transformers RUN uv venv --python 3.12 /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 /app/venv/bin/python -c "from sentence_transformers import SentenceTransformer; SentenceTransformer('all-MiniLM-L6-v2')"
# Pre-warm uv cache with common packages (shared across all project venvs)
RUN uv pip install --python /app/venv/bin/python httpx fastapi uvicorn requests flask pydantic numpy pandas matplotlib pillow jinja2 pyyaml python-dotenv beautifulsoup4 lxml aiohttp aiofiles pytest rich click typer sqlalchemy
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 .

View File

@ -257,6 +257,7 @@ async fn ensure_workspace(exec: &LocalExecutor, workdir: &str) {
let venv_path = format!("{}/.venv", workdir); let venv_path = format!("{}/.venv", workdir);
if !Path::new(&venv_path).exists() { if !Path::new(&venv_path).exists() {
let _ = exec.execute("uv venv .venv", workdir).await; let _ = exec.execute("uv venv .venv", workdir).await;
let _ = exec.execute("uv pip install httpx fastapi uvicorn requests flask pydantic numpy pandas matplotlib pillow jinja2 pyyaml python-dotenv beautifulsoup4 lxml aiohttp aiofiles pytest rich click typer sqlalchemy", workdir).await;
} }
} }
} }