File size: 1,133 Bytes
b12284c
 
 
 
 
 
 
 
 
 
dc9cb16
b12284c
 
 
 
 
dc9cb16
b12284c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
FROM python:3.12-slim

# System dependencies: Tesseract OCR, OpenCV headless deps, WeasyPrint
RUN apt-get update && apt-get install -y --no-install-recommends \
    # Tesseract OCR
    tesseract-ocr \
    tesseract-ocr-eng \
    libtesseract-dev \
    leptonica-progs \
    # OpenCV headless deps
    libgl1 \
    libglib2.0-0 \
    # WeasyPrint deps
    libpango-1.0-0 \
    libpangocairo-1.0-0 \
    libcairo2 \
    libgdk-pixbuf-2.0-0 \
    libffi-dev \
    libharfbuzz0b \
    # Font rendering
    fonts-liberation \
    fonts-dejavu \
    fontconfig \
    # Utilities
    wget \
    && rm -rf /var/lib/apt/lists/*

WORKDIR /app

# Python deps
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt

# Application code
COPY app/ ./app/

# Temp directories
RUN mkdir -p /tmp/handbook_uploads /tmp/handbook_exports

# Env defaults
COPY .env.example .env.example
ENV PORT=7860
EXPOSE 7860

# Single worker — OCR is CPU-intensive; keep memory bounded
CMD ["sh", "-c", "uvicorn app.main:app --host 0.0.0.0 --port ${PORT:-7860} --workers 1 --timeout-keep-alive 300"]