pyrtan / Dockerfile
1,598 bytes · last changed 2026-10-27 in Drop "hardcoded" from the tagline; describe the trees as inspectable
| 1 | # Pyrtan: one image for a service or a hub. The command decides which. |
| 2 | # |
| 3 | # docker run -p 8701:8701 -v ./trees:/trees pyrtan serve /trees --host 0.0.0.0 |
| 4 | # docker run -p 8700:8700 pyrtan hub --host 0.0.0.0 |
| 5 | # |
| 6 | # The examples are baked in at /examples so the image demos on its own. |
| 7 | FROM python:3.12-slim AS build |
| 8 | WORKDIR /src |
| 9 | COPY pyproject.toml README.md LICENSE ./ |
| 10 | COPY src ./src |
| 11 | RUN pip install --no-cache-dir --prefix=/install . |
| 12 | |
| 13 | FROM python:3.12-slim |
| 14 | LABEL org.opencontainers.image.title="pyrtan" \ |
| 15 | org.opencontainers.image.description="A core set of expandable services that act on all forms of I/O through inspectable decision trees." \ |
| 16 | org.opencontainers.image.source="https://github.com/b-i-t-8/pyrtan" \ |
| 17 | org.opencontainers.image.licenses="AGPL-3.0-or-later" |
| 18 | COPY --from=build /install /usr/local |
| 19 | COPY examples /examples |
| 20 | # The build context keeps the host checkout's modes, which a NAS share |
| 21 | # can leave unreadable to others; the non-root user must read the examples. |
| 22 | RUN chmod -R a+rX /examples \ |
| 23 | && useradd --system --uid 10001 --home /nonexistent --shell /usr/sbin/nologin pyrtan \ |
| 24 | && mkdir -p /trees && chown pyrtan:pyrtan /trees |
| 25 | USER pyrtan |
| 26 | VOLUME ["/trees"] |
| 27 | ENV PYTHONUNBUFFERED=1 PYRTAN_TREES=/trees |
| 28 | EXPOSE 8700 8701 |
| 29 | HEALTHCHECK --interval=30s --timeout=5s --start-period=5s --retries=3 \ |
| 30 | CMD python -c "import os,sys,urllib.request;p=os.environ.get('PYRTAN_PORT','8701');sys.exit(0 if urllib.request.urlopen(f'http://127.0.0.1:{p}/health',timeout=4).status==200 else 1)" |
| 31 | ENTRYPOINT ["pyrtan"] |
| 32 | CMD ["serve", "/examples", "--host", "0.0.0.0", "--port", "8701"] |