Tonic commited on
Commit
dfeb22f
·
unverified ·
1 Parent(s): c29928a

using docker initial commit

Browse files
Files changed (1) hide show
  1. Dockerfile +31 -33
Dockerfile CHANGED
@@ -1,67 +1,65 @@
1
  FROM ubuntu:22.04
2
 
3
  # Set non-interactive frontend for apt
4
-
5
  ENV DEBIAN_FRONTEND=noninteractive
6
 
7
  # Install dependencies for LLVM script and repository
8
-
9
  RUN apt-get update && apt-get install -y \
10
- wget \
11
- gnupg \
12
- lsb-release \
13
- software-properties-common \
14
- && rm -rf /var/lib/apt/lists/\*
15
 
16
  # Add LLVM repository for Clang 18
17
-
18
  RUN wget https://apt.llvm.org/llvm.sh && \
19
- chmod +x llvm.sh && \
20
- ./llvm.sh 18 && \
21
- rm llvm.sh
22
 
23
  # Install system dependencies for bitnet.cpp and Python
24
-
25
  RUN apt-get update && apt-get install -y \
26
- build-essential \
27
- cmake \
28
- clang-18 \
29
- git \
30
- python3.9 \
31
- python3-pip \
32
- && rm -rf /var/lib/apt/lists/\*
33
 
34
  # Set Clang as default compiler
35
-
36
- ENV CC=/usr/bin/clang-18
37
  ENV CXX=/usr/bin/clang++-18
38
 
39
  # Create a non-root user (Hugging Face Spaces run as non-root)
 
40
 
41
- RUN useradd -m -u 1000 user USER user WORKDIR /home/user/app
 
42
 
43
- # Add user’s local bin to PATH to suppress pip warnings
 
44
 
 
45
  ENV PATH="/home/user/.local/bin:$PATH"
46
 
47
  # Install Python dependencies
48
-
49
- COPY requirements.txt . RUN pip3 install --no-cache-dir -r requirements.txt
50
 
51
  # Clone bitnet.cpp with submodules
52
-
53
- RUN git clone --recurse-submodules https://github.com/microsoft/BitNet.git bitnet.cpp WORKDIR /home/user/app/bitnet.cpp RUN mkdir build && cd build && \
54
- cmake .. -DCMAKE_C_COMPILER=clang-18 -DCMAKE_CXX_COMPILER=clang++-18 && \
55
- make -j$(nproc)
 
56
 
57
  # Copy application code
58
-
59
- WORKDIR /home/user/app COPY app.py .
60
 
61
  # Expose port 7860 (required for Hugging Face Spaces)
62
-
63
  EXPOSE 7860
64
 
65
  # Run Gradio app
66
-
67
  CMD ["python3", "app.py"]
 
1
  FROM ubuntu:22.04
2
 
3
  # Set non-interactive frontend for apt
 
4
  ENV DEBIAN_FRONTEND=noninteractive
5
 
6
  # Install dependencies for LLVM script and repository
 
7
  RUN apt-get update && apt-get install -y \
8
+ wget \
9
+ gnupg \
10
+ lsb-release \
11
+ software-properties-common \
12
+ && rm -rf /var/lib/apt/lists/*
13
 
14
  # Add LLVM repository for Clang 18
 
15
  RUN wget https://apt.llvm.org/llvm.sh && \
16
+ chmod +x llvm.sh && \
17
+ ./llvm.sh 18 && \
18
+ rm llvm.sh
19
 
20
  # Install system dependencies for bitnet.cpp and Python
 
21
  RUN apt-get update && apt-get install -y \
22
+ build-essential \
23
+ cmake \
24
+ clang-18 \
25
+ git \
26
+ python3.9 \
27
+ python3-pip \
28
+ && rm -rf /var/lib/apt/lists/*
29
 
30
  # Set Clang as default compiler
31
+ ENV CC=/usr/bin/clang-18
 
32
  ENV CXX=/usr/bin/clang++-18
33
 
34
  # Create a non-root user (Hugging Face Spaces run as non-root)
35
+ RUN useradd -m -u 1000 user
36
 
37
+ # Switch to non-root user
38
+ USER user
39
 
40
+ # Set working directory
41
+ WORKDIR /home/user/app
42
 
43
+ # Add user’s local bin to PATH to suppress pip warnings
44
  ENV PATH="/home/user/.local/bin:$PATH"
45
 
46
  # Install Python dependencies
47
+ COPY requirements.txt .
48
+ RUN pip3 install --no-cache-dir -r requirements.txt
49
 
50
  # Clone bitnet.cpp with submodules
51
+ RUN git clone --recurse-submodules https://github.com/microsoft/BitNet.git bitnet.cpp
52
+ WORKDIR /home/user/app/bitnet.cpp
53
+ RUN mkdir build && cd build && \
54
+ cmake .. -DCMAKE_C_COMPILER=clang-18 -DCMAKE_CXX_COMPILER=clang++-18 && \
55
+ make -j$(nproc)
56
 
57
  # Copy application code
58
+ WORKDIR /home/user/app
59
+ COPY app.py .
60
 
61
  # Expose port 7860 (required for Hugging Face Spaces)
 
62
  EXPOSE 7860
63
 
64
  # Run Gradio app
 
65
  CMD ["python3", "app.py"]