Spaces:
Running
Running
File size: 1,627 Bytes
8d817d1 fc3bf2a 8d817d1 fc3bf2a 8d817d1 fc3bf2a 8d817d1 fc3bf2a c6a9250 fc3bf2a 8d817d1 fc3bf2a bb68da2 13b60b7 | 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 | # Use a slim Python image (matches local development Python 3.12 artifacts)
FROM python:3.12-slim AS builder
# Metadata
LABEL maintainer="techtrans <phaethon@phaethon.llc>"
# Environment - Optimized for Cloud Run and Cloud Logging
ENV PYTHONDONTWRITEBYTECODE=1 \
PYTHONUNBUFFERED=1 \
PIP_DISABLE_PIP_VERSION_CHECK=1 \
PORT=7860 \
PYTHONPATH=/app
WORKDIR /app
# Install system dependencies required by some Python packages (Tesseract for OCR, libs for images/PDFs)
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
build-essential \
tesseract-ocr \
poppler-utils \
libgl1 \
wget \
ca-certificates \
git \
&& rm -rf /var/lib/apt/lists/*
# Copy requirements first to leverage Docker cache
COPY requirements.txt .
# Install Python dependencies (include gunicorn for production)
RUN pip wheel --no-cache-dir --wheel-dir /wheels -r requirements.txt
FROM python:3.12-slim
ENV PYTHONDONTWRITEBYTECODE=1 \
PYTHONUNBUFFERED=1 \
PIP_DISABLE_PIP_VERSION_CHECK=1 \
PORT=7860
WORKDIR /app
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
tesseract-ocr \
poppler-utils \
libgl1 \
wget \
ca-certificates \
git \
&& rm -rf /var/lib/apt/lists/*
COPY --from=builder /wheels /wheels
RUN pip install --no-cache-dir /wheels/*
COPY . .
USER root
COPY entrypoint.sh /entrypoint.sh
RUN chmod +x /entrypoint.sh
ENTRYPOINT ["/entrypoint.sh"]
CMD ["bash", "-lc", "exec gunicorn 'app:create_app()' --bind 0.0.0.0:${PORT} --workers 1 --threads 1 --timeout ${GUNICORN_TIMEOUT:-1200} --access-logfile - --error-logfile -"] |