JumaRubea commited on
Commit
ddb819d
·
verified ·
1 Parent(s): 243d0a8

creating dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +57 -0
Dockerfile CHANGED
@@ -0,0 +1,57 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Use Python 3.9 slim as the base image
2
+ FROM python:3.9-slim
3
+
4
+ # Set environment variables
5
+ ENV PYTHONUNBUFFERED=1 \
6
+ DEBIAN_FRONTEND=noninteractive
7
+
8
+ # Install system dependencies
9
+ RUN apt-get update && apt-get install -y --no-install-recommends \
10
+ git \
11
+ wget \
12
+ build-essential \
13
+ python3-dev \
14
+ cmake \
15
+ libopencv-dev \
16
+ libglib2.0-0 \
17
+ libsm6 \
18
+ libxext6 \
19
+ libxrender1 \
20
+ && apt-get clean && rm -rf /var/lib/apt/lists/*
21
+
22
+ # Set the working directory
23
+ WORKDIR /app
24
+
25
+ # Install PyTorch CPU version
26
+ RUN pip3 install --no-cache-dir torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cpu
27
+
28
+ # Install Python dependencies
29
+ RUN pip3 install --no-cache-dir \
30
+ numpy \
31
+ pyyaml \
32
+ fastapi \
33
+ uvicorn \
34
+ python-multipart \
35
+ opencv-python-headless \
36
+ scipy \
37
+ pillow
38
+
39
+ # Clone and install Detectron2
40
+ RUN git clone https://github.com/facebookresearch/detectron2.git && \
41
+ cd detectron2 && \
42
+ python setup.py build develop && \
43
+ cd .. && rm -rf detectron2/.git
44
+
45
+ # Copy application files
46
+ COPY ./app /app
47
+ COPY ./mask_rcnn_config.yaml /app/
48
+ COPY ./model_final.pth /app/
49
+
50
+ # Create directory for uploads
51
+ RUN mkdir -p /app/uploads && chmod -R 777 /app/uploads
52
+
53
+ # Expose the application port
54
+ EXPOSE 8000
55
+
56
+ # Set the command to run the FastAPI server
57
+ CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8000", "--workers", "1"]