File size: 1,187 Bytes
ce9fbaa
 
 
 
0b083c6
 
 
ce9fbaa
 
 
 
0b083c6
 
 
ce9fbaa
0b083c6
ce9fbaa
 
 
 
 
0b083c6
 
 
 
 
 
 
 
 
ce9fbaa
 
 
 
 
0b083c6
 
 
ce9fbaa
 
 
0b083c6
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
# 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"]