mcesptool/Dockerfile
Ryan Malloy 64c1505a00 Add QEMU ESP32 emulation support
Integrate Espressif's QEMU fork for virtual ESP device management:

- QemuManager component with 5 MCP tools (start/stop/list/status/flash)
- Config auto-detects QEMU binaries from ~/.espressif/tools/
- Supports esp32, esp32s2, esp32s3, esp32c3 chip emulation
- Virtual serial over TCP (socket://localhost:PORT) transparent to esptool
- Scan integration: QEMU instances appear in esp_scan_ports results
- Blank flash images initialized to 0xFF (erased NOR flash state)
- 38 unit tests covering lifecycle, port allocation, flash writes
2026-01-28 15:35:22 -07:00

93 lines
2.1 KiB
Docker

# Use official uv image for Python development
FROM ghcr.io/astral-sh/uv:python3.11-bookworm-slim AS base
# Set working directory
WORKDIR /app
# Install system dependencies for ESP development
RUN apt-get update && apt-get install -y \
git \
curl \
build-essential \
cmake \
ninja-build \
ccache \
libffi-dev \
libssl-dev \
dfu-util \
libusb-1.0-0 \
python3-venv \
&& rm -rf /var/lib/apt/lists/*
# Development stage with source mounting and hot reload
FROM base AS development
# Set environment for development
ENV UV_COMPILE_BYTECODE=0
ENV DEV_ENABLE_HOT_RELOAD=true
# Copy dependency files
COPY pyproject.toml uv.lock ./
# Install dependencies in development mode
RUN --mount=type=cache,target=/root/.cache/uv \
uv sync --dev --frozen
# Copy source code
COPY . .
# Install project in editable mode
RUN --mount=type=cache,target=/root/.cache/uv \
uv pip install -e .
# Create non-root user for security
RUN useradd -m -u 1000 mcpuser && \
chown -R mcpuser:mcpuser /app
USER mcpuser
# Default command for development
CMD ["uv", "run", "mcp-esptool-server", "--debug"]
# Production stage with optimized build
FROM base AS production
# Set environment for production
ENV UV_COMPILE_BYTECODE=1
ENV PRODUCTION_MODE=true
# Copy dependency files
COPY pyproject.toml uv.lock ./
# Install only production dependencies
RUN --mount=type=cache,target=/root/.cache/uv \
uv sync --frozen --no-dev --no-editable
# Copy source code
COPY src ./src
# Install project
RUN --mount=type=cache,target=/root/.cache/uv \
uv pip install --no-editable .
# Create non-root user
RUN useradd -m -u 1000 mcpuser && \
chown -R mcpuser:mcpuser /app
USER mcpuser
# Health check
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
CMD uv run python -c "import mcp_esptool_server; print('OK')" || exit 1
# Default command for production
CMD ["uv", "run", "mcp-esptool-server", "--production"]
# Testing stage for CI/CD
FROM development AS testing
# Run tests as part of build
RUN uv run pytest tests/ -v
# Default target
FROM development