FROM python:3.12-slim

# onnxruntime (fastembed) needs libgomp at runtime
RUN apt-get update && apt-get install -y --no-install-recommends libgomp1 \
    && rm -rf /var/lib/apt/lists/*

WORKDIR /app
COPY . /app
RUN pip install --no-cache-dir ".[server]"

# Pre-download the default model into the image so first start is fast (optional;
# remove to keep the image small and download on first run instead).
RUN python -c "from fastembed import TextEmbedding; TextEmbedding('intfloat/multilingual-e5-small')"

ENV OMCS_HOST=0.0.0.0 \
    OMCS_PORT=8848 \
    OMCS_CACHE_DIR=/data/cache \
    OMCS_CONFIG_DIR=/data/config

EXPOSE 8848
COPY docker/entrypoint.sh /entrypoint.sh
RUN chmod +x /entrypoint.sh
ENTRYPOINT ["/entrypoint.sh"]
