Update Dockerfile
Browse filesmodified Dockerfile and replace any reference to /root/.cache with /tmp/huggingface_cache
- Dockerfile +15 -21
Dockerfile
CHANGED
|
@@ -1,44 +1,38 @@
|
|
| 1 |
-
# Use an official Python runtime as
|
| 2 |
FROM python:3.9-slim
|
| 3 |
|
| 4 |
-
# Set the working directory
|
| 5 |
WORKDIR /app
|
| 6 |
|
| 7 |
-
# Install system dependencies for
|
| 8 |
RUN apt-get update && apt-get install -y \
|
| 9 |
build-essential \
|
| 10 |
libopenblas-dev \
|
| 11 |
libomp-dev \
|
| 12 |
&& rm -rf /var/lib/apt/lists/*
|
| 13 |
|
| 14 |
-
#
|
| 15 |
-
RUN
|
| 16 |
|
| 17 |
-
#
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
# Set environment variables
|
| 21 |
-
ENV HF_HOME=/root/.cache/huggingface
|
| 22 |
ENV MPLCONFIGDIR=/tmp/matplotlib
|
| 23 |
|
| 24 |
-
|
| 25 |
-
# Add Hugging Face API token (replace YOUR_HF_TOKEN with your actual token)
|
| 26 |
-
ENV HUGGINGFACE_TOKEN=${HUGGINGFACE_TOKEN}
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
# Copy the dependencies file first for caching efficiency
|
| 32 |
COPY requirements.txt /app/requirements.txt
|
| 33 |
|
| 34 |
# Install Python dependencies
|
| 35 |
RUN pip install --no-cache-dir -r requirements.txt
|
| 36 |
|
| 37 |
-
#
|
|
|
|
|
|
|
|
|
|
| 38 |
COPY . /app
|
| 39 |
|
| 40 |
-
# Expose port 7860
|
| 41 |
EXPOSE 7860
|
| 42 |
|
| 43 |
-
#
|
| 44 |
CMD ["python", "main.py"]
|
|
|
|
| 1 |
+
# Use an official Python runtime as a parent image
|
| 2 |
FROM python:3.9-slim
|
| 3 |
|
| 4 |
+
# Set the working directory to /app
|
| 5 |
WORKDIR /app
|
| 6 |
|
| 7 |
+
# Install system dependencies for machine learning and data processing libraries
|
| 8 |
RUN apt-get update && apt-get install -y \
|
| 9 |
build-essential \
|
| 10 |
libopenblas-dev \
|
| 11 |
libomp-dev \
|
| 12 |
&& rm -rf /var/lib/apt/lists/*
|
| 13 |
|
| 14 |
+
# Create writable cache directories for Hugging Face and Matplotlib
|
| 15 |
+
RUN mkdir -p /tmp/huggingface_cache /tmp/matplotlib
|
| 16 |
|
| 17 |
+
# Set environment variables
|
| 18 |
+
ENV TRANSFORMERS_CACHE=/tmp/huggingface_cache
|
| 19 |
+
ENV HF_HOME=/tmp/huggingface_cache
|
|
|
|
|
|
|
| 20 |
ENV MPLCONFIGDIR=/tmp/matplotlib
|
| 21 |
|
| 22 |
+
# Copy requirements.txt first to leverage Docker caching
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 23 |
COPY requirements.txt /app/requirements.txt
|
| 24 |
|
| 25 |
# Install Python dependencies
|
| 26 |
RUN pip install --no-cache-dir -r requirements.txt
|
| 27 |
|
| 28 |
+
# Install PyTorch separately to ensure compatibility with the correct architecture
|
| 29 |
+
RUN pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cpu
|
| 30 |
+
|
| 31 |
+
# Copy the rest of the application code
|
| 32 |
COPY . /app
|
| 33 |
|
| 34 |
+
# Expose port 7860 for Hugging Face Spaces
|
| 35 |
EXPOSE 7860
|
| 36 |
|
| 37 |
+
# Command to run your Flask app
|
| 38 |
CMD ["python", "main.py"]
|