codewithRiz commited on
Commit
9d117bd
·
verified ·
1 Parent(s): eabc1b5

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +51 -0
Dockerfile CHANGED
@@ -0,0 +1,51 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # ----------------------------
2
+ # Stage 1: Builder
3
+ # ----------------------------
4
+ FROM python:3.12-slim AS builder
5
+
6
+ WORKDIR /app
7
+
8
+ # Install only what is needed for building wheels
9
+ RUN apt-get update && apt-get install -y --no-install-recommends \
10
+ build-essential \
11
+ gcc \
12
+ libgl1 \
13
+ && rm -rf /var/lib/apt/lists/*
14
+
15
+ # Copy dependencies file
16
+ COPY requirements.txt .
17
+
18
+ # Install dependencies into a temporary folder
19
+ RUN pip install --upgrade pip && \
20
+ pip install --prefix=/install --no-cache-dir -r requirements.txt
21
+
22
+ # Copy source
23
+ COPY . .
24
+
25
+ # ----------------------------
26
+ # Stage 2: Runtime (minimal size)
27
+ # ----------------------------
28
+ FROM python:3.12-slim
29
+
30
+ WORKDIR /app
31
+
32
+ # Install minimal runtime libraries only
33
+ RUN apt-get update && apt-get install -y --no-install-recommends \
34
+ libgl1 \
35
+ libglib2.0-0 \
36
+ && rm -rf /var/lib/apt/lists/*
37
+
38
+ # Copy only installed python deps
39
+ COPY --from=builder /install /usr/local
40
+
41
+ # Copy only application code (not build deps)
42
+ COPY --from=builder /app /app
43
+
44
+ # Reduce Python overhead
45
+ ENV PYTHONUNBUFFERED=1
46
+ ENV PYTHONDONTWRITEBYTECODE=1
47
+
48
+ EXPOSE 7860
49
+
50
+ # Use multiple workers in a lightweight way
51
+ CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]