Skip to content
This repository was archived by the owner on Jul 4, 2025. It is now read-only.

Commit 3ab628b

Browse files
committed
Merge branch 'dev' into chore/docker-selfhosted-runner
2 parents 9f105ae + 8db7e9c commit 3ab628b

18 files changed

+489
-404
lines changed

.github/workflows/cortex-cpp-quality-gate.yml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ jobs:
102102
cd engine
103103
echo "huggingFaceToken: ${{ secrets.HUGGINGFACE_TOKEN_READ }}" > ~/.cortexrc
104104
echo "gitHubToken: ${{ secrets.PAT_SERVICE_ACCOUNT }}" >> ~/.cortexrc
105-
./build/cortex
105+
# ./build/cortex
106106
cat ~/.cortexrc
107107
108108
- name: Run unit tests
@@ -115,10 +115,10 @@ jobs:
115115
- name: Run setup config
116116
run: |
117117
cd engine
118-
echo "huggingFaceToken: ${{ secrets.HUGGINGFACE_TOKEN_READ }}" > ~/.cortexrc
118+
echo "apiServerPort: 3928" > ~/.cortexrc
119+
echo "huggingFaceToken: ${{ secrets.HUGGINGFACE_TOKEN_READ }}" >> ~/.cortexrc
119120
echo "gitHubToken: ${{ secrets.PAT_SERVICE_ACCOUNT }}" >> ~/.cortexrc
120-
echo "apiServerPort: 3928" >> ~/.cortexrc
121-
./build/cortex
121+
# ./build/cortex
122122
cat ~/.cortexrc
123123
124124
- name: Run e2e tests
@@ -205,6 +205,7 @@ jobs:
205205
--build-arg MINIO_SECRET_KEY="${{ secrets.MINIO_SECRET_ACCESS_KEY }}" \
206206
-t menloltd/cortex:test -f docker/Dockerfile.cache .
207207
docker run -it -d -p 3928:39281 --name cortex menloltd/cortex:test
208+
sleep 20
208209
209210
- name: use python
210211
uses: actions/setup-python@v5
@@ -222,6 +223,7 @@ jobs:
222223
continue-on-error: true
223224
if: always()
224225
run: |
226+
docker logs cortex
225227
docker stop cortex
226228
docker rm cortex
227229
echo "y\n" | docker system prune -af

docker/Dockerfile

Lines changed: 29 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,12 @@
1-
FROM ubuntu:22.04 as base
2-
3-
FROM base as build
4-
5-
ARG CORTEX_CPP_VERSION=latest
6-
7-
ARG CMAKE_EXTRA_FLAGS=""
1+
# Stage 1: Base dependencies (common stage)
2+
FROM ubuntu:22.04 as common
83

94
ENV DEBIAN_FRONTEND=noninteractive
105

