2025-10-12 20:41:39 -07:00
|
|
|
# Use Python 3.11 slim image for smaller size
|
2025-10-29 21:55:10 -07:00
|
|
|
FROM python:3.11-slim AS base
|
2025-10-12 20:41:39 -07:00
|
|
|
|
2025-10-26 10:33:18 -07:00
|
|
|
# Install system dependencies for BLE, serial communication
|
2025-10-25 09:55:36 -07:00
|
|
|
# Use --no-install-recommends to minimize package size
|
|
|
|
|
RUN apt-get update && apt-get install -y --no-install-recommends \
|
2025-10-12 20:41:39 -07:00
|
|
|
bluez \
|
|
|
|
|
libbluetooth-dev \
|
2025-10-25 10:00:44 -07:00
|
|
|
curl \
|
2025-10-25 09:55:36 -07:00
|
|
|
&& rm -rf /var/lib/apt/lists/* \
|
|
|
|
|
&& apt-get clean
|
2025-10-12 20:41:39 -07:00
|
|
|
|
|
|
|
|
# Set working directory
|
|
|
|
|
WORKDIR /app
|
|
|
|
|
|
2025-10-25 09:55:36 -07:00
|
|
|
# Create non-root user for security (do this early to avoid permission issues)
|
|
|
|
|
RUN useradd -m -u 1000 meshcore
|
|
|
|
|
|
2025-10-12 20:41:39 -07:00
|
|
|
# Copy requirements first for better Docker layer caching
|
|
|
|
|
COPY requirements.txt .
|
|
|
|
|
|
2025-10-25 09:55:36 -07:00
|
|
|
# Install Python dependencies with optimizations
|
|
|
|
|
RUN pip install --no-cache-dir --upgrade pip \
|
|
|
|
|
&& pip install --no-cache-dir -r requirements.txt \
|
|
|
|
|
&& pip cache purge
|
2025-10-12 20:41:39 -07:00
|
|
|
|
2025-10-26 10:33:18 -07:00
|
|
|
# Install Node.js via nvm and meshcore-decoder for auth token support
|
2025-10-26 18:50:18 -07:00
|
|
|
ENV NVM_DIR=/opt/nvm
|
2025-10-26 10:56:37 -07:00
|
|
|
ENV NODE_VERSION=lts/*
|
2025-10-26 10:33:18 -07:00
|
|
|
|
2025-10-26 18:50:18 -07:00
|
|
|
RUN mkdir -p "$NVM_DIR" && \
|
|
|
|
|
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash \
|
2025-10-26 10:33:18 -07:00
|
|
|
&& . "$NVM_DIR/nvm.sh" \
|
|
|
|
|
&& nvm install $NODE_VERSION \
|
|
|
|
|
&& nvm use $NODE_VERSION \
|
|
|
|
|
&& npm install -g @michaelhart/meshcore-decoder \
|
2025-10-26 10:56:37 -07:00
|
|
|
&& ln -s "$NVM_DIR/versions/node/$(ls $NVM_DIR/versions/node | head -1)/bin/"* /usr/local/bin/
|
2025-10-25 10:00:44 -07:00
|
|
|
|
|
|
|
|
# Copy application files
|
2025-10-25 10:03:29 -07:00
|
|
|
COPY --chown=meshcore:meshcore packet_capture.py enums.py auth_token.py ./
|
2025-10-12 20:41:39 -07:00
|
|
|
|
|
|
|
|
# Create data directory for output files
|
2025-10-25 09:55:36 -07:00
|
|
|
RUN mkdir -p /app/data && chown -R meshcore:meshcore /app
|
2025-10-12 20:41:39 -07:00
|
|
|
|
2025-10-25 09:55:36 -07:00
|
|
|
# Switch to non-root user
|
|
|
|
|
USER meshcore
|
2025-10-12 20:41:39 -07:00
|
|
|
|
|
|
|
|
# Set default environment variables
|
2026-01-09 10:17:11 -08:00
|
|
|
# Note: These are defaults - override in docker-compose.yml or .env.local
|
|
|
|
|
ENV PACKETCAPTURE_CONNECTION_TYPE=serial \
|
2025-10-25 09:55:36 -07:00
|
|
|
PYTHONUNBUFFERED=1 \
|
|
|
|
|
PYTHONDONTWRITEBYTECODE=1
|
|
|
|
|
|
|
|
|
|
# Health check
|
|
|
|
|
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
|
|
|
|
|
CMD python -c "import meshcore; print('OK')" || exit 1
|
2025-10-12 20:41:39 -07:00
|
|
|
|
|
|
|
|
# Default command
|
|
|
|
|
CMD ["python", "packet_capture.py"]
|