2026-02-07 10:48:22 +00:00
|
|
|
# Stage 1: Build dependencies
|
|
|
|
|
FROM python:3.13-slim AS builder
|
2025-05-21 21:30:00 +00:00
|
|
|
|
|
|
|
|
RUN apt-get update && apt-get install -y --no-install-recommends \
|
|
|
|
|
build-essential \
|
|
|
|
|
gcc \
|
|
|
|
|
python3-dev \
|
|
|
|
|
libopencv-dev \
|
2026-02-07 10:48:22 +00:00
|
|
|
libmariadb-dev \
|
|
|
|
|
&& rm -rf /var/lib/apt/lists/*
|
|
|
|
|
|
|
|
|
|
WORKDIR /app
|
|
|
|
|
|
|
|
|
|
COPY requirements.txt ./
|
|
|
|
|
|
|
|
|
|
# Install dependencies into a venv using pip (no poetry needed)
|
|
|
|
|
RUN python -m venv /app/.venv && \
|
|
|
|
|
/app/.venv/bin/pip install --no-cache-dir -r requirements.txt
|
|
|
|
|
|
|
|
|
|
# Stage 2: Runtime image
|
|
|
|
|
FROM python:3.13-slim
|
|
|
|
|
|
|
|
|
|
# Install only runtime system dependencies (no build tools)
|
|
|
|
|
RUN apt-get update && apt-get install -y --no-install-recommends \
|
2025-05-21 21:30:00 +00:00
|
|
|
libgl1 \
|
|
|
|
|
libglib2.0-0 \
|
|
|
|
|
tesseract-ocr \
|
|
|
|
|
tesseract-ocr-eng \
|
2026-02-07 10:48:22 +00:00
|
|
|
libmariadb3 \
|
2025-05-21 21:30:00 +00:00
|
|
|
&& rm -rf /var/lib/apt/lists/*
|
|
|
|
|
|
|
|
|
|
WORKDIR /app
|
|
|
|
|
|
2026-02-07 10:48:22 +00:00
|
|
|
# Copy the venv from the builder stage
|
|
|
|
|
COPY --from=builder /app/.venv /app/.venv
|
2025-05-21 21:30:00 +00:00
|
|
|
|
|
|
|
|
ENV PATH="/app/.venv/bin:$PATH"
|
|
|
|
|
|
|
|
|
|
# Copy the application code
|
|
|
|
|
COPY . .
|
|
|
|
|
|
2025-06-24 19:12:20 +00:00
|
|
|
EXPOSE 5001
|
2026-02-06 20:55:10 +00:00
|
|
|
CMD ["uvicorn", "api.app:app", "--host", "0.0.0.0", "--port", "5001"]
|