Exposes host CPU, memory, disk, and network usage over HTTP for the dashboard's System Stats block (or anything else that can send a header) to poll. Auth is a required X-API-Key, auto-generated and persisted on first run if not supplied, checked with a constant-time comparison and rate-limited after repeated failures. No CORS, so a browser can't call it directly from another origin -- only a server-side caller can, keeping the key out of anyone's network tab.
24 lines
591 B
Docker
24 lines
591 B
Docker
FROM python:3.12-slim
|
|
|
|
RUN useradd --create-home --shell /usr/sbin/nologin agent
|
|
|
|
WORKDIR /app
|
|
COPY requirements.txt .
|
|
RUN pip install --no-cache-dir -r requirements.txt
|
|
|
|
COPY app ./app
|
|
|
|
ENV PYTHONUNBUFFERED=1 \
|
|
AGENT_DATA_DIR=/data
|
|
|
|
RUN mkdir -p /data && chown agent:agent /data
|
|
USER agent
|
|
|
|
EXPOSE 9090
|
|
VOLUME ["/data"]
|
|
|
|
HEALTHCHECK --interval=30s --timeout=5s --start-period=5s --retries=3 \
|
|
CMD ["python", "-c", "import urllib.request; urllib.request.urlopen('http://127.0.0.1:9090/api/health', timeout=3)"]
|
|
|
|
CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "9090"]
|