FROM python:3.13-slim AS build
WORKDIR /build
COPY pyproject.toml README.md LICENSE ./
COPY riscon_moat ./riscon_moat
RUN python -m pip wheel --no-cache-dir --wheel-dir /wheels .

FROM python:3.13-slim
RUN mkdir /data && chown 10001:10001 /data
COPY --from=build /wheels /wheels
RUN python -m pip install --no-index --no-cache-dir --find-links /wheels riscon-moat && rm -r /wheels
ENV MOAT_DB=/data/ledger.sqlite3
USER 10001:10001
EXPOSE 8767
VOLUME ["/data"]
ENTRYPOINT ["riscon-moat"]
CMD ["serve", "--host", "0.0.0.0", "--port", "8767"]
