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

Commit 287123e

Browse files
authored
Merge pull request #1747 from janhq/dev
Sync dev to main for v1.0.4-rc2
2 parents 9725403 + 9622b91 commit 287123e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

64 files changed

+2150
-618
lines changed

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

Lines changed: 87 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ on:
55
types: [opened, synchronize, reopened, ready_for_review]
66
paths: ["engine/**", ".github/workflows/cortex-cpp-quality-gate.yml"]
77
workflow_dispatch:
8+
schedule:
9+
- cron: '0 22 * * *'
810

911
env:
1012
LLM_MODEL_URL: https://delta.jan.ai/tinyllama-1.1b-chat-v0.3.Q2_K.gguf
@@ -102,7 +104,7 @@ jobs:
102104
cd engine
103105
echo "huggingFaceToken: ${{ secrets.HUGGINGFACE_TOKEN_READ }}" > ~/.cortexrc
104106
echo "gitHubToken: ${{ secrets.PAT_SERVICE_ACCOUNT }}" >> ~/.cortexrc
105-
./build/cortex
107+
# ./build/cortex
106108
cat ~/.cortexrc
107109
108110
- name: Run unit tests
@@ -115,10 +117,10 @@ jobs:
115117
- name: Run setup config
116118
run: |
117119
cd engine
118-
echo "huggingFaceToken: ${{ secrets.HUGGINGFACE_TOKEN_READ }}" > ~/.cortexrc
120+
echo "apiServerPort: 3928" > ~/.cortexrc
121+
echo "huggingFaceToken: ${{ secrets.HUGGINGFACE_TOKEN_READ }}" >> ~/.cortexrc
119122
echo "gitHubToken: ${{ secrets.PAT_SERVICE_ACCOUNT }}" >> ~/.cortexrc
120-
echo "apiServerPort: 3928" >> ~/.cortexrc
121-
./build/cortex
123+
# ./build/cortex
122124
cat ~/.cortexrc
123125
124126
- name: Run e2e tests
@@ -149,6 +151,34 @@ jobs:
149151
env:
150152
GITHUB_TOKEN: ${{ secrets.PAT_SERVICE_ACCOUNT }}
151153

154+
- name: Run e2e tests
155+
if: github.event_name == 'schedule' && runner.os != 'Windows' && github.event.pull_request.draft == false
156+
run: |
157+
cd engine
158+
cp build/cortex build/cortex-nightly
159+
cp build/cortex build/cortex-beta
160+
python -m pip install --upgrade pip
161+
python -m pip install -r e2e-test/requirements.txt
162+
python e2e-test/cortex-llamacpp-e2e-nightly.py
163+
rm build/cortex-nightly
164+
rm build/cortex-beta
165+
env:
166+
GITHUB_TOKEN: ${{ secrets.PAT_SERVICE_ACCOUNT }}
167+
168+
- name: Run e2e tests
169+
if: github.event_name == 'schedule' && runner.os == 'Windows' && github.event.pull_request.draft == false
170+
run: |
171+
cd engine
172+
cp build/cortex.exe build/cortex-nightly.exe
173+
cp build/cortex.exe build/cortex-beta.exe
174+
python -m pip install --upgrade pip
175+
python -m pip install -r e2e-test/requirements.txt
176+
python e2e-test/cortex-llamacpp-e2e-nightly.py
177+
rm build/cortex-nightly.exe
178+
rm build/cortex-beta.exe
179+
env:
180+
GITHUB_TOKEN: ${{ secrets.PAT_SERVICE_ACCOUNT }}
181+
152182
- name: Pre-package
153183
run: |
154184
cd engine
@@ -188,40 +218,58 @@ jobs:
188218
AWS_SECRET_ACCESS_KEY: "${{ secrets.MINIO_SECRET_ACCESS_KEY }}"
189219
AWS_DEFAULT_REGION: "${{ secrets.MINIO_REGION }}"
190220

