File size: 1,337 Bytes
094bc93
b831db1
094bc93
 
4712f94
b831db1
b2fe216
40e7168
094bc93
b831db1
 
4712f94
75c0487
 
7f54a14
4712f94
b852046
50d2fe5
4712f94
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
40e7168
f1d9987
 
4712f94
 
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
FROM python:3.10-slim

WORKDIR /app

# Install explicit production system dependencies for OpenCV and FFmpeg
RUN apt-get update && apt-get install -y \
    ffmpeg \
    libgl1 \
    libglib2.0-0 \
    && rm -rf /var/lib/apt/lists/*

# Copy python dependencies layout and install with no cache layers
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt

# Copy the streamlined app implementation script
COPY app.py .

# Create operational directory context scopes with correct system permissions
RUN mkdir -p /tmp/uploads /tmp/outputs /tmp/frames /tmp/u2net_models && \
    chmod -R 777 /tmp

# ============================================================
# HUGGING FACE FREE CPU TIERS RESOURCE CONSTRAINT HARDENING
# ============================================================
ENV PYTHONUNBUFFERED=1
ENV MALLOC_TRIM_THRESHOLD_=65536

# Force all standard backend execution libraries into tight sequential single-thread structures
ENV OMP_NUM_THREADS=1
ENV MKL_NUM_THREADS=1
ENV OPENBLAS_NUM_THREADS=1
ENV VECLIB_MAXIMUM_THREADS=1
ENV NUMEXPR_NUM_THREADS=1
ENV ONNXRUNTIME_EXECUTION_MODE=SEQUENTIAL

EXPOSE 7860

# Force Uvicorn into exactly 1 worker to prevent duplicate process RAM multiplication
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860", "--workers", "1", "--timeout-keep-alive", "300"]