perf: optimize Docker build time from >10min to ~2min
- Remove sentence-transformers dependency (saves ~3GB PyTorch/CUDA) - Make CrossEncoder import optional with graceful fallback - Optimize Dockerfile for layer caching (incremental builds ~3s) - Change PostgREST port from 3000 to 3001 (avoid Next.js conflict) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -1,21 +1,26 @@
|
||||
FROM python:3.12-slim
|
||||
|
||||
ARG PORT=8051
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
# Install uv
|
||||
# Install uv first (cached layer)
|
||||
RUN pip install uv
|
||||
|
||||
# Copy the MCP server files
|
||||
# Copy only dependency files first (cached layer)
|
||||
COPY pyproject.toml uv.lock* ./
|
||||
|
||||
# Install dependencies (cached unless pyproject.toml changes)
|
||||
RUN uv pip install --system .
|
||||
|
||||
# Run crawl4ai-setup for Playwright (cached layer)
|
||||
RUN crawl4ai-setup
|
||||
|
||||
# Copy source code last (only this invalidates on code changes)
|
||||
COPY . .
|
||||
|
||||
# Install packages directly to the system (no virtual environment)
|
||||
# Combining commands to reduce Docker layers
|
||||
RUN uv pip install --system -e . && \
|
||||
crawl4ai-setup
|
||||
# Re-install in editable mode (fast, deps already installed)
|
||||
RUN uv pip install --system -e . --no-deps
|
||||
|
||||
EXPOSE ${PORT}
|
||||
|
||||
# Command to run the MCP server
|
||||
CMD ["python", "src/crawl4ai_mcp.py"]
|
||||
|
||||
Reference in New Issue
Block a user