Shaikhsarib commited on
Commit
1dba2a4
·
verified ·
1 Parent(s): 7498ab7

Upload Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +37 -0
Dockerfile ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Build Stage
2
+ FROM python:3.11-slim as builder
3
+
4
+ WORKDIR /app
5
+ RUN apt-get update && apt-get install -y build-essential
6
+
7
+ COPY requirements.txt .
8
+ # Install to a temp folder, then copy to global path
9
+ RUN pip install --no-cache-dir --prefix=/install -r requirements.txt
10
+
11
+ # Final Stage
12
+ FROM python:3.11-slim
13
+
14
+ WORKDIR /app
15
+
16
+ # Install runtime libs for OpenCV/OCR
17
+ RUN apt-get update && apt-get install -y \
18
+ libgl1 libglib2.0-0 libsm6 libxext6 libxrender1 libgomp1 \
19
+ && rm -rf /var/lib/apt/lists/*
20
+
21
+ # Copy installed packages to global system path
22
+ COPY --from=builder /install /usr/local
23
+
24
+ # Setup App
25
+ COPY main.py .
26
+ COPY index.html .
27
+
28
+ # Create cache directories with correct permissions
29
+ RUN mkdir -p /app/.cache /app/data && chmod 777 /app/.cache /app/data
30
+ ENV HF_HOME=/app/.cache
31
+
32
+ # Create user
33
+ RUN useradd -m -u 1000 user && chown -R user:user /app
34
+ USER user
35
+
36
+ EXPOSE 7860
37
+ CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]