feat(tfgrid3deployer): add openwebui deployment example

- Adds a new example demonstrating deployment of OpenWebUI on the ThreeFold Grid using the `tfgrid3deployer` module.
- Provides detailed instructions and a README file for easy setup and execution.

Co-authored-by: mahmmoud.hassanein <mahmmoud.hassanein@gmail.com>
This commit is contained in:
2025-02-05 11:51:05 +02:00
parent 5bbb99c3f9
commit babbb610d9
2 changed files with 94 additions and 0 deletions

View File

@@ -0,0 +1,41 @@
#!/usr/bin/env -S v -gc none -no-retry-compilation -d use_openssl -enable-globals -cg run
//#!/usr/bin/env -S v -gc none -no-retry-compilation -cc tcc -d use_openssl -enable-globals -cg run
import freeflowuniverse.herolib.threefold.gridproxy
import freeflowuniverse.herolib.threefold.tfgrid3deployer
import freeflowuniverse.herolib.installers.threefold.griddriver
import os
import time
griddriver.install()!
v := tfgrid3deployer.get()!
println('cred: ${v}')
deployment_name := 'openwebui_example'
mut deployment := tfgrid3deployer.new_deployment(deployment_name)!
deployment.add_machine(
name: 'vm1'
cpu: 1
memory: 16
planetary: true
size: 100 // 10 gig
flist: 'https://hub.grid.tf/mariobassem1.3bot/docker.io-threefolddev-open_webui-latest.flist'
)
deployment.deploy()!
vm1 := deployment.vm_get('vm1')!
println('vm1 info: ${vm1}')
deployment.add_webname(
name: 'openwebui'
backend: 'http://${vm1.wireguard_ip}:8080'
use_wireguard_network: true
)
deployment.deploy()!
gw1 := deployment.webname_get('openwebui')!
println('gw info: ${gw1}')
// tfgrid3deployer.delete_deployment(deployment_name)!

View File

@@ -0,0 +1,53 @@
# OpenWebUI Deployment on ThreeFold Grid
## Overview
This script automates the deployment of an OpenWebUI instance on the ThreeFold Grid using the `tfgrid3deployer` module. It sets up a virtual machine (VM), configures networking, and assigns a webname for easy access.
## Requirements
- V compiler installed
- OpenSSL support enabled
- herolib dependencies:
- `freeflowuniverse.herolib.threefold.gridproxy`
- `freeflowuniverse.herolib.threefold.tfgrid3deployer`
- `freeflowuniverse.herolib.installers.threefold.griddriver`
## Installation
Ensure you have the required dependencies installed. The script will automatically install the `griddriver` before proceeding.
## Usage
Run the script using the following command:
```sh
./open_webui_gw.vsh
```
### Script Execution Steps
1. Installs the necessary ThreeFold Grid driver.
2. Retrieves credentials for deployment.
3. Creates a new deployment named `openwebui_example`.
4. Adds a VM with the following specifications:
- 1 CPU
- 16GB RAM
- 100GB storage
- Uses planetary networking
- Deploys OpenWebUI from the ThreeFold Hub.
5. Deploys the VM.
6. Retrieves VM information.
7. Configures a webname (`openwebui`) pointing to the VM's backend.
8. Deploys the webname for public access.
9. Retrieves and displays webname gateway details.
## Cleanup
To delete the deployment, run the following line in the script:
```v
tfgrid3deployer.delete_deployment(deployment_name)!
```
## Gateway Information
The gateway points to the WireGuard IP of the VM on port 8080, which is the port that the OpenWebUI server is listening on.
## Notes
- Ensure you have a valid ThreeFold Grid account and necessary permissions to deploy resources.
- Adjust VM specifications based on your requirements.