githubexplorer / Dockerfile
Kareman's picture
feat: add dockerfile
17e2d86
Raw
History Blame Contribute Delete
1.14 kB
FROM python:3.12-slim
WORKDIR /app
# ------------------------
# Environment
# ------------------------
ENV PYTHONUNBUFFERED=1
ENV PYTHONDONTWRITEBYTECODE=1
# HuggingFace cache
ENV HF_HOME=/tmp/.cache
ENV TRANSFORMERS_CACHE=/tmp/.cache
ENV HUGGINGFACE_HUB_CACHE=/tmp/.cache
RUN mkdir -p /tmp/.cache && chmod -R 777 /tmp/.cache
# ------------------------
# System packages
# ------------------------
RUN apt-get update && apt-get install -y \
build-essential \
git \
&& rm -rf /var/lib/apt/lists/*
# ------------------------
# Python packages
# ------------------------
COPY requirements.txt .
RUN pip install --upgrade pip
RUN pip install --no-cache-dir -r requirements.txt
# ------------------------
# Download embedding model
# ------------------------
RUN python -c "from sentence_transformers import SentenceTransformer; SentenceTransformer('BAAI/bge-small-en-v1.5')"
# ------------------------
# Copy project
# ------------------------
COPY . .
# ------------------------
# HuggingFace Spaces
# ------------------------
EXPOSE 7860
CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "7860"]