LLM-LOD / Dockerfile
wjbmattingly's picture
Upload Dockerfile
a6f119f verified
FROM python:3.10
WORKDIR /app
# Create cache directories with proper permissions
RUN mkdir -p /app/.cache /app/.huggingface && \
chmod 777 /app/.cache /app/.huggingface
# Set environment variables for cache directories
ENV HF_HOME=/app/.huggingface
ENV TRANSFORMERS_CACHE=/app/.huggingface
ENV HF_DATASETS_CACHE=/app/.huggingface
ENV TORCH_HOME=/app/.cache
# Install system dependencies for building Python packages
RUN apt-get update && apt-get install -y \
gcc \
g++ \
build-essential \
&& rm -rf /var/lib/apt/lists/*
# Upgrade pip and install wheel to use pre-compiled packages when possible
RUN pip install --upgrade pip wheel
# Copy requirements and install dependencies
COPY requirements.txt .
# Install packages with timeout and prefer binary wheels
RUN pip install --no-cache-dir --timeout 300 --prefer-binary -r requirements.txt
# Download spaCy model
RUN python -m spacy download en_core_web_sm
# Copy application files
COPY . .
# Expose port for HuggingFace Spaces
EXPOSE 7860
# Run the Flask app
CMD ["python", "app.py"]