File size: 1,614 Bytes
a44e6f7
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7a1d86c
d29d40b
 
a44e6f7
d29d40b
a44e6f7
7a1d86c
 
d29d40b
a44e6f7
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 an official Python 3.11 slim image with Debian Bookworm (newer)
FROM python:3.11-slim-bookworm

# Set working directory in the container
WORKDIR /app

# Install system dependencies required by deepmost (and generally good for ML)
RUN apt-get update && \
    apt-get install -y --no-install-recommends \
    git \
    git-lfs \
    ffmpeg \
    libsm6 \
    libxext6 \
    cmake \
    rsync \
    libgl1-mesa-glx \
    build-essential \
    && rm -rf /var/lib/apt/lists/* \
    && git lfs install

# --- CRITICAL FIX 1: Create /.deepmost and set permissions ---
# Docker images usually run as root during RUN steps.
# Create the directory where deepmost wants to save its files.
RUN mkdir -p /.deepmost && \
    chmod 777 /.deepmost # Give read/write/execute permissions to all for this specific folder

# --- CRITICAL FIX 2: Set Hugging Face cache directory to /tmp ---
ENV HF_HOME="/tmp/.hf_cache"
# Also set MPLCONFIGDIR for Matplotlib cache 
ENV MPLCONFIGDIR=/tmp/.matplotlib


# Copy requirements.txt and install Python dependencies
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt

# Copy the rest of your application code
COPY . .

# Set the PORT environment variable. Hugging Face Spaces will
# inject its own PORT value (e.g., 7860), which will override this
# if it's set. This ensures the CMD always has a value.
ENV PORT=7860 

# Expose the port Flask will run on
EXPOSE ${PORT}

# Use the shell form of CMD to allow $PORT expansion
# This command will start Gunicorn and bind it to the exposed port.
CMD gunicorn --bind 0.0.0.0:${PORT} app:app --timeout 300 --workers 1