File size: 942 Bytes
b7ff3ad
 
7d21e3f
b7ff3ad
 
7d21e3f
 
b7ff3ad
 
3675b6b
b7ff3ad
 
 
 
3675b6b
b7ff3ad
 
 
 
 
 
3675b6b
 
 
b7ff3ad
7d21e3f
b7ff3ad
 
 
 
7d21e3f
b7ff3ad
 
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
FROM python:3.10

# 1. Install system dependencies
RUN apt-get update && apt-get install -y \
    git \
    libgl1 \
    libglib2.0-0 \
    && rm -rf /var/lib/apt/lists/*

# 2. Create user
RUN useradd -m -u 1000 user
USER user
ENV PATH="/home/user/.local/bin:$PATH"

# 3. Install Torch dependencies FIRST
RUN pip install --no-cache-dir pip --upgrade && \
    pip install --no-cache-dir \
    torch==2.0.1+cpu \
    torchvision==0.15.2+cpu \
    --extra-index-url https://download.pytorch.org/whl/cpu

# 4. Install Detectron2 with --no-build-isolation
# This flag fixes the "No module named torch" error
RUN pip install --no-cache-dir --no-build-isolation git+https://github.com/facebookresearch/detectron2.git

# 5. Install the requirements.txt 
WORKDIR /app
COPY --chown=user ./requirements.txt requirements.txt
RUN pip install --no-cache-dir -r requirements.txt

# 6. Copy app files and run
COPY --chown=user . /app
CMD ["python", "app.py"]