File size: 1,411 Bytes
665bb42 b72622e a7328ec 665bb42 a7328ec 665bb42 a7328ec 238ea57 b010b3f 665bb42 a7328ec b72622e 665bb42 a7328ec 665bb42 b46be0b 665bb42 a7328ec 665bb42 a7328ec 665bb42 a7328ec |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# Use Python 3.10 for compatibility
FROM python:3.10-slim
# Set working directory
WORKDIR /app
# Install system dependencies
RUN apt-get update && apt-get install -y \
build-essential \
libopenblas-dev \
libomp-dev \
&& rm -rf /var/lib/apt/lists/*
# Create cache directories on /data and matplotlib config dir
RUN mkdir -p \
/data/.huggingface \
/data/.cache/huggingface/datasets \
/data/.cache/huggingface/transformers \
/tmp/matplotlib \
&& chmod -R 777 /data /tmp/matplotlib
# Clean any old Hugging Face caches (defensive)
RUN rm -rf \
/root/.cache/huggingface \
/root/.cache/huggingface_hub \
/root/.cache/huggingface/datasets || true
# Set cache environment variables to point at /data
ENV HF_HOME=/data/.huggingface
ENV HF_HUB_CACHE=/data/.cache/huggingface/hub
ENV HF_DATASETS_CACHE=/data/.cache/huggingface/datasets
ENV TRANSFORMERS_CACHE=/data/.cache/huggingface/transformers
ENV MPLCONFIGDIR=/tmp/matplotlib
# Copy requirements file
COPY requirements.txt /app/requirements.txt
# Install dependencies
RUN pip install --upgrade pip && pip install --no-cache-dir -r requirements.txt
# Install PyTorch separately for compatibility
RUN pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cpu
# Copy application files
COPY . /app
# Expose Flask app port
EXPOSE 7860
# Run the application
CMD ["python", "main.py"]
|