Skip to content

Commit f19609b

Browse files
Fix Dockerfile error and add CI test for IPEX (#1585)
* Fix Dockerfile error and add CI teat Signed-off-by: lvliang-intel <[email protected]>
1 parent 4024302 commit f19609b

File tree

3 files changed

+83
-1
lines changed

3 files changed

+83
-1
lines changed

.github/workflows/docker/compose/third_parties-compose.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,5 +100,8 @@ services:
100100
image: ${REGISTRY:-opea}/lvm-llama-vision-guard:${TAG:-latest}
101101
ipex-llm:
102102
build:
103+
args:
104+
COMPILE: ON
105+
PORT_SSH: 2345
103106
dockerfile: comps/third_parties/ipex/src/Dockerfile
104107
image: ${REGISTRY:-opea}/ipex-llm:${TAG:-latest}

comps/third_parties/ipex/src/Dockerfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ RUN apt-get update && \
1414
g++-12 \
1515
gcc-12 \
1616
git \
17-
make
17+
make \
1818
numactl \
1919
wget
2020

@@ -47,6 +47,7 @@ RUN apt-get update && \
4747
openssh-server && \
4848
apt-get clean && \
4949
rm -rf /var/lib/apt/lists/* && \
50+
if [ -f /etc/apt/apt.conf.d/proxy.conf ]; then rm /etc/apt/apt.conf.d/proxy.conf; fi
5051

5152
COPY --from=dev /root/intel-extension-for-pytorch/examples/cpu/llm ./llm
5253
COPY --from=dev /root/intel-extension-for-pytorch/tools/get_libstdcpp_lib.sh ./llm/tools
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
#!/bin/bash
2+
# Copyright (C) 2024 Intel Corporation
3+
# SPDX-License-Identifier: Apache-2.0
4+
5+
set -x
6+
7+
WORKPATH=$(dirname "$PWD")
8+
ip_address=$(hostname -I | awk '{print $1}')
9+
export DATA_PATH=${model_cache}
10+
11+
function build_docker_images() {
12+
echo "Start building docker images for microservice"
13+
cd $WORKPATH
14+
docker build --no-cache -t opea/ipex-llm:comps --build-arg https_proxy=$https_proxy --build-arg http_proxy=$http_proxy --build-arg COMPILE=ON --build-arg PORT_SSH=2345 -f comps/third_parties/ipex/src/Dockerfile .
15+
if [ $? -ne 0 ]; then
16+
echo "opea/ipex-llm built fail"
17+
exit 1
18+
else
19+
echo "opea/ipex-llm built successful"
20+
fi
21+
}
22+
23+
function start_service() {
24+
echo "Starting microservice"
25+
export host_ip=${ip_address}
26+
export MODEL_ID="microsoft/phi-4"
27+
export TAG=comps
28+
cd $WORKPATH
29+
cd comps/third_parties/ipex/deployment/docker_compose
30+
docker compose -f compose.yaml up -d
31+
echo "Microservice started"
32+
sleep 120
33+
}
34+
35+
function validate_microservice() {
36+
echo "Validate microservice started"
37+
result=$(http_proxy="" curl http://localhost:8688/v1/chat/completions \
38+
-X POST \
39+
-H "Content-Type: application/json" \
40+
-d '{
41+
"model": "microsoft/Phi-4-mini-instruct",
42+
"messages": [
43+
{"role": "user", "content": "What is Deep Learning?"}
44+
],
45+
"max_tokens": 32
46+
}'
47+
)
48+
if [[ $result == *"Deep"* ]]; then
49+
echo "Result correct."
50+
else
51+
echo "Result wrong."
52+
docker logs ipex-llm-server
53+
exit 1
54+
fi
55+
}
56+
57+
function stop_docker() {
58+
cid=$(docker ps -aq --filter "name=ipex-llm-server")
59+
echo "Shutdown legacy containers "$cid
60+
if [[ ! -z "$cid" ]]; then docker stop $cid && docker rm $cid && sleep 1s; fi
61+
}
62+
63+
function main() {
64+
65+
stop_docker
66+
67+
build_docker_images
68+
start_service
69+
70+
validate_microservice
71+
72+
stop_docker
73+
echo "cleanup container images and volumes"
74+
echo y | docker system prune 2>&1 > /dev/null
75+
76+
}
77+
78+
main

0 commit comments

Comments
 (0)