Spaces:
Build error
Build error
FROM ubuntu:22.04 | |
# Set non-interactive frontend for apt | |
ENV DEBIAN_FRONTEND=noninteractive | |
# Install dependencies for LLVM script and repository | |
RUN apt-get update && apt-get install -y \ | |
wget \ | |
gnupg \ | |
lsb-release \ | |
software-properties-common \ | |
&& rm -rf /var/lib/apt/lists/* | |
# Add LLVM repository for Clang 18 | |
RUN wget https://apt.llvm.org/llvm.sh && \ | |
chmod +x llvm.sh && \ | |
./llvm.sh 18 && \ | |
rm llvm.sh | |
# Install system dependencies for bitnet.cpp and Python | |
RUN apt-get update && apt-get install -y \ | |
build-essential \ | |
cmake \ | |
clang-18 \ | |
git \ | |
python3.9 \ | |
python3-pip \ | |
&& rm -rf /var/lib/apt/lists/* | |
# Set Clang as default compiler | |
ENV CC=/usr/bin/clang-18 | |
ENV CXX=/usr/bin/clang++-18 | |
# Create a non-root user (Hugging Face Spaces run as non-root) | |
RUN useradd -m -u 1000 user | |
# Switch to non-root user | |
USER user | |
# Set working directory | |
WORKDIR /home/user/app | |
# Add user’s local bin to PATH to suppress pip warnings | |
ENV PATH="/home/user/.local/bin:$PATH" | |
# Install Python dependencies | |
COPY requirements.txt . | |
RUN pip3 install --no-cache-dir -r requirements.txt | |
# Clone bitnet.cpp with submodules | |
RUN git clone --recurse-submodules https://github.com/microsoft/BitNet.git bitnet.cpp | |
WORKDIR /home/user/app/bitnet.cpp | |
RUN mkdir build && cd build && \ | |
cmake .. -DCMAKE_C_COMPILER=clang-18 -DCMAKE_CXX_COMPILER=clang++-18 && \ | |
make -j$(nproc) | |
# Copy application code | |
WORKDIR /home/user/app | |
COPY app.py . | |
# Expose port 7860 (required for Hugging Face Spaces) | |
EXPOSE 7860 | |
# Run Gradio app | |
CMD ["python3", "app.py"] |