# Production backend image for Arabic diacritization API (FastAPI + Diac + Whisper). # Build context: project root (see docker-compose.yml). FROM python:3.12-slim-bookworm ENV PYTHONDONTWRITEBYTECODE=1 \ PYTHONUNBUFFERED=1 \ PYTHONPATH=/app \ HF_HOME=/cache/huggingface \ TRANSFORMERS_CACHE=/cache/huggingface \ PIP_NO_CACHE_DIR=1 WORKDIR /app # git: install diac from GitHub; ffmpeg: audio format fallback in asr_service.py RUN apt-get update && apt-get install -y --no-install-recommends \ git \ build-essential \ ffmpeg \ libsndfile1 \ curl \ && rm -rf /var/lib/apt/lists/* COPY backend/requirements.txt ./backend/requirements.txt RUN pip install --no-cache-dir -r backend/requirements.txt COPY backend ./backend COPY app ./app COPY constants ./constants RUN useradd --create-home --uid 1000 appuser \ && mkdir -p /cache/huggingface \ && chown -R appuser:appuser /app /cache/huggingface USER appuser EXPOSE 8000 HEALTHCHECK --interval=30s --timeout=10s --start-period=180s --retries=3 \ CMD curl -f http://127.0.0.1:8000/health || exit 1 CMD ["uvicorn", "backend.app.main:app", "--host", "0.0.0.0", "--port", "8000"]