veylant/services/pii/Dockerfile
2026-03-06 18:38:04 +01:00

30 lines
816 B
Docker

FROM python:3.12-slim
WORKDIR /app
# gen/ must be in PYTHONPATH so grpc stubs can resolve 'from pii.v1 import ...'
ENV PYTHONPATH=/app/gen
# Install system dependencies for spaCy compilation
RUN apt-get update && apt-get install -y --no-install-recommends \
gcc \
g++ \
&& rm -rf /var/lib/apt/lists/*
# Install Python dependencies
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
# Download spaCy models at build time to avoid cold-start latency in production.
# fr_core_news_lg (~600MB) is the primary French NER model.
# en_core_web_sm is the English fallback.
RUN python -m spacy download fr_core_news_lg
RUN python -m spacy download en_core_web_sm
# Copy source (after pip install to leverage Docker layer cache)
COPY . .
EXPOSE 8000 50051
CMD ["python", "main.py"]