From dc17f1e0744414cb5c3dc688fd64c92ee9a83108 Mon Sep 17 00:00:00 2001 From: Jah-yee Date: Fri, 13 Mar 2026 02:35:46 +0800 Subject: [PATCH] Add Dockerfile for containerized deployment - Enables running BitNet in Kubernetes or Docker environments - Uses Python 3.11-slim as base image - Installs all build dependencies (cmake, build-essential) - Includes Python requirements for inference - Resolves: microsoft/BitNet#433 --- Dockerfile | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 000000000..e97d64ed9 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,42 @@ +# syntax=docker/dockerfile:1 +# BitNet Dockerfile - CPU inference for 1-bit LLMs +# Build: docker build -t bitnet . +# Run: docker run --rm -it bitnet python run_inference.py -m models/BitNet-b1.58-2B-4T/ggml-model-i2_s.gguf -p "Your prompt" -cnv + +FROM python:3.11-slim + +# Set environment variables +ENV PYTHONUNBUFFERED=1 \ + DEBIAN_FRONTEND=noninteractive \ + PIP_NO_CACHE_DIR=1 \ + PIP_DISABLE_PIP_VERSION_CHECK=1 + +# Install system dependencies +RUN apt-get update && apt-get install -y --no-install-recommends \ + build-essential \ + cmake \ + git \ + wget \ + curl \ + libomp-dev \ + && rm -rf /var/lib/apt/lists/* + +# Set working directory +WORKDIR /workspace + +# Clone BitNet repository (for builds from source) +# If building from local source, copy files instead +COPY . . + +# Install Python dependencies +RUN pip install -r requirements.txt + +# Build the project (optional - can be done at runtime with setup_env.py) +# This creates the native extensions needed for inference +RUN git submodule update --init --recursive 2>/dev/null || true + +# Create models directory +RUN mkdir -p models + +# Default command shows help +CMD ["python", "run_inference.py", "--help"]