Skip to content

Commit

Permalink
Merge branch 'dev' into feat/cicd-docker
Browse files Browse the repository at this point in the history
  • Loading branch information
hientominh committed Nov 6, 2024
2 parents e6cf0ff + 90bcb79 commit c04b46c
Show file tree
Hide file tree
Showing 7 changed files with 51 additions and 47 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/beta-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ jobs:
ref: ${{ github.ref }}
new_version: ${{ needs.get-update-version.outputs.new_version }}
runs-on: ubuntu-latest
cmake-extra-flags: "-DCORTEX_VARIANT=beta"
cmake-extra-flags: "-DCORTEX_VARIANT=prod"
tags: "menloltd/cortex:${{ needs.get-update-version.outputs.new_version }}"

update_release:
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/cortex-cpp-quality-gate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,8 @@ jobs:
run: |
cd engine
make run-unit-tests
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Run setup config for macos
if: runner.os == 'macOS'
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/nightly-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ jobs:
ref: ${{ needs.set-public-provider.outputs.ref }}
new_version: nightly-${{ needs.get-update-version.outputs.new_version }}
runs-on: ubuntu-latest
cmake-extra-flags: "-DCORTEX_VARIANT=nightly"
cmake-extra-flags: "-DCORTEX_VARIANT=prod"
tags: menloltd/cortex:nightly-${{ needs.get-update-version.outputs.new_version }}

noti-discord-nightly-and-update-url-readme:
Expand Down
5 changes: 3 additions & 2 deletions .github/workflows/template-build-docker-x64.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,11 @@ jobs:
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }}
run: |
README_CONTENT=$(cat docker/README.md | tr -d '\r' | sed ':a;N;$!ba;s/\n/\\n/g' | sed 's/"/\\"/g')
README_CONTENT=$(cat docker/README.md | tr -d '\r' | sed ':a;N;$!ba;s/\n/\\n/g')
JSON_PAYLOAD=$(printf '{"full_description": "%s"}' "$README_CONTENT")
curl -X PATCH \
-H "Content-Type: application/json" \
-H "Authorization: JWT $(curl -s -H "Content-Type: application/json" -X POST -d '{"username": "'"$DOCKERHUB_USERNAME"'", "password": "'"$DOCKERHUB_TOKEN"'"}' https://hub.docker.com/v2/users/login/ | jq -r .token)" \
-d "{\"full_description\": \"$README_CONTENT\"}" \
-d "{\"full_description\": \"$JSON_PAYLOAD\"}" \
https://hub.docker.com/v2/repositories/menloltd/cortex/
2 changes: 2 additions & 0 deletions .github/workflows/test-cortexso-model-hub.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ jobs:
run: |
cd engine
make run-unit-tests
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Run setup config for linux
shell: bash
Expand Down
82 changes: 40 additions & 42 deletions docker/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,58 +10,56 @@ For more information on how to use Cortex, please refer to the [Cortex Documenta

### Instructions

#### Build Cortex Docker Image from source or Pull from Docker Hub
**Build Cortex Docker Image from source or Pull from Docker Hub**

##### Pull Cortex Docker Image from Docker Hub
- Pull Cortex Docker Image from Docker Hub

```bash
# Pull the latest image
docker pull menloltd/cortex:latest
```bash
# Pull the latest image
docker pull menloltd/cortex:latest

# Pull a specific version
docker pull menloltd/cortex:nightly-1.0.1-224
```
# Pull a specific version
docker pull menloltd/cortex:nightly-1.0.1-224
```

##### Build and Run Cortex Docker Container from Dockerfile
- Build and Run Cortex Docker Container from Dockerfile

1. Clone the Cortex repository
```bash
git clone https://github.com/janhq/cortex.cpp.git
cd cortex.cpp
git submodule update --init
```
2. Build the Docker image
```bash
# Default always uses the latest cortex.cpp and cortex.llamacpp
docker build -t cortex --build-arg CORTEX_CPP_VERSION=$(git rev-parse HEAD) -f docker/Dockerfile .
```bash
git clone https://github.com/janhq/cortex.cpp.git
cd cortex.cpp
git submodule update --init

# Use specific version of cortex.cpp and cortex.llamacpp
docker build --build-arg CORTEX_LLAMACPP_VERSION=0.1.34 --build-arg CORTEX_CPP_VERSION=$(git rev-parse HEAD) -t cortex -f docker/Dockerfile .
```
# Default always uses the latest cortex.cpp and cortex.llamacpp
docker build -t menloltd/cortex --build-arg CORTEX_CPP_VERSION=$(git rev-parse HEAD) -f docker/Dockerfile .

#### Run Cortex Docker Container
# Use specific version of cortex.cpp and cortex.llamacpp
docker build --build-arg CORTEX_LLAMACPP_VERSION=0.1.34 --build-arg CORTEX_CPP_VERSION=$(git rev-parse HEAD) -t menloltd/cortex -f docker/Dockerfile .
```

1. Run the Docker container
```bash
# Create Volume to store models and data
docker volume create cortex_data
**Run Cortex Docker Container**

# CPU mode
docker run -it -d --name cortex -v cortex_data:/root/cortexcpp -p 39281:39281 cortex
```bash
# Create Volume to store models and data
docker volume create cortex_data

# GPU mode - nvidia-docker required, it will automatically use all available GPUs
docker run --gpus all -it -d --name cortex -v cortex_data:/root/cortexcpp -p 39281:39281 cortex
```
# GPU mode - nvidia-docker required, it will automatically use all available GPUs
docker run --gpus all -it -d --name cortex -v cortex_data:/root/cortexcpp -p 39281:39281 menloltd/cortex

2. Check logs (Optional)
```bash
docker logs cortex
```
# CPU mode
docker run -it -d --name cortex -v cortex_data:/root/cortexcpp -p 39281:39281 menloltd/cortex
```

3. Access to http://localhost:39281 to check the cortex docs API.
**Check logs (Optional)**

4. Execute to container and try out cortex cli
```bash
docker exec -it cortex bash
cortex --help
```
```bash
docker logs cortex
```

**Access to http://localhost:39281 to check the cortex docs API.**

**Execute to container and try out cortex cli**

```bash
docker exec -it cortex bash
cortex --help
```
3 changes: 2 additions & 1 deletion engine/cli/commands/cortex_upd_cmd.cc
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ std::unique_ptr<system_info_utils::SystemInfo> GetSystemInfoWithUniversal() {
std::string GetNightlyInstallerName(const std::string& v,
const std::string& os_arch) {
const std::string kCortex = "cortex";
std::string version = v == "latest" ? "" : (v + "-");
// Remove 'v' in file name
std::string version = v == "latest" ? "" : (v.substr(1) + "-");
#if defined(__APPLE__) && defined(__MACH__)
return kCortex + "-" + version + os_arch + "-network-installer.pkg";
#elif defined(__linux__)
Expand Down

0 comments on commit c04b46c

Please sign in to comment.