11-
# Install dependencies
6+
# Install common dependencies
127
RUN apt-get update && apt-get install -y --no-install-recommends \
138
ca-certificates \
9+
software-properties-common \
1410
curl \
1511
wget \
1612
jq \
@@ -20,71 +16,65 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
2016
apt-get clean && \
2117
rm -rf /var/lib/apt/lists/*
2218

23-
RUN apt-get update && apt-get install -y --no-install-recommends \
19+
# Stage 2: Build dependencies and compilation
20+
FROM common as build
21+
22+
# Install Dependencies
23+
RUN wget -O - https://apt.kitware.com/keys/kitware-archive-latest.asc 2>/dev/null | gpg --dearmor - | tee /etc/apt/trusted.gpg.d/kitware.gpg >/dev/null && \
24+
apt-add-repository "deb https://apt.kitware.com/ubuntu/ $(lsb_release -cs) main" && \
25+
apt-get update && \
26+
apt-get install -y --no-install-recommends \
27+
cmake \
28+
make \
2429
git \
2530
uuid-dev \
2631
lsb-release \
27-
software-properties-common \
2832
gpg \
2933
zip \
3034
unzip \
3135
gcc \
3236
g++ \
3337
ninja-build \
3438
pkg-config \
39+
python3-pip \
3540
openssl && \
41+
pip3 install awscli && \
3642
apt-get clean && \
3743
rm -rf /var/lib/apt/lists/*
3844

39-
RUN wget -O - https://apt.kitware.com/keys/kitware-archive-latest.asc 2>/dev/null | gpg --dearmor - | tee /etc/apt/trusted.gpg.d/kitware.gpg >/dev/null && \
40-
apt-add-repository "deb https://apt.kitware.com/ubuntu/ $(lsb_release -cs) main" && \
41-
apt-get update && \
42-
apt-get install -y cmake && \
43-
apt-get clean && \
44-
rm -rf /var/lib/apt/lists/*
45+
ARG CORTEX_CPP_VERSION=latest
46+
ARG CMAKE_EXTRA_FLAGS=""
4547

4648
WORKDIR /app
4749

50+
# Copy source code
4851
COPY ./engine /app/engine
49-
5052
COPY ./docs/static/openapi/cortex.json /app/docs/static/openapi/cortex.json
5153

54+
# Build project
55+
# Configure vcpkg binary sources
5256
RUN cd engine && make configure-vcpkg && make build CMAKE_EXTRA_FLAGS="-DCORTEX_CPP_VERSION=${CORTEX_CPP_VERSION} -DCMAKE_BUILD_TEST=OFF -DCMAKE_TOOLCHAIN_FILE=vcpkg/scripts/buildsystems/vcpkg.cmake ${CMAKE_EXTRA_FLAGS}"
5357

54-
FROM base as runtime
55-
56-
ENV DEBIAN_FRONTEND=noninteractive
57-
58-
# Install dependencies
59-
RUN apt-get update && apt-get install -y --no-install-recommends \
60-
ca-certificates \
61-
curl \
62-
wget \
63-
jq \
64-
tar \
65-
openmpi-bin \
66-
libopenmpi-dev && \
67-
apt-get clean && \
68-
rm -rf /var/lib/apt/lists/*
69-
70-
ARG CORTEX_LLAMACPP_VERSION=latest
58+
# Stage 3: Runtime
7159

60+
WORKDIR /app
7261
COPY --from=build /app/engine/build/cortex /usr/local/bin/cortex
7362
COPY --from=build /app/engine/build/cortex-server /usr/local/bin/cortex-server
7463

7564
COPY ./docker/download-cortex.llamacpp.sh /tmp/download-cortex.llamacpp.sh
65+
COPY ./docker/entrypoint.sh /usr/local/bin/entrypoint.sh
7666

77-
# Get the latest version of the Cortex Llama
67+
# Get the latest version of Cortex Llama
68+
ARG CORTEX_LLAMACPP_VERSION=latest
7869
RUN chmod +x /tmp/download-cortex.llamacpp.sh && /bin/bash /tmp/download-cortex.llamacpp.sh ${CORTEX_LLAMACPP_VERSION}
7970

80-
# Copy the entrypoint script
81-
COPY ./docker/entrypoint.sh /usr/local/bin/entrypoint.sh
82-
71+
# Configure entrypoint
8372
RUN chmod +x /usr/local/bin/entrypoint.sh
8473

8574
EXPOSE 39281
8675

76+
# Healthcheck
8777
HEALTHCHECK --interval=300s --timeout=30s --start-period=10s --retries=3 \
8878
CMD curl -f http://127.0.0.1:39281/healthz || exit 1
89-
79+
9080
ENTRYPOINT ["/usr/local/bin/entrypoint.sh"]

docker/download-cortex.llamacpp.sh

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,18 @@ cd /opt/cortex.llamacpp
1313

1414
# Download the cortex.llamacpp engines
1515
echo -e "Downloading Cortex Llama version $VERSION"
16-
wget https://github.com/janhq/cortex.llamacpp/releases/download/v$VERSION/cortex.llamacpp-$VERSION-linux-amd64-avx-cuda-11-7.tar.gz > /dev/null
17-
wget https://github.com/janhq/cortex.llamacpp/releases/download/v$VERSION/cortex.llamacpp-$VERSION-linux-amd64-avx-cuda-12-0.tar.gz > /dev/null
18-
wget https://github.com/janhq/cortex.llamacpp/releases/download/v$VERSION/cortex.llamacpp-$VERSION-linux-amd64-avx.tar.gz > /dev/null
19-
wget https://github.com/janhq/cortex.llamacpp/releases/download/v$VERSION/cortex.llamacpp-$VERSION-linux-amd64-avx2-cuda-11-7.tar.gz > /dev/null
20-
wget https://github.com/janhq/cortex.llamacpp/releases/download/v$VERSION/cortex.llamacpp-$VERSION-linux-amd64-avx2-cuda-12-0.tar.gz > /dev/null
21-
wget https://github.com/janhq/cortex.llamacpp/releases/download/v$VERSION/cortex.llamacpp-$VERSION-linux-amd64-avx2.tar.gz > /dev/null
22-
wget https://github.com/janhq/cortex.llamacpp/releases/download/v$VERSION/cortex.llamacpp-$VERSION-linux-amd64-avx512-cuda-11-7.tar.gz > /dev/null
23-
wget https://github.com/janhq/cortex.llamacpp/releases/download/v$VERSION/cortex.llamacpp-$VERSION-linux-amd64-avx512-cuda-12-0.tar.gz > /dev/null
24-
wget https://github.com/janhq/cortex.llamacpp/releases/download/v$VERSION/cortex.llamacpp-$VERSION-linux-amd64-avx512.tar.gz > /dev/null
25-
wget https://github.com/janhq/cortex.llamacpp/releases/download/v$VERSION/cortex.llamacpp-$VERSION-linux-amd64-noavx-cuda-11-7.tar.gz > /dev/null
26-
wget https://github.com/janhq/cortex.llamacpp/releases/download/v$VERSION/cortex.llamacpp-$VERSION-linux-amd64-noavx-cuda-12-0.tar.gz > /dev/null
27-
wget https://github.com/janhq/cortex.llamacpp/releases/download/v$VERSION/cortex.llamacpp-$VERSION-linux-amd64-noavx.tar.gz > /dev/null
28-
wget https://github.com/janhq/cortex.llamacpp/releases/download/v$VERSION/cortex.llamacpp-$VERSION-linux-amd64-vulkan.tar.gz > /dev/null
29-
wget https://github.com/janhq/cortex.llamacpp/releases/download/v$VERSION/cuda-11-7-linux-amd64.tar.gz > /dev/null
30-
wget https://github.com/janhq/cortex.llamacpp/releases/download/v$VERSION/cuda-12-0-linux-amd64.tar.gz > /dev/null
16+
wget https://github.com/janhq/cortex.llamacpp/releases/download/v$VERSION/cortex.llamacpp-$VERSION-linux-amd64-avx-cuda-11-7.tar.gz
17+
wget https://github.com/janhq/cortex.llamacpp/releases/download/v$VERSION/cortex.llamacpp-$VERSION-linux-amd64-avx-cuda-12-0.tar.gz
18+
wget https://github.com/janhq/cortex.llamacpp/releases/download/v$VERSION/cortex.llamacpp-$VERSION-linux-amd64-avx.tar.gz
19+
wget https://github.com/janhq/cortex.llamacpp/releases/download/v$VERSION/cortex.llamacpp-$VERSION-linux-amd64-avx2-cuda-11-7.tar.gz
20+
wget https://github.com/janhq/cortex.llamacpp/releases/download/v$VERSION/cortex.llamacpp-$VERSION-linux-amd64-avx2-cuda-12-0.tar.gz
21+
wget https://github.com/janhq/cortex.llamacpp/releases/download/v$VERSION/cortex.llamacpp-$VERSION-linux-amd64-avx2.tar.gz
22+
wget https://github.com/janhq/cortex.llamacpp/releases/download/v$VERSION/cortex.llamacpp-$VERSION-linux-amd64-avx512-cuda-11-7.tar.gz
23+
wget https://github.com/janhq/cortex.llamacpp/releases/download/v$VERSION/cortex.llamacpp-$VERSION-linux-amd64-avx512-cuda-12-0.tar.gz
24+
wget https://github.com/janhq/cortex.llamacpp/releases/download/v$VERSION/cortex.llamacpp-$VERSION-linux-amd64-avx512.tar.gz
25+
wget https://github.com/janhq/cortex.llamacpp/releases/download/v$VERSION/cortex.llamacpp-$VERSION-linux-amd64-noavx-cuda-11-7.tar.gz
26+
wget https://github.com/janhq/cortex.llamacpp/releases/download/v$VERSION/cortex.llamacpp-$VERSION-linux-amd64-noavx-cuda-12-0.tar.gz
27+
wget https://github.com/janhq/cortex.llamacpp/releases/download/v$VERSION/cortex.llamacpp-$VERSION-linux-amd64-noavx.tar.gz
28+
wget https://github.com/janhq/cortex.llamacpp/releases/download/v$VERSION/cortex.llamacpp-$VERSION-linux-amd64-vulkan.tar.gz
29+
wget https://github.com/janhq/cortex.llamacpp/releases/download/v$VERSION/cuda-11-7-linux-amd64.tar.gz
30+
wget https://github.com/janhq/cortex.llamacpp/releases/download/v$VERSION/cuda-12-0-linux-amd64.tar.gz

docker/entrypoint.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,11 @@
55
echo "apiServerHost: 0.0.0.0" > /root/.cortexrc
66
echo "enableCors: true" >> /root/.cortexrc
77

8+
# Install the engine
89
cortex engines install llama-cpp -s /opt/cortex.llamacpp
10+
cortex engines list
911

1012
# Start the cortex server
11-
1213
cortex start
1314

1415
# Keep the container running by tailing the log files

0 commit comments

Comments
 (0)