generated from axonivy-market/market-product
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'document/IVYPORTAL-17735-Stage-1-Use-internal-OpenSearc…
…h-of-ivy-engine-as-the-vector-store' of https://github.com/axonivy-market/ai-assistant into dev/IVYPORTAL-18058-Adapt-ai-assistant-to-the-official-Axon-Ivy-12.0.0-release
- Loading branch information
Showing
18 changed files
with
2,048 additions
and
1 deletion.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
# Set vm.max_map_count using WSL | ||
if (wsl -l -q | Select-String -Pattern "rancher-desktop") { | ||
Write-Host "Setting vm.max_map_count to 262144 using WSL for Rancher Desktop..." | ||
wsl -d rancher-desktop sysctl -w vm.max_map_count=262144 | ||
} elseif (wsl -l -q | Select-String -Pattern "docker-desktop") { | ||
Write-Host "Setting vm.max_map_count to 262144 using WSL for Docker Desktop..." | ||
wsl -d docker-desktop sysctl -w vm.max_map_count=262144 | ||
} | ||
|
||
# Create directories if they do not exist | ||
$directories = @("./opensearch-data", "./opensearch-logs") | ||
foreach ($dir in $directories) { | ||
if (-not (Test-Path $dir)) { | ||
New-Item -ItemType Directory -Path $dir | ||
Write-Host "Created directory: $dir" | ||
} | ||
} | ||
|
||
# Set permissions for OpenSearch directories | ||
Write-Host "Setting permissions for data, and logs directories..." | ||
$acl = Get-Acl "./opensearch-data" | ||
$permission = "Everyone","FullControl","Allow" | ||
$accessRule = New-Object System.Security.AccessControl.FileSystemAccessRule $permission | ||
$acl.SetAccessRule($accessRule) | ||
Set-Acl "./opensearch-data" $acl | ||
|
||
$acl = Get-Acl "./opensearch-logs" | ||
$acl.SetAccessRule($accessRule) | ||
Set-Acl "./opensearch-logs" $acl | ||
|
||
# Create an .env file to store environment variables securely if it doesn't exist | ||
$envFilePath = ".env" | ||
if (-not (Test-Path $envFilePath)) { | ||
$envContent = @" | ||
OPENSEARCH_INITIAL_ADMIN_PASSWORD=1Ae0ce926bb6a0a1d1cf10c9c9e147a50457f9c27e49780c20e103a78036380d | ||
"@ | ||
Set-Content -Path $envFilePath -Value $envContent | ||
Write-Host "Created .env file with environment variables." | ||
} else { | ||
Write-Host ".env file already exists." | ||
} | ||
|
||
# Create docker-compose.yml file if it doesn't exist | ||
$composeFilePath = "docker-compose.yml" | ||
if (-not (Test-Path $composeFilePath)) { | ||
$composeContent = @" | ||
services: | ||
opensearch: | ||
image: opensearchproject/opensearch:2.17.1 | ||
container_name: axon-ivy-open-search-vector-store | ||
environment: | ||
- cluster.name=axon-ivy-open-search-vector-store-cluster | ||
- cluster.routing.allocation.disk.watermark.low=900mb | ||
- cluster.routing.allocation.disk.watermark.high=600mb | ||
- cluster.routing.allocation.disk.watermark.flood_stage=400mb | ||
- discovery.type=single-node | ||
- plugins.security.disabled=true | ||
- node.name=axon-ivy-open-search-vector-store-node | ||
- bootstrap.memory_lock=true | ||
- OPENSEARCH_JAVA_OPTS=-Xms1g -Xmx1g | ||
deploy: | ||
resources: | ||
limits: | ||
memory: 2g | ||
reservations: | ||
memory: 1g | ||
ulimits: | ||
memlock: | ||
soft: -1 | ||
hard: -1 | ||
nofile: | ||
soft: 65536 | ||
hard: 65536 | ||
ports: | ||
- "19201:9200" | ||
volumes: | ||
- type: bind | ||
source: ./opensearch-data | ||
target: /usr/share/opensearch/data | ||
- type: bind | ||
source: ./opensearch-logs | ||
target: /usr/share/opensearch/logs | ||
restart: unless-stopped | ||
env_file: | ||
- .env | ||
"@ | ||
Set-Content -Path $composeFilePath -Value $composeContent | ||
Write-Host "docker-compose.yml file created." | ||
} else { | ||
Write-Host "docker-compose.yml file already exists." | ||
} | ||
|
||
# Start Docker Compose | ||
Write-Host "Starting Docker Compose..." | ||
docker compose up | ||
|
||
# Keep PowerShell window open | ||
Write-Host "Press Enter to exit..." | ||
Read-Host |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,116 @@ | ||
#!/bin/bash | ||
|
||
# Set vm.max_map_count using WSL if on Windows with WSL | ||
if [[ "$(uname -r)" == *"Microsoft"* ]]; then | ||
if wsl -l -q | grep -q "rancher-desktop"; then | ||
echo "Setting vm.max_map_count to 262144 using WSL for Rancher Desktop..." | ||
wsl -d rancher-desktop sysctl -w vm.max_map_count=262144 | ||
elif wsl -l -q | grep -q "docker-desktop"; then | ||
echo "Setting vm.max_map_count to 262144 using WSL for Docker Desktop..." | ||
wsl -d docker-desktop sysctl -w vm.max_map_count=262144 | ||
fi | ||
else | ||
# For native Linux and macOS, set vm.max_map_count directly | ||
echo "Setting vm.max_map_count to 262144..." | ||
sudo sysctl -w vm.max_map_count=262144 | ||
fi | ||
|
||
# Create directories if they do not exist | ||
create_directories() { | ||
directories=("opensearch-data" "opensearch-logs") | ||
for dir in "${directories[@]}"; do | ||
if [ ! -d "$dir" ]; then | ||
mkdir -p "$dir" | ||
echo "Created directory: $dir" | ||
fi | ||
done | ||
} | ||
|
||
# Set permissions for OpenSearch directories | ||
set_permissions() { | ||
echo "Setting permissions for data and logs directories..." | ||
chmod -R 777 ./opensearch-data | ||
chmod -R 777 ./opensearch-logs | ||
} | ||
|
||
# Create an .env file to store environment variables securely if it doesn't exist | ||
create_env_file() { | ||
envFilePath=".env" | ||
envContent="OPENSEARCH_INITIAL_ADMIN_PASSWORD=1Ae0ce926bb6a0a1d1cf10c9c9e147a50457f9c27e49780c20e103a78036380d" | ||
if [ ! -f "$envFilePath" ]; then | ||
echo "$envContent" > "$envFilePath" | ||
echo "Created .env file with environment variables." | ||
else | ||
echo ".env file already exists." | ||
fi | ||
} | ||
|
||
# Create docker-compose.yml file if it doesn't exist | ||
create_docker_compose_file() { | ||
composeFilePath="docker-compose.yml" | ||
if [ ! -f "$composeFilePath" ]; then | ||
composeContent=$(cat <<EOF | ||
services: | ||
opensearch: | ||
image: opensearchproject/opensearch:2.17.1 | ||
container_name: axon-ivy-open-search-vector-store | ||
environment: | ||
- cluster.name=axon-ivy-open-search-vector-store-cluster | ||
- cluster.routing.allocation.disk.watermark.low=900mb | ||
- cluster.routing.allocation.disk.watermark.high=600mb | ||
- cluster.routing.allocation.disk.watermark.flood_stage=400mb | ||
- discovery.type=single-node | ||
- plugins.security.disabled=true | ||
- node.name=axon-ivy-open-search-vector-store-node | ||
- bootstrap.memory_lock=true | ||
- OPENSEARCH_JAVA_OPTS=-Xms1g -Xmx1g | ||
deploy: | ||
resources: | ||
limits: | ||
memory: 2g | ||
reservations: | ||
memory: 1g | ||
ulimits: | ||
memlock: | ||
soft: -1 | ||
hard: -1 | ||
nofile: | ||
soft: 65536 | ||
hard: 65536 | ||
ports: | ||
- "19201:9200" | ||
volumes: | ||
- type: bind | ||
source: ./opensearch-data | ||
target: /usr/share/opensearch/data | ||
- type: bind | ||
source: ./opensearch-logs | ||
target: /usr/share/opensearch/logs | ||
restart: unless-stopped | ||
env_file: | ||
- .env | ||
EOF | ||
) | ||
echo "$composeContent" > "$composeFilePath" | ||
echo "docker-compose.yml file created." | ||
else | ||
echo "docker-compose.yml file already exists." | ||
fi | ||
} | ||
|
||
# Start Docker Compose | ||
start_docker_compose() { | ||
echo "Starting Docker Compose..." | ||
docker compose up | ||
} | ||
|
||
# Main script execution | ||
create_directories | ||
set_permissions | ||
create_env_file | ||
create_docker_compose_file | ||
start_docker_compose | ||
|
||
# Keep Bash shell open | ||
echo "Press Enter to exit..." | ||
read -r |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.