Spaces:
Runtime error
Runtime error
| FROM python:3.11-slim AS builder | |
| # Install build dependencies | |
| RUN apt-get update && apt-get install -y \ | |
| git cmake clang build-essential wget curl \ | |
| && rm -rf /var/lib/apt/lists/* | |
| # Clone bitnet.cpp | |
| RUN git clone --recursive https://github.com/microsoft/BitNet.git /opt/BitNet | |
| # Install BitNet Python deps (needed for setup_env.py) | |
| RUN pip install --no-cache-dir -r /opt/BitNet/requirements.txt | |
| # Build bitnet.cpp with i2_s kernel support | |
| # setup_env.py does the cmake build and downloads the GGUF model | |
| RUN cd /opt/BitNet && python setup_env.py \ | |
| --hf-repo microsoft/bitnet-b1.58-2B-4T-gguf \ | |
| -q i2_s | |
| # βββ Runtime stage βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ | |
| FROM python:3.11-slim | |
| RUN apt-get update && apt-get install -y \ | |
| libgomp1 curl \ | |
| && rm -rf /var/lib/apt/lists/* | |
| # Create non-root user (required by HF Spaces) | |
| RUN useradd -ms /bin/bash user | |
| WORKDIR /home/user/app | |
| # Copy built binaries and model from builder | |
| COPY --from=builder /opt/BitNet/build/bin /home/user/app/bin | |
| COPY --from=builder /opt/BitNet/models /home/user/app/models | |
| # Install Python app dependencies | |
| COPY requirements.txt . | |
| RUN pip install --no-cache-dir -r requirements.txt | |
| # Copy app files | |
| COPY app.py . | |
| COPY start.sh . | |
| RUN chmod +x start.sh | |
| # Fix permissions | |
| RUN chown -R user:user /home/user/app | |
| USER user | |
| EXPOSE 7860 | |
| ENV GRADIO_SERVER_NAME="0.0.0.0" | |
| ENV GRADIO_SERVER_PORT="7860" | |
| CMD ["./start.sh"] | |