Split deploy into independent poller and web stacks

Decouple the privileged hardware poller from web iterations so a web
redeploy can never recreate/restart the poller (the backplane-touching
container). Two images from one Dockerfile via build targets:

- jbod-poller: privileged producer, ships smartmontools/sg3-utils/ledmon,
  Redis-only deps (~197MB)
- jbod-web: unprivileged read-only consumer (REST/UI/MQTT), no hardware
  tools, no /dev (~147MB)

Two compose projects sharing Redis over host networking:
- compose.infra.yml (jbod-infra): poller + redis — stable substrate
- compose.web.yml   (jbod-web):   app — 'up -d --build' touches only app

build.sh builds/pushes both images; split requirements-{poller,web}.txt;
dropped the combined docker-compose.yml; .dockerignore excludes tmp/ (keeps
the venv and the mqtt.env creds out of the build context).
This commit is contained in:
2026-06-16 15:23:42 +00:00
parent 0f829e0380
commit cccc2bc004
9 changed files with 137 additions and 90 deletions

View File

@@ -1,4 +1,4 @@
# ---- Stage 1: Build frontend ----
# ---- Stage: build frontend ----
FROM node:22-alpine AS frontend-build
WORKDIR /app/frontend
COPY frontend/package.json frontend/package-lock.json* ./
@@ -7,8 +7,10 @@ COPY frontend/ ./
RUN npm run build
# Output: /app/static/
# ---- Stage 2: Production runtime ----
FROM python:3.13-slim
# ---- Target: poller (hardware producer) ----
# Privileged at runtime; the only image with SAS/SMART tooling. Slim Python
# deps (just Redis) — no web stack.
FROM python:3.13-slim AS poller
RUN apt-get update && apt-get install -y --no-install-recommends \
smartmontools \
@@ -20,16 +22,27 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
WORKDIR /app
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
COPY requirements-poller.txt .
RUN pip install --no-cache-dir -r requirements-poller.txt
COPY poller.py .
COPY services/ services/
CMD ["python", "-u", "poller.py"]
# ---- Target: web (read-only consumer) ----
# Unprivileged at runtime; no hardware tools. Serves REST/UI + MQTT, reads Redis.
FROM python:3.13-slim AS web
WORKDIR /app
COPY requirements-web.txt .
RUN pip install --no-cache-dir -r requirements-web.txt
COPY main.py .
COPY poller.py .
COPY routers/ routers/
COPY services/ services/
COPY models/ models/
# Copy built frontend from stage 1
COPY --from=frontend-build /app/static/ static/
EXPOSE 8000