# Build from a verified source archive, not from the development checkout.
FROM python:3.12-slim-bookworm
ENV PYTHONDONTWRITEBYTECODE=1 PYTHONUNBUFFERED=1 OPENBLAS_NUM_THREADS=2 OMP_NUM_THREADS=2
ENV NUMBA_CACHE_DIR=/tmp/numba-cache
WORKDIR /site
COPY release/requirements.lock /tmp/requirements.lock
RUN pip install --no-cache-dir -r /tmp/requirements.lock
ARG RELEASE_COMMIT=downloaded-source
LABEL org.opencontainers.image.revision=$RELEASE_COMMIT
COPY . /site
RUN python scripts/package-release.py --repack /site --output /opt/source-release
RUN python scripts/fetch-models.py
RUN python scripts/fetch-singing-model.py
EXPOSE 8124
HEALTHCHECK --interval=30s --timeout=5s --retries=3 CMD python -c "import urllib.request; urllib.request.urlopen('http://127.0.0.1:8124/healthz')"
CMD ["python", "server/app.py", "--bind", "0.0.0.0", "--port", "8124", "--data", "/data", "--release", "/opt/source-release"]
