moriire commited on
Commit
9471754
1 Parent(s): 233c362

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +37 -21
Dockerfile CHANGED
@@ -1,51 +1,67 @@
1
  # Define the image argument and provide a default value
2
- ARG IMAGE=python:3-slim-bullseye
3
 
4
  # Use the image as specified
5
- FROM ${IMAGE}
6
 
7
  # Re-declare the ARG after FROM
8
- ARG IMAGE
9
 
10
  # Update and upgrade the existing packages
11
- RUN apt-get update && apt-get upgrade -y && apt-get install -y --no-install-recommends \
12
- python3 \
13
- python3-pip \
14
- ninja-build \
15
- libopenblas-dev \
16
- build-essential
17
 
18
  #RUN mkdir /app
19
  #WORKDIR /app
20
- COPY . .
21
 
22
- RUN python3 -m pip install --upgrade pip
23
 
24
  #RUN make deps && make build && make clean
25
 
26
  # Set environment variable for the host
27
- ENV HOST=0.0.0.0
28
- ENV PORT=7860
29
- ENV ORIGINS=*
30
 
31
  # Install requirements.txt
32
- RUN pip install --no-cache-dir --upgrade -r requirements.txt
33
 
34
  # Set up a new user named "user" with user ID 1000
35
- RUN useradd -m -u 1000 user
36
  # Switch to the "user" user
37
- USER user
38
  # Set home to the user's home directory
39
- ENV HOME=/home/user \
40
- PATH=/home/user/.local/bin:$PATH
41
 
42
  # Set the working directory to the user's home directory
43
  # WORKDIR $HOME/app
44
 
45
  # Copy the current directory contents into the container at $HOME/app setting the owner to the user
46
- COPY --chown=user . $HOME
47
 
48
  # Start the FastAPI app on port 7860, the default port expected by Spaces
49
  #CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]
50
  #ENTRYPOINT ["python3"]
51
- ENTRYPOINT ["python3", "-m", "llama_cpp.server", "--hf_model_repo_id", "Qwen/Qwen1.5-0.5B-Chat-GGUF", "--model", "*q4_0.gguf", "--host", "0.0.0.0"]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  # Define the image argument and provide a default value
2
+ #ARG IMAGE=python:3-slim-bullseye
3
 
4
  # Use the image as specified
5
+ #FROM ${IMAGE}
6
 
7
  # Re-declare the ARG after FROM
8
+ #ARG IMAGE
9
 
10
  # Update and upgrade the existing packages
11
+ #RUN apt-get update && apt-get upgrade -y && apt-get install -y --no-install-recommends \
12
+ # python3 \
13
+ # python3-pip \
14
+ # ninja-build \
15
+ # libopenblas-dev \
16
+ # build-essential
17
 
18
  #RUN mkdir /app
19
  #WORKDIR /app
20
+ #COPY . .
21
 
22
+ #RUN python3 -m pip install --upgrade pip
23
 
24
  #RUN make deps && make build && make clean
25
 
26
  # Set environment variable for the host
27
+ #ENV HOST=0.0.0.0
28
+ #ENV PORT=7860
29
+ #ENV ORIGINS=*
30
 
31
  # Install requirements.txt
32
+ #RUN pip install --no-cache-dir --upgrade -r requirements.txt
33
 
34
  # Set up a new user named "user" with user ID 1000
35
+ #RUN useradd -m -u 1000 user
36
  # Switch to the "user" user
37
+ #USER user
38
  # Set home to the user's home directory
39
+ #ENV HOME=/home/user \
40
+ # PATH=/home/user/.local/bin:$PATH
41
 
42
  # Set the working directory to the user's home directory
43
  # WORKDIR $HOME/app
44
 
45
  # Copy the current directory contents into the container at $HOME/app setting the owner to the user
46
+ #COPY --chown=user . $HOME
47
 
48
  # Start the FastAPI app on port 7860, the default port expected by Spaces
49
  #CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]
50
  #ENTRYPOINT ["python3"]
51
+ #ENTRYPOINT ["python3", "-m", "llama_cpp.server", "--hf_model_repo_id", "Qwen/Qwen1.5-0.5B-Chat-GGUF", "--model", "*q4_0.gguf", "--host", "0.0.0.0"]
52
+ FROM python:3-slim-bullseye
53
+ # It's not at all clear why the image published by the llama-cpp-python author doesn't work,
54
+ # but it can't find the llama libraries, soI had to re-build the docker container
55
+ # We need to set the host to 0.0.0.0 to allow outside access
56
+ ENV HOST 0.0.0.0
57
+
58
+ COPY . .
59
+
60
+ # Install the package
61
+ RUN apt update && apt install -y libopenblas-dev ninja-build build-essential pkg-config
62
+ RUN python -m pip install --upgrade pip pytest cmake scikit-build setuptools fastapi uvicorn sse-starlette pydantic-settings starlette-context
63
+
64
+ RUN CMAKE_ARGS="-DLLAMA_BLAS=ON -DLLAMA_BLAS_VENDOR=OpenBLAS" pip install llama_cpp_python --verbose
65
+
66
+ # Run the server
67
+ CMD python3 -m llama_cpp.server --model $MODEL --n_gpu_layers $N_GPU_LAYERS --n_batch $N_BATCH