File size: 2,455 Bytes
453aad4
 
 
e2af51e
453aad4
 
 
 
 
 
 
 
 
 
 
1634aff
 
cdd090f
 
453aad4
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
e2af51e
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# ------------------------------------------------------------
# Base image
# ------------------------------------------------------------
FROM python:3.12-slim

# ------------------------------------------------------------
# Environment
# ------------------------------------------------------------
#   PYTHONUNBUFFERED  : ensures stdout/stderr aren’t buffered (logs show up instantly)
#   PYTHONDONTWRITEBYTECODE : avoids .pyc files
#   PIP_NO_CACHE_DIR  : prevents pip from caching wheels
ENV PYTHONUNBUFFERED=1 \
    PYTHONDONTWRITEBYTECODE=1 \
    PIP_NO_CACHE_DIR=1

RUN mkdir -p /app/output /app/backend/output && chmod -R 777 /app/output /app/backend/output




# ------------------------------------------------------------
# Working directory inside container
# ------------------------------------------------------------
WORKDIR /app

# ------------------------------------------------------------
# Copy application files
# ------------------------------------------------------------
# Copy only what’s required first (so Docker can cache layers)

COPY . .

# ------------------------------------------------------------
# System + Python dependencies
# ------------------------------------------------------------
# --no-install-recommends  : install only what we ask for
# Remove apt cache & docs to reduce size
RUN apt-get update && \
    apt-get install -y --no-install-recommends \
        ffmpeg \
        libgl1 \
        libglib2.0-0 \
        libsm6 \
        libxrender1 \
        libxext6 && \
    rm -rf /var/lib/apt/lists/* /usr/share/doc /usr/share/man /usr/share/locale && \
    \
    # Upgrade pip & install Python dependencies (CPU-only Torch)
    pip install --no-cache-dir --upgrade pip && \
    pip install --no-cache-dir \
        torch==2.4.1+cpu \
        torchvision==0.19.1+cpu \
        --index-url https://download.pytorch.org/whl/cpu && \
    pip install --no-cache-dir -r requirements.txt && \
    # Editable install so the package can be imported elsewhere
    pip install --no-cache-dir -e .

# ------------------------------------------------------------
# Networking
# ------------------------------------------------------------
EXPOSE 8000

# ------------------------------------------------------------
# Start FastAPI with auto-reload (remove --reload for production)
# ------------------------------------------------------------
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]