-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
64 lines (55 loc) · 2.03 KB
/
Dockerfile
File metadata and controls
64 lines (55 loc) · 2.03 KB
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# ==================================================
# Base image (CPU, slim, production-safe)
# ==================================================
FROM python:3.12-slim
# ==================================================
# Environment
# ==================================================
ENV PYTHONUNBUFFERED=1 \
PYTHONDONTWRITEBYTECODE=1 \
TESSDATA_PREFIX=/usr/share/tesseract-ocr/4.00/tessdata \
TORCH_HOME=/app/.torch
# ==================================================
# System dependencies (OpenCV + OCR + Torch runtime)
# ==================================================
RUN apt-get update && \
DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
build-essential \
tesseract-ocr \
tesseract-ocr-eng \
libglib2.0-0 \
libgl1 \
libsm6 \
libxext6 \
libxrender1 \
ca-certificates \
curl \
git \
&& rm -rf /var/lib/apt/lists/*
# ==================================================
# Work directory
# ==================================================
WORKDIR /app
# ==================================================
# Python dependencies (cached layer)
# ==================================================
COPY requirements.txt .
RUN pip install --no-cache-dir --upgrade pip && \
pip install --no-cache-dir -r requirements.txt
# ==================================================
# Copy project files
# ==================================================
COPY . .
# ==================================================
# Download model weights (build-time, ONCE)
# Safe because ensure_models() is idempotent
# ==================================================
RUN python download_modes.py
# ==================================================
# Expose FastAPI port
# ==================================================
EXPOSE 8000
# ==================================================
# Start FastAPI server
# ==================================================
CMD ["uvicorn", "server:app", "--host", "0.0.0.0", "--port", "8000"]