Update Dockerfile
Browse files- Dockerfile +44 -30
Dockerfile
CHANGED
@@ -1,59 +1,73 @@
|
|
|
|
1 |
ARG UBUNTU_VERSION=22.04
|
2 |
-
# This needs to generally match the container host's environment.
|
3 |
ARG CUDA_VERSION=11.7.1
|
4 |
-
# Target the CUDA build image
|
5 |
ARG BASE_CUDA_DEV_CONTAINER=nvidia/cuda:${CUDA_VERSION}-devel-ubuntu${UBUNTU_VERSION}
|
6 |
-
# Target the CUDA runtime image
|
7 |
ARG BASE_CUDA_RUN_CONTAINER=nvidia/cuda:${CUDA_VERSION}-runtime-ubuntu${UBUNTU_VERSION}
|
8 |
|
|
|
9 |
FROM ${BASE_CUDA_DEV_CONTAINER} as build
|
10 |
|
11 |
-
#
|
12 |
-
ARG CUDA_DOCKER_ARCH=all
|
13 |
-
|
14 |
RUN apt-get update && \
|
15 |
apt-get install -y build-essential git
|
16 |
|
17 |
# Install Python3 and pip
|
18 |
RUN apt-get install -y python3 python3-pip
|
19 |
|
|
|
20 |
WORKDIR /app
|
21 |
|
|
|
22 |
COPY . .
|
23 |
|
24 |
-
#
|
25 |
-
|
26 |
-
|
27 |
-
|
|
|
28 |
|
|
|
|
|
|
|
|
|
|
|
29 |
FROM ${BASE_CUDA_RUN_CONTAINER} as runtime
|
30 |
|
31 |
-
#
|
32 |
-
RUN
|
33 |
-
apt-get
|
34 |
-
libopenblas-dev
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
41 |
RUN apt-get install -y python3 python3-pip
|
42 |
|
43 |
-
|
44 |
-
|
|
|
|
|
45 |
|
46 |
-
# Download model
|
47 |
-
RUN mkdir model && \
|
48 |
-
curl -L https://huggingface.co/matthoffner/Magicoder-S-DS-6.7B-GGUF/resolve/main/Magicoder-S-DS-6.7B_Q4_K_M.gguf -o model/gguf-model.gguf
|
49 |
|
50 |
-
COPY ./main.py
|
51 |
|
52 |
-
# Set environment
|
53 |
-
ENV HOST=0.0.0.0
|
54 |
-
|
55 |
|
56 |
-
# Expose
|
57 |
EXPOSE ${PORT}
|
58 |
|
59 |
# Run the server start script
|
|
|
1 |
+
# Set arguments for versions
|
2 |
ARG UBUNTU_VERSION=22.04
|
|
|
3 |
ARG CUDA_VERSION=11.7.1
|
|
|
4 |
ARG BASE_CUDA_DEV_CONTAINER=nvidia/cuda:${CUDA_VERSION}-devel-ubuntu${UBUNTU_VERSION}
|
|
|
5 |
ARG BASE_CUDA_RUN_CONTAINER=nvidia/cuda:${CUDA_VERSION}-runtime-ubuntu${UBUNTU_VERSION}
|
6 |
|
7 |
+
# Build stage with CUDA development container
|
8 |
FROM ${BASE_CUDA_DEV_CONTAINER} as build
|
9 |
|
10 |
+
# Install build essentials and git
|
|
|
|
|
11 |
RUN apt-get update && \
|
12 |
apt-get install -y build-essential git
|
13 |
|
14 |
# Install Python3 and pip
|
15 |
RUN apt-get install -y python3 python3-pip
|
16 |
|
17 |
+
# Set work directory to /app
|
18 |
WORKDIR /app
|
19 |
|
20 |
+
# Copy your application code to the container
|
21 |
COPY . .
|
22 |
|
23 |
+
# Create a non-root user 'user' in the build stage as well
|
24 |
+
RUN useradd -m -u 1000 user
|
25 |
+
|
26 |
+
# Switch to the non-root user for any further commands
|
27 |
+
USER user
|
28 |
|
29 |
+
# Set nvcc architecture and enable cuBLAS
|
30 |
+
ENV CUDA_DOCKER_ARCH=all \
|
31 |
+
LLAMA_CUBLAS=1
|
32 |
+
|
33 |
+
# Runtime stage with CUDA runtime container
|
34 |
FROM ${BASE_CUDA_RUN_CONTAINER} as runtime
|
35 |
|
36 |
+
# Re-create the non-root user 'user' in the runtime stage
|
37 |
+
RUN useradd -m -u 1000 user && \
|
38 |
+
apt-get update && \
|
39 |
+
apt-get install -y libopenblas-dev ninja-build build-essential pkg-config curl
|
40 |
+
|
41 |
+
# Switch to non-root user
|
42 |
+
USER user
|
43 |
+
|
44 |
+
# Set home and path for the user
|
45 |
+
ENV HOME=/home/user \
|
46 |
+
PATH=/home/user/.local/bin:$PATH
|
47 |
+
|
48 |
+
# Set work directory to user's home directory
|
49 |
+
WORKDIR $HOME/app
|
50 |
+
|
51 |
+
# Install Python3 and pip for the runtime container
|
52 |
+
USER root
|
53 |
RUN apt-get install -y python3 python3-pip
|
54 |
|
55 |
+
# Switch back to the non-root user for installing Python packages
|
56 |
+
USER user
|
57 |
+
RUN pip install --no-cache-dir --upgrade pip setuptools wheel && \
|
58 |
+
pip install --verbose llama-cpp-python[server]
|
59 |
|
60 |
+
# Download the model to the user's directory
|
61 |
+
RUN mkdir $HOME/model && \
|
62 |
+
curl -L https://huggingface.co/matthoffner/Magicoder-S-DS-6.7B-GGUF/resolve/main/Magicoder-S-DS-6.7B_Q4_K_M.gguf -o $HOME/model/gguf-model.gguf
|
63 |
|
64 |
+
COPY --chown=user ./main.py $HOME/app/
|
65 |
|
66 |
+
# Set environment variables for the host
|
67 |
+
ENV HOST=0.0.0.0 \
|
68 |
+
PORT=7860
|
69 |
|
70 |
+
# Expose the server port
|
71 |
EXPOSE ${PORT}
|
72 |
|
73 |
# Run the server start script
|