Skip to content

Commit 3099afb

Browse files
committed
wip: Backend Dockerfile for python backends
Signed-off-by: Ettore Di Giacinto <mudler@localai.io>
1 parent 5226227 commit 3099afb

File tree

7 files changed

+80
-6
lines changed

7 files changed

+80
-6
lines changed

backend/python/Dockerfile

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
ARG BASE_IMAGE=ubuntu:22.04
2+
3+
FROM ${BASE_IMAGE} AS builder
4+
ARG BACKEND=rerankers
5+
ARG BUILD_TYPE
6+
ENV BUILD_TYPE=${BUILD_TYPE}
7+
ARG CUDA_MAJOR_VERSION
8+
ENV CUDA_MAJOR_VERSION=${CUDA_MAJOR_VERSION}
9+
ENV DEBIAN_FRONTEND=noninteractive
10+
11+
RUN apt-get update && \
12+
apt-get install -y --no-install-recommends \
13+
curl python3-pip \
14+
python-is-python3 \
15+
python3-dev llvm \
16+
python3-venv make && \
17+
apt-get clean && \
18+
rm -rf /var/lib/apt/lists/* && \
19+
pip install --upgrade pip
20+
21+
22+
# Install uv as a system package
23+
RUN curl -LsSf https://astral.sh/uv/install.sh | UV_INSTALL_DIR=/usr/bin sh
24+
ENV PATH="/root/.cargo/bin:${PATH}"
25+
26+
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
27+
28+
# Install grpcio-tools (the version in 22.04 is too old)
29+
RUN pip install --user grpcio-tools==1.71.0 grpcio==1.71.0
30+
31+
COPY ${BACKEND} /${BACKEND}
32+
COPY common/ /${BACKEND}/common
33+
34+
RUN cd /${BACKEND} && make
35+
36+
FROM scratch
37+
ARG BACKEND=rerankers
38+
COPY --from=builder /${BACKEND}/ /

backend/python/rerankers/install.sh

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
11
#!/bin/bash
22
set -e
33

4-
source $(dirname $0)/../common/libbackend.sh
4+
backend_dir=$(dirname $0)
5+
6+
if [ -d $backend_dir/common ]; then
7+
source $backend_dir/common/libbackend.sh
8+
else
9+
source $backend_dir/../common/libbackend.sh
10+
fi
511

612
# This is here because the Intel pip index is broken and returns 200 status codes for every package name, it just doesn't return any package links.
713
# This makes uv think that the package exists in the Intel pip index, and by default it stops looking at other pip indexes once it finds a match.

backend/python/rerankers/run.sh

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
11
#!/bin/bash
2-
source $(dirname $0)/../common/libbackend.sh
2+
3+
backend_dir=$(dirname $0)
4+
if [ -d $backend_dir/common ]; then
5+
source $backend_dir/common/libbackend.sh
6+
else
7+
source $backend_dir/../common/libbackend.sh
8+
fi
39

410
startBackend $@

backend/python/rerankers/test.sh

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
#!/bin/bash
22
set -e
33

4-
source $(dirname $0)/../common/libbackend.sh
4+
backend_dir=$(dirname $0)
5+
if [ -d $backend_dir/common ]; then
6+
source $backend_dir/common/libbackend.sh
7+
else
8+
source $backend_dir/../common/libbackend.sh
9+
fi
510

611
runUnittests

backend/python/vllm/install.sh

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,13 @@ set -e
33

44
EXTRA_PIP_INSTALL_FLAGS="--no-build-isolation"
55

6-
source $(dirname $0)/../common/libbackend.sh
6+
backend_dir=$(dirname $0)
7+
8+
if [ -d $backend_dir/common ]; then
9+
source $backend_dir/common/libbackend.sh
10+
else
11+
source $backend_dir/../common/libbackend.sh
12+
fi
713

814
# This is here because the Intel pip index is broken and returns 200 status codes for every package name, it just doesn't return any package links.
915
# This makes uv think that the package exists in the Intel pip index, and by default it stops looking at other pip indexes once it finds a match.

backend/python/vllm/run.sh

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,11 @@
11
#!/bin/bash
2-
source $(dirname $0)/../common/libbackend.sh
2+
3+
backend_dir=$(dirname $0)
4+
5+
if [ -d $backend_dir/common ]; then
6+
source $backend_dir/common/libbackend.sh
7+
else
8+
source $backend_dir/../common/libbackend.sh
9+
fi
310

411
startBackend $@

backend/python/vllm/test.sh

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
#!/bin/bash
22
set -e
33

4-
source $(dirname $0)/../common/libbackend.sh
4+
backend_dir=$(dirname $0)
5+
6+
if [ -d $backend_dir/common ]; then
7+
source $backend_dir/common/libbackend.sh
8+
else
9+
source $backend_dir/../common/libbackend.sh
10+
fi
511

612
runUnittests

0 commit comments

Comments
 (0)