open-notebook / Dockerfile
ffreemt
babel
a075c8a
Raw
History Blame Contribute Delete
1.84 kB
FROM python:3.11-slim
WORKDIR /app
# Set PYTHONPATH to include /app
ENV PYTHONPATH=/app
# Set Hugging Face cache directories (writable in HF Spaces)
ENV HF_HOME=/tmp
ENV TRANSFORMERS_CACHE=/tmp
ENV SENTENCE_TRANSFORMERS_HOME=/tmp
ENV UV_SYSTEM_PYTHON=1
ENV UV_BREAK_SYSTEM_PACKAGES=1
ENV TZ=Asia/Shanghai
COPY --from=ghcr.io/astral-sh/uv:latest /uv /uvx /bin/
# Install system dependencies
RUN apt-get update && apt-get install -y \
curl tzdata \
build-essential && \
curl -sSf https://install.surrealdb.com | sh && \
curl -fsS https://dotenvx.sh | sh && \
rm -rf /var/lib/apt/lists/*
# Copy requirements.txt for dependency installation
COPY requirements.txt ./
# Install Python dependencies from requirements.txt
RUN uv pip install --no-cache-dir --upgrade pip && \
uv pip install --no-cache-dir -r requirements.txt
# Explicitly ensure surreal-commands is installed (belt-and-suspenders approach)
# RUN pip install --no-cache-dir surreal-commands>=1.2.0
# requirements.txt
# Pre-download sentence-transformers model at build time
# This will be cached in the Docker image
RUN python -c "from sentence_transformers import SentenceTransformer; SentenceTransformer('all-MiniLM-L6-v2')"
# Copy application code
# COPY run_api.py start.sh api/ open_notebook/ commands/ migrations/ prompts/ ./
COPY . .
# Make start script executable
RUN chmod +x start.sh
# Set environment variables for SurrealDB connection
ENV SURREAL_URL=ws://localhost:8000/rpc
ENV SURREAL_ADDRESS=localhost
ENV SURREAL_PORT=8000
ENV SURREAL_USER=root
ENV SURREAL_PASS=root
ENV SURREAL_NAMESPACE=open_notebook
ENV SURREAL_DATABASE=main
# Set API configuration for Hugging Face Spaces
ENV API_HOST=0.0.0.0
ENV API_PORT=7860
ENV API_RELOAD=false
# Expose Hugging Face Spaces port
EXPOSE 7860
# Run the start script
CMD ["./start.sh"]