Spaces:
Runtime error
Runtime error
fix: single-stage build, download model at runtime to avoid timeout
Browse files- Dockerfile +23 -27
Dockerfile
CHANGED
|
@@ -1,48 +1,44 @@
|
|
| 1 |
-
FROM python:3.11-slim
|
| 2 |
|
| 3 |
-
# Install build dependencies
|
| 4 |
RUN apt-get update && apt-get install -y \
|
| 5 |
-
git cmake clang build-essential
|
| 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
|
| 12 |
RUN pip install --no-cache-dir -r /opt/BitNet/requirements.txt
|
| 13 |
|
| 14 |
-
# Build bitnet.cpp
|
| 15 |
-
#
|
| 16 |
-
RUN cd /opt/BitNet &&
|
| 17 |
-
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 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
|
| 28 |
RUN useradd -ms /bin/bash user
|
| 29 |
WORKDIR /home/user/app
|
| 30 |
|
| 31 |
-
# Copy
|
| 32 |
-
|
| 33 |
-
|
|
|
|
| 34 |
|
| 35 |
-
# Install Python app
|
| 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 |
-
#
|
| 45 |
-
RUN
|
|
|
|
| 46 |
|
| 47 |
USER user
|
| 48 |
|
|
|
|
| 1 |
+
FROM python:3.11-slim
|
| 2 |
|
| 3 |
+
# Install build + runtime dependencies in one layer
|
| 4 |
RUN apt-get update && apt-get install -y \
|
| 5 |
+
git cmake clang build-essential curl libgomp1 \
|
| 6 |
&& rm -rf /var/lib/apt/lists/*
|
| 7 |
|
| 8 |
+
# Clone bitnet.cpp (shallow clone for speed)
|
| 9 |
+
RUN git clone --depth 1 --recursive https://github.com/microsoft/BitNet.git /opt/BitNet
|
| 10 |
|
| 11 |
+
# Install BitNet Python deps
|
| 12 |
RUN pip install --no-cache-dir -r /opt/BitNet/requirements.txt
|
| 13 |
|
| 14 |
+
# Build bitnet.cpp WITHOUT downloading the model (just compile the binary)
|
| 15 |
+
# We use cmake directly instead of setup_env.py to avoid the model download
|
| 16 |
+
RUN cd /opt/BitNet && \
|
| 17 |
+
cmake -B build -DCMAKE_BUILD_TYPE=Release \
|
| 18 |
+
-DGGML_BITNET_ARM_TL1=OFF \
|
| 19 |
+
-DGGML_BITNET_X86_TL2=OFF && \
|
| 20 |
+
cmake --build build --config Release -j$(nproc) --target llama-server llama-cli
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 21 |
|
| 22 |
+
# Create non-root user
|
| 23 |
RUN useradd -ms /bin/bash user
|
| 24 |
WORKDIR /home/user/app
|
| 25 |
|
| 26 |
+
# Copy just the binaries we need
|
| 27 |
+
RUN cp /opt/BitNet/build/bin/llama-server /home/user/app/ && \
|
| 28 |
+
cp /opt/BitNet/build/bin/llama-cli /home/user/app/ && \
|
| 29 |
+
rm -rf /opt/BitNet
|
| 30 |
|
| 31 |
+
# Install Python app deps
|
| 32 |
COPY requirements.txt .
|
| 33 |
RUN pip install --no-cache-dir -r requirements.txt
|
| 34 |
|
| 35 |
# Copy app files
|
| 36 |
+
COPY app.py start.sh ./
|
|
|
|
| 37 |
RUN chmod +x start.sh
|
| 38 |
|
| 39 |
+
# Create model directory
|
| 40 |
+
RUN mkdir -p /home/user/app/models && \
|
| 41 |
+
chown -R user:user /home/user/app
|
| 42 |
|
| 43 |
USER user
|
| 44 |
|