WSLINMSAI commited on
Commit
b7ff3ad
·
verified ·
1 Parent(s): 723f99a

Create Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +35 -0
Dockerfile ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ FROM python:3.10
2
+
3
+ # 1. Install system dependencies (Git and GL libraries are required)
4
+ RUN apt-get update && apt-get install -y \
5
+ git \
6
+ libgl1-mesa-glx \
7
+ && rm -rf /var/lib/apt/lists/*
8
+
9
+ # 2. Create a user (Hugging Face Spaces best practice)
10
+ RUN useradd -m -u 1000 user
11
+ USER user
12
+ ENV PATH="/home/user/.local/bin:$PATH"
13
+
14
+ # 3. Install Torch and Torchvision FIRST
15
+ # We force this to happen before Detectron is even looked at
16
+ RUN pip install --no-cache-dir pip --upgrade && \
17
+ pip install --no-cache-dir \
18
+ torch==2.0.1+cpu \
19
+ torchvision==0.15.2+cpu \
20
+ --extra-index-url https://download.pytorch.org/whl/cpu
21
+
22
+ # 4. Install Detectron2
23
+ # Now that Torch is installed, this build will succeed
24
+ RUN pip install --no-cache-dir git+https://github.com/facebookresearch/detectron2.git
25
+
26
+ # 5. Install remaining requirements
27
+ WORKDIR /app
28
+ COPY --chown=user ./requirements.txt requirements.txt
29
+ RUN pip install --no-cache-dir -r requirements.txt
30
+
31
+ # 6. Copy the rest of your app
32
+ COPY --chown=user . /app
33
+
34
+ # 7. Launch the app
35
+ CMD ["python", "app.py"]