191-
# build-docker-and-test:
192-
# runs-on: ubuntu-latest
193-
# steps:
194-
# - name: Getting the repo
195-
# uses: actions/checkout@v3
196-
# with:
197-
# submodules: 'recursive'
221+
build-docker-and-test:
222+
runs-on: ubuntu-24-04-docker
223+
steps:
224+
- name: Getting the repo
225+
uses: actions/checkout@v3
226+
with:
227+
submodules: 'recursive'
228+
229+
- name: Run Docker
230+
if: github.event_name != 'schedule'
231+
run: |
232+
docker build \
233+
--build-arg REMOTE_CACHE_URL="${{ secrets.MINIO_ENDPOINT }}/vcpkg-cache" \
234+
--build-arg MINIO_ENDPOINT_URL="${{ secrets.MINIO_ENDPOINT }}" \
235+
--build-arg MINIO_ACCESS_KEY="${{ secrets.MINIO_ACCESS_KEY_ID }}" \
236+
--build-arg MINIO_SECRET_KEY="${{ secrets.MINIO_SECRET_ACCESS_KEY }}" \
237+
-t menloltd/cortex:test -f docker/Dockerfile.cache .
238+
docker run -it -d -p 3928:39281 --name cortex menloltd/cortex:test
239+
sleep 20
198240
199-
# - name: Set up QEMU
200-
# uses: docker/setup-qemu-action@v3
241+
- name: Run Docker
242+
if: github.event_name == 'schedule'
243+
run: |
244+
latest_prerelease=$(curl -s https://api.github.com/repos/cortexcpp/cortex.cpp/releases | jq -r '.[] | select(.prerelease == true) | .tag_name' | head -n 1)
245+
echo "cortex.llamacpp latest release: $latest_prerelease"
246+
docker build \
247+
--build-arg REMOTE_CACHE_URL="${{ secrets.MINIO_ENDPOINT }}/vcpkg-cache" \
248+
--build-arg MINIO_ENDPOINT_URL="${{ secrets.MINIO_ENDPOINT }}" \
249+
--build-arg MINIO_ACCESS_KEY="${{ secrets.MINIO_ACCESS_KEY_ID }}" \
250+
--build-arg MINIO_SECRET_KEY="${{ secrets.MINIO_SECRET_ACCESS_KEY }}" \
251+
--build-arg CORTEX_CPP_VERSION="${latest_prerelease}" \
252+
-t menloltd/cortex:test -f docker/Dockerfile.cache .
253+
docker run -it -d -p 3928:39281 --name cortex menloltd/cortex:test
254+
sleep 20
201255
202-
# - name: Set up Docker Buildx
203-
# uses: docker/setup-buildx-action@v3
204-
205-
# - name: Run Docker
206-
# run: |
207-
# docker build -t menloltd/cortex:test -f docker/Dockerfile .
208-
# docker run -it -d -p 3928:39281 --name cortex menloltd/cortex:test
209-
210-
# - name: use python
211-
# uses: actions/setup-python@v5
212-
# with:
213-
# python-version: "3.10"
214-
215-
# - name: Run e2e tests
216-
# run: |
217-
# cd engine
218-
# python -m pip install --upgrade pip
219-
# python -m pip install -r e2e-test/requirements.txt
220-
# pytest e2e-test/test_api_docker.py
221-
222-
# - name: Run Docker
223-
# continue-on-error: true
224-
# if: always()
225-
# run: |
226-
# docker stop cortex
227-
# docker rm cortex
256+
- name: use python
257+
uses: actions/setup-python@v5
258+
with:
259+
python-version: "3.10"
260+
261+
- name: Run e2e tests
262+
run: |
263+
cd engine
264+
python -m pip install --upgrade pip
265+
python -m pip install -r e2e-test/requirements.txt
266+
pytest e2e-test/test_api_docker.py
267+
268+
- name: Run Docker
269+
continue-on-error: true
270+
if: always()
271+
run: |
272+
docker logs cortex
273+
docker stop cortex
274+
docker rm cortex
275+
echo "y\n" | docker system prune -af

docker/Dockerfile

Lines changed: 30 additions & 40 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
71-
58+
# Stage 3: Runtime
59+
FROM common as runtime
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"]

0 commit comments

Comments
 (0)