# Use Python 3.11 slim image as base FROM python:3.11-slim # Set environment variables ENV PYTHONDONTWRITEBYTECODE=1 \ PYTHONUNBUFFERED=1 \ PYTHONPATH=/app \ POETRY_VERSION=1.7.1 \ POETRY_HOME="/opt/poetry" \ POETRY_VENV_IN_PROJECT=1 \ POETRY_NO_INTERACTION=1 # Add Poetry to PATH ENV PATH="$POETRY_HOME/bin:$PATH" # Install system dependencies RUN apt-get update && apt-get install -y \ curl \ build-essential \ libpq-dev \ tesseract-ocr \ tesseract-ocr-eng \ libtesseract-dev \ pkg-config \ libcairo2-dev \ libpango1.0-dev \ libglib2.0-dev \ libjpeg-dev \ libpng-dev \ libtiff-dev \ libwebp-dev \ libopenjp2-7-dev \ libgif-dev \ libmagickwand-dev \ && rm -rf /var/lib/apt/lists/* # Install Poetry RUN curl -sSL https://install.python-poetry.org | python3 - # Set work directory WORKDIR /app # Copy Poetry configuration files COPY pyproject.toml poetry.lock* ./ # Install Python dependencies RUN poetry install --only=main,dev --no-root # Copy application code COPY . . # Create necessary directories RUN mkdir -p logs uploads temp # Set permissions RUN chmod +x scripts/*.sh # Expose port EXPOSE 8000 # Default command CMD ["poetry", "run", "uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "8000", "--reload"]