# Dockerfile-server-base
# Base image with system dependencies and Python packages (matches upstream layout;
# locale and comments are Western; pip install kept compatible with openai-whisper).

FROM python:3.10-slim

# System packages: audio stack + locales for UTF-8 (en_US, not zh_CN)
RUN apt-get update && \
    apt-get install -y --no-install-recommends libopus0 ffmpeg locales && \
    sed -i '/en_US.UTF-8/s/^# //g' /etc/locale.gen && \
    locale-gen && \
    apt-get clean && \
    rm -rf /var/lib/apt/lists/*

# Pip network resilience (default PyPI index)
RUN pip config set global.timeout 120 && \
    pip config set install.retries 5

ENV LANG=en_US.UTF-8 \
    LC_ALL=en_US.UTF-8 \
    LANGUAGE=en_US:en \
    PYTHONIOENCODING=utf-8

WORKDIR /opt/xiaozhi-esp32-server

COPY main/xiaozhi-server/requirements.txt .

# openai-whisper uses legacy setuptools hooks; pin setuptools and skip build isolation
RUN pip install --no-cache-dir --upgrade pip "setuptools<81" wheel && \
    pip install --no-cache-dir --no-build-isolation -r requirements.txt --default-timeout=120 --retries 5
