Spaces:
Runtime error
Runtime error
Upload Dockerfile
Browse files- Dockerfile +54 -0
Dockerfile
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
FROM python:3.11-slim AS builder
|
| 2 |
+
|
| 3 |
+
# Install build dependencies
|
| 4 |
+
RUN apt-get update && apt-get install -y \
|
| 5 |
+
git cmake clang build-essential wget curl \
|
| 6 |
+
&& rm -rf /var/lib/apt/lists/*
|
| 7 |
+
|
| 8 |
+
# Clone bitnet.cpp
|
| 9 |
+
RUN git clone --recursive https://github.com/microsoft/BitNet.git /opt/BitNet
|
| 10 |
+
|
| 11 |
+
# Install BitNet Python deps (needed for setup_env.py)
|
| 12 |
+
RUN pip install --no-cache-dir -r /opt/BitNet/requirements.txt
|
| 13 |
+
|
| 14 |
+
# Build bitnet.cpp with i2_s kernel support
|
| 15 |
+
# setup_env.py does the cmake build and downloads the GGUF model
|
| 16 |
+
RUN cd /opt/BitNet && python setup_env.py \
|
| 17 |
+
--hf-repo microsoft/bitnet-b1.58-2B-4T-gguf \
|
| 18 |
+
-q i2_s
|
| 19 |
+
|
| 20 |
+
# βββ Runtime stage βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 21 |
+
FROM python:3.11-slim
|
| 22 |
+
|
| 23 |
+
RUN apt-get update && apt-get install -y \
|
| 24 |
+
libgomp1 curl \
|
| 25 |
+
&& rm -rf /var/lib/apt/lists/*
|
| 26 |
+
|
| 27 |
+
# Create non-root user (required by HF Spaces)
|
| 28 |
+
RUN useradd -ms /bin/bash user
|
| 29 |
+
WORKDIR /home/user/app
|
| 30 |
+
|
| 31 |
+
# Copy built binaries and model from builder
|
| 32 |
+
COPY --from=builder /opt/BitNet/build/bin /home/user/app/bin
|
| 33 |
+
COPY --from=builder /opt/BitNet/models /home/user/app/models
|
| 34 |
+
|
| 35 |
+
# Install Python app dependencies
|
| 36 |
+
COPY requirements.txt .
|
| 37 |
+
RUN pip install --no-cache-dir -r requirements.txt
|
| 38 |
+
|
| 39 |
+
# Copy app files
|
| 40 |
+
COPY app.py .
|
| 41 |
+
COPY start.sh .
|
| 42 |
+
RUN chmod +x start.sh
|
| 43 |
+
|
| 44 |
+
# Fix permissions
|
| 45 |
+
RUN chown -R user:user /home/user/app
|
| 46 |
+
|
| 47 |
+
USER user
|
| 48 |
+
|
| 49 |
+
EXPOSE 7860
|
| 50 |
+
|
| 51 |
+
ENV GRADIO_SERVER_NAME="0.0.0.0"
|
| 52 |
+
ENV GRADIO_SERVER_PORT="7860"
|
| 53 |
+
|
| 54 |
+
CMD ["./start.sh"]
|