File size: 1,375 Bytes
a664674
 
 
 
 
 
 
 
 
3528d52
 
 
 
 
 
 
 
 
 
 
 
 
 
af27444
 
 
 
 
 
a664674
 
 
 
 
 
 
 
 
 
 
 
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
# Use the official Python 3.10 image as a base
FROM python:3.10-slim

# Set the working directory inside the container
WORKDIR /code

# Set an environment variable to prevent prompts during package installation
ENV DEBIAN_FRONTEND=noninteractive

# --- NEW SECTION: CREATE A WRITABLE DIRECTORY FOR ALL CACHES ---
# Create a directory that any user can write to for cache files.
RUN mkdir -p /data/huggingface && \
    mkdir -p /data/ultralytics && \
    mkdir -p /data/paddle && \
    chmod -R 777 /data

# Tell all the libraries to use this new writable directory for their caches.
ENV HF_HOME=/data/huggingface
ENV HUGGINGFACE_HUB_CACHE=/data/huggingface
ENV TRANSFORMERS_CACHE=/data/huggingface
ENV YOLO_CONFIG_DIR=/data/ultralytics
ENV PADDLE_HOME=/data/paddle
ENV MPLCONFIGDIR=/data/matplotlib

# Install missing system-level dependencies required by OpenCV (cv2)
RUN apt-get update && \
    apt-get install -y libgl1-mesa-glx libglib2.0-0 ffmpeg libsm6 libxext6 && \
    apt-get clean

# Copy the requirements file into the container
COPY requirements.txt .

# Install the Python dependencies from requirements.txt
RUN pip install --no-cache-dir --upgrade pip && \
    pip install --no-cache-dir -r requirements.txt

# Copy the application file into the container
COPY app.py .

# Command to run the Gradio application when the container starts
CMD ["python", "app.py"]