Spaces:
Build error
Build error
Create Dockerfile
Browse files- Dockerfile +45 -0
Dockerfile
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Use Ubuntu as the base image
|
| 2 |
+
FROM ubuntu:22.04
|
| 3 |
+
|
| 4 |
+
# Set the working directory in the container
|
| 5 |
+
WORKDIR /app
|
| 6 |
+
|
| 7 |
+
# Install system dependencies and Python
|
| 8 |
+
RUN apt-get update && apt-get install -y \
|
| 9 |
+
python3 \
|
| 10 |
+
python3-pip \
|
| 11 |
+
curl \
|
| 12 |
+
git \
|
| 13 |
+
build-essential \
|
| 14 |
+
cmake \
|
| 15 |
+
ninja-build \
|
| 16 |
+
wget \
|
| 17 |
+
&& rm -rf /var/lib/apt/lists/*
|
| 18 |
+
|
| 19 |
+
# Set Python3 as the default
|
| 20 |
+
RUN ln -s /usr/bin/python3 /usr/bin/python
|
| 21 |
+
|
| 22 |
+
# Copy the requirements file and install dependencies
|
| 23 |
+
COPY requirements.txt ./
|
| 24 |
+
RUN pip install --no-cache-dir -r requirements.txt
|
| 25 |
+
|
| 26 |
+
# Install llama.cpp using CMake
|
| 27 |
+
RUN git clone https://github.com/ggerganov/llama.cpp.git /app/llama.cpp && \
|
| 28 |
+
cd /app/llama.cpp && \
|
| 29 |
+
mkdir build && cd build && \
|
| 30 |
+
cmake .. -G Ninja && ninja install
|
| 31 |
+
|
| 32 |
+
# Ensure llama.cpp binaries are in the system path
|
| 33 |
+
ENV PATH="/usr/local/bin:$PATH"
|
| 34 |
+
|
| 35 |
+
# Copy the Llama model into the Docker image
|
| 36 |
+
COPY Meta-Llama-3-8B-Instruct.Q4_0.gguf /app/
|
| 37 |
+
|
| 38 |
+
# Copy the application files
|
| 39 |
+
COPY . .
|
| 40 |
+
|
| 41 |
+
# Expose the FastAPI default port
|
| 42 |
+
EXPOSE 8000
|
| 43 |
+
|
| 44 |
+
# Start llama.cpp server, then start FastAPI
|
| 45 |
+
CMD ["sh", "-c", "/usr/local/bin/server -m /app/Meta-Llama-3-8B-Instruct.Q4_0.gguf & sleep 5 && uvicorn main:app --host 0.0.0.0 --port 8000"]
|