mecha10-cli 0.1.47

Mecha10 CLI tool
Documentation
# syntax=docker/dockerfile:1
# Dockerfile.remote - Remote Node Container
#
# This container runs AI/ML nodes (object-detector, image-classifier, llm-command)
# that require platform-specific dependencies (ONNX Runtime, CUDA, etc.)
#
# The mecha10-remote supervisor reads targets.remote from mecha10.json
# and spawns each node using `mecha10 node <name>`.
#
# Uses sccache + BuildKit caches for faster rebuilds.
# See docs/guides/FASTER_BUILDS.md
#
# For standard configurations, use pre-built images from:
#   ghcr.io/mecha-industries/mecha10-remote:<version>
#
# Customize this file only if you need additional system dependencies.
# Changes to this file trigger a local rebuild (pre-built image won't be used).
#
# Auto-generated by `mecha10 init`

# ============================================================================
# Builder Stage: Install mecha10 CLI with vision support
# ============================================================================
FROM ubuntu:24.04 AS builder

# Install Rust and system dependencies
RUN apt-get update && apt-get install -y \
    curl \
    build-essential \
    pkg-config \
    libssl-dev \
    libudev-dev \
    libasound2-dev \
    cmake \
    && rm -rf /var/lib/apt/lists/*

# Install Rust
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
ENV PATH="/root/.cargo/bin:${PATH}"

# Install sccache for faster compilation caching
RUN cargo install sccache
ENV RUSTC_WRAPPER=sccache

WORKDIR /build

# Install mecha10 CLI from crates.io with vision feature
# Uses sccache + BuildKit caches for faster rebuilds
ARG MECHA10_VERSION=0.1.46
RUN --mount=type=cache,target=/root/.cache/sccache \
    --mount=type=cache,target=/usr/local/cargo/registry \
    cargo install mecha10-cli --version ${MECHA10_VERSION} --features vision --root /build


# ============================================================================
# Runtime Stage: Minimal image with binaries
# ============================================================================
FROM ubuntu:24.04 AS runtime

# Install minimal runtime dependencies
RUN apt-get update && apt-get install -y --no-install-recommends \
    ca-certificates \
    libssl3 \
    libgomp1 \
    && rm -rf /var/lib/apt/lists/*

# Copy ONNX Runtime libraries (downloaded by ort crate during build)
COPY --from=builder /root/.cache/ort.pyke.io /root/.cache/ort.pyke.io
ENV LD_LIBRARY_PATH=/root/.cache/ort.pyke.io${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}

# Copy mecha10 binaries
COPY --from=builder /build/bin/mecha10 /usr/local/bin/mecha10
COPY --from=builder /build/bin/mecha10-remote /usr/local/bin/mecha10-remote

WORKDIR /app

# Config files are mounted at runtime (not baked in)
# This allows config changes without rebuilding
VOLUME ["/app/configs", "/app/models"]

# Environment variables
ENV RUST_LOG=info
ENV REDIS_URL=redis://redis:6379
ENV MECHA10_CONFIG=/app/mecha10.json

# The runtime reads targets.remote from mecha10.json
# and spawns each node as a separate process
ENTRYPOINT ["mecha10-remote"]

# Health check - verify mecha10 is available
HEALTHCHECK --interval=30s --timeout=10s --retries=3 --start-period=10s \
    CMD mecha10 --version || exit 1