1- # ─────────────────────────────────────────────────────────────────
2- # MeshPi HOST image
3- # Runs: meshpi host (FastAPI + WebSocket + mDNS advertisement)
4- #
5- # Build: docker build -t meshpi-host -f docker/host/Dockerfile .
6- # Run: docker run -p 7422:7422 meshpi-host
7- # ─────────────────────────────────────────────────────────────────
8- FROM python:3.12-slim-bookworm AS builder
1+ """
2+ MeshPi Host Docker Image
93
10- WORKDIR /build
11- COPY pyproject.toml README.md LICENSE ./
12- COPY meshpi/ ./ meshpi/
4+ Usage:
5+ docker build -t meshpi-host .
6+ docker run -p 7422:7422 meshpi-host
137
14- RUN pip install --no-cache-dir build && \
15- python -m build --wheel && \
16- ls dist/
8+ Environment Variables:
9+ MESHPI_PORT - Host port (default: 7422)
10+ MESHPI_BIND - Bind address (default: 0.0.0.0)
11+ MESHPI_CONFIG_DIR - Config directory (default: /app/config)
12+ """
1713
14+ FROM python:3.11-slim
1815
19- FROM python:3.12-slim-bookworm
20-
21- LABEL maintainer="Softreck <info@softreck.dev>"
22- LABEL description="MeshPi Host — encrypted RPi fleet configuration server"
16+ LABEL maintainer="MeshPi"
2317LABEL version="0.2.0"
24- LABEL license="Apache-2.0"
18+ LABEL description="MeshPi Host Service for Raspberry Pi Fleet Management"
19+
20+ # Set environment variables
21+ ENV PYTHONUNBUFFERED=1
22+ ENV PYTHONDONTWRITEBYTECODE=1
23+ ENV MESHPI_PORT=7422
24+ ENV MESHPI_BIND=0.0.0.0
25+ ENV MESHPI_CONFIG_DIR=/app/config
2526
26- # Runtime dependencies only
27+ # Install system dependencies
2728RUN apt-get update && apt-get install -y --no-install-recommends \
28- iputils-ping \
29+ curl \
2930 avahi-daemon \
3031 avahi-utils \
3132 libnss-mdns \
32- dbus \
3333 && rm -rf /var/lib/apt/lists/*
3434
35+ # Create app directory
3536WORKDIR /app
3637
37- # Copy built wheel from builder stage
38- COPY --from=builder /build/dist/*.whl /tmp/
39- RUN pip install --no-cache-dir /tmp/*.whl "meshpi[llm]" 2>/dev/null || \
40- pip install --no-cache-dir /tmp/*.whl && \
41- rm /tmp/*.whl
38+ # Create non-root user
39+ RUN useradd -m -u 1000 meshpi && \
40+ mkdir -p /app/config /app/data && \
41+ chown -R meshpi:meshpi /app
4242
43- # Create meshpi config directory
44- RUN mkdir -p /root/.meshpi && chmod 700 /root/.meshpi
43+ # Install Python dependencies
44+ COPY pyproject.toml .
45+ RUN pip install --no-cache-dir -e . && \
46+ pip install --no-cache-dir prometheus-client pyyaml
4547
46- # Copy entrypoint
47- COPY docker/host/entrypoint.sh /entrypoint.sh
48- RUN chmod +x /entrypoint.sh
48+ # Copy application code
49+ COPY --chown=meshpi:meshpi . .
4950
50- # Config volume — mount your config.env here
51- VOLUME ["/root/.meshpi" ]
52-
53- # Default environment
54- ENV MESHPI_PORT=7422
55- ENV MESHPI_BIND=0.0.0.0
56- ENV PYTHONUNBUFFERED=1
51+ # Switch to non-root user
52+ USER meshpi
5753
54+ # Expose ports
5855EXPOSE 7422
5956
60- HEALTHCHECK --interval=30s --timeout=5s --start-period=10s --retries=3 \
61- CMD python -c "import httpx; httpx.get('http://localhost:7422/health', timeout=4).raise_for_status()"
57+ # Health check
58+ HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
59+ CMD curl -f http://localhost:7422/health || exit 1
6260
63- ENTRYPOINT [ "/entrypoint.sh" ]
64- CMD ["host" ]
61+ # Run the host service
62+ CMD ["python" , "-m" , "meshpi. host" ]
0 commit comments