Spaces:
Runtime error
Runtime error
fix: move all heavy work to runtime, minimal Dockerfile for fast build
Browse files- Dockerfile +3 -24
Dockerfile
CHANGED
|
@@ -1,34 +1,15 @@
|
|
| 1 |
FROM python:3.11-slim
|
| 2 |
|
| 3 |
-
# Install
|
| 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 |
-
#
|
| 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 |
|
|
@@ -36,9 +17,7 @@ RUN pip install --no-cache-dir -r requirements.txt
|
|
| 36 |
COPY app.py start.sh ./
|
| 37 |
RUN chmod +x start.sh
|
| 38 |
|
| 39 |
-
|
| 40 |
-
RUN mkdir -p /home/user/app/models && \
|
| 41 |
-
chown -R user:user /home/user/app
|
| 42 |
|
| 43 |
USER user
|
| 44 |
|
|
|
|
| 1 |
FROM python:3.11-slim
|
| 2 |
|
| 3 |
+
# Install all dependencies (build + runtime)
|
| 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 |
# Create non-root user
|
| 9 |
RUN useradd -ms /bin/bash user
|
| 10 |
WORKDIR /home/user/app
|
| 11 |
|
| 12 |
+
# Install Python deps first (cached layer)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 13 |
COPY requirements.txt .
|
| 14 |
RUN pip install --no-cache-dir -r requirements.txt
|
| 15 |
|
|
|
|
| 17 |
COPY app.py start.sh ./
|
| 18 |
RUN chmod +x start.sh
|
| 19 |
|
| 20 |
+
RUN chown -R user:user /home/user/app
|
|
|
|
|
|
|
| 21 |
|
| 22 |
USER user
|
| 23 |
|