mirror of
https://github.com/ipnet-mesh/meshcore-hub.git
synced 2026-10-30 19:52:03 +01:00
Remove the upgrade-compatibility items scheduled for v0.20 in the v0.19 release notes: - the `meshcore-hub db migrate-to-postgres` command and its `common/db_migrate.py` module (with its dedicated tests) - the `database_backend` settings field and its legacy-backend validator (a leftover DATABASE_BACKEND is now silently ignored) - the `[postgres]` pip extra alias (Dockerfile installs `.` now) `tests/test_main.py` is rewritten as a minimal CLI smoke test to keep entry-point coverage. Docs updated: v0.20.0 upgrade section notes the removals (SQLite deployments must upgrade through v0.19 first), README and database.md pointers reworded, stale .env.example comment dropped.
120 lines
3.9 KiB
Docker
120 lines
3.9 KiB
Docker
# MeshCore Hub - Multi-stage Dockerfile
|
|
# Build and run MeshCore Hub components
|
|
|
|
# =============================================================================
|
|
# Stage 1: Frontend - Build Tailwind CSS and vendor static assets
|
|
# =============================================================================
|
|
FROM node:24-slim AS frontend
|
|
|
|
WORKDIR /app
|
|
|
|
COPY package.json package-lock.json ./
|
|
RUN npm ci
|
|
|
|
COPY build.js vite.config.ts tsconfig.json ./
|
|
COPY src/meshcore_hub/web/static/css/input.css ./src/meshcore_hub/web/static/css/input.css
|
|
COPY src/meshcore_hub/web/templates/ ./src/meshcore_hub/web/templates/
|
|
COPY src/meshcore_hub/web/static/js/ ./src/meshcore_hub/web/static/js/
|
|
RUN npm run build
|
|
|
|
# =============================================================================
|
|
# Stage 2: Builder - Install dependencies and build package
|
|
# =============================================================================
|
|
FROM python:3.14-slim AS builder
|
|
|
|
# Set environment variables
|
|
ENV PYTHONDONTWRITEBYTECODE=1 \
|
|
PYTHONUNBUFFERED=1 \
|
|
PIP_NO_CACHE_DIR=1 \
|
|
PIP_DISABLE_PIP_VERSION_CHECK=1
|
|
|
|
# Install build dependencies
|
|
RUN apt-get update && apt-get install -y --no-install-recommends \
|
|
build-essential \
|
|
&& rm -rf /var/lib/apt/lists/*
|
|
|
|
# Create and use virtual environment
|
|
RUN python -m venv /opt/venv
|
|
ENV PATH="/opt/venv/bin:$PATH"
|
|
|
|
# Copy project files
|
|
WORKDIR /app
|
|
COPY pyproject.toml README.md ./
|
|
COPY src/ ./src/
|
|
COPY alembic/ ./alembic/
|
|
COPY alembic.ini ./
|
|
|
|
# Overlay built frontend assets onto source tree
|
|
COPY --from=frontend /app/src/meshcore_hub/web/static/vendor ./src/meshcore_hub/web/static/vendor
|
|
COPY --from=frontend /app/src/meshcore_hub/web/static/css/tailwind.css ./src/meshcore_hub/web/static/css/tailwind.css
|
|
COPY --from=frontend /app/src/meshcore_hub/web/static/dist ./src/meshcore_hub/web/static/dist
|
|
|
|
# Build argument for version (set via CI or manually)
|
|
ARG BUILD_VERSION=dev
|
|
|
|
# Set version in _version.py and install the package
|
|
RUN sed -i "s|__version__ = \"dev\"|__version__ = \"${BUILD_VERSION}\"|" src/meshcore_hub/_version.py && \
|
|
pip install --upgrade pip && \
|
|
pip install "."
|
|
|
|
# =============================================================================
|
|
# Stage 3: Runtime - Final production image
|
|
# =============================================================================
|
|
FROM python:3.14-slim AS runtime
|
|
|
|
# Labels
|
|
LABEL org.opencontainers.image.title="MeshCore Hub" \
|
|
org.opencontainers.image.description="Python monorepo for managing MeshCore mesh networks" \
|
|
org.opencontainers.image.source="https://github.com/ipnet-mesh/meshcore-hub"
|
|
|
|
# Set environment variables
|
|
ENV PYTHONDONTWRITEBYTECODE=1 \
|
|
PYTHONUNBUFFERED=1 \
|
|
# Default configuration
|
|
LOG_LEVEL=INFO \
|
|
MQTT_HOST=mqtt \
|
|
MQTT_PORT=1883 \
|
|
MQTT_PREFIX=meshcore \
|
|
DATA_HOME=/data \
|
|
API_HOST=0.0.0.0 \
|
|
API_PORT=8000 \
|
|
WEB_HOST=0.0.0.0 \
|
|
WEB_PORT=8080 \
|
|
API_BASE_URL=http://api:8000
|
|
|
|
# Install runtime dependencies
|
|
RUN apt-get update && apt-get install -y --no-install-recommends \
|
|
# For serial port access
|
|
udev \
|
|
&& rm -rf /var/lib/apt/lists/* \
|
|
&& mkdir -p /data
|
|
|
|
# Copy virtual environment from builder
|
|
COPY --from=builder /opt/venv /opt/venv
|
|
ENV PATH="/opt/venv/bin:$PATH"
|
|
|
|
# Copy alembic configuration for migrations
|
|
WORKDIR /app
|
|
COPY --from=builder /app/alembic.ini ./
|
|
COPY --from=builder /app/alembic/ ./alembic/
|
|
|
|
# Create non-root user
|
|
RUN useradd --create-home --shell /bin/bash meshcore && \
|
|
chown -R meshcore:meshcore /data /app
|
|
|
|
# Default to non-root user (can be overridden for device access)
|
|
USER meshcore
|
|
|
|
# Expose common ports
|
|
EXPOSE 8000 8080
|
|
|
|
# Health check - uses the API health endpoint by default
|
|
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
|
|
CMD python -c "import urllib.request; urllib.request.urlopen('http://localhost:8000/health')" || exit 1
|
|
|
|
# Set entrypoint to the CLI
|
|
ENTRYPOINT ["meshcore-hub"]
|
|
|
|
# Default command shows help
|
|
CMD ["--help"]
|