FROM python:3.12-slim
WORKDIR /app

ENV PIP_DEFAULT_TIMEOUT=300 PIP_RETRIES=10 PYTHONDONTWRITEBYTECODE=1
COPY requirements.txt ./
RUN pip install --no-cache-dir -r requirements.txt

COPY . .
RUN rm -rf tests .venv && python -c "import server"   # fail the build, not the pod, on import errors

RUN groupadd -g 1001 novaos && useradd -r -u 1001 -g 1001 -s /bin/false novaos && chown -R novaos:novaos /app
USER novaos

# NovaOS runs agents with a read-only root filesystem; only /tmp is writable.
ENV TMPDIR=/tmp HOME=/tmp XDG_CACHE_HOME=/tmp/.cache SERVER_PORT=8001
EXPOSE 8001
CMD ["uvicorn", "server:app", "--host", "0.0.0.0", "--port", "8001"]
