Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add flist and dockerfile for openwebui #328

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions tfgrid3/openwebui/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
FROM ubuntu:22.04

Check failure

Code scanning / Trivy

Image user should not be 'root' High

Artifact: tfgrid3/openwebui/Dockerfile
Type: dockerfile
Vulnerability DS002
Severity: HIGH
Message: Specify at least 1 USER command in Dockerfile with non-root user as argument
Link: DS002

RUN apt update && \
apt -y install wget openssh-server curl sudo iproute2

RUN wget -O /sbin/zinit https://github.com/threefoldtech/zinit/releases/download/v0.2.5/zinit && \
chmod +x /sbin/zinit

RUN curl -fsSL https://get.docker.com -o /usr/local/bin/install-docker.sh && \
chmod +x /usr/local/bin/install-docker.sh

RUN sh /usr/local/bin/install-docker.sh

COPY ./scripts/ /scripts/
COPY ./zinit/ /etc/zinit/
RUN chmod +x /scripts/*.sh

ENTRYPOINT ["/sbin/zinit", "init"]
115 changes: 115 additions & 0 deletions tfgrid3/openwebui/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
<h1> OpenWebUI Deployment with Ollama Flist</h1>

<h2> Table of Contents </h2>

- [Introduction](#introduction)
- [Directory Structure](#directory-structure)
- [Create the Docker Image](#create-the-docker-image)
- [Convert the Docker Image to Zero-OS FList](#convert-the-docker-image-to-zero-os-flist)
- [TFGrid Deployment](#tfgrid-deployment)
- [Playground Steps](#playground-steps)
- [Conclusion](#conclusion)

***

## Introduction

This project provides a self-contained deployment of **OpenWebUI** on the ThreeFold Grid, using a micro VM. The deployment is managed via **zinit** for automatic service management and includes:

- Docker daemon for container management
- Secure SSH server configuration
- **OpenWebUI** with Ollama integration
- Automatic container updates via Watchtower
- Self-healing services via **zinit**

The deployment automatically provisions:
- Secure SSH access
- OpenWebUI on port `8080`
- Persistent storage for Docker and WebUI data

***

## Directory Structure

```
.
├── Dockerfile
├── README.md
├── scripts
│ ├── start_containers.sh
│ └── sshd_init.sh
└── zinit
├── dockerd.yaml
├── start_containers.yaml
├── sshd.yaml
└── ssh-init.yaml
```

- **`scripts/`**: Contains initialization and service scripts
- **`zinit/`**: Contains **zinit** service configurations for managing services
- **`Dockerfile`**: Defines the Docker image with all dependencies and configurations

***

## Create the Docker Image

To create the Docker image:

1. Clone this repository:
```bash
git clone https://github.com/threefoldtech/tf-images
cd ./tf-images/tfgrid3/openwebui
```

2. Build the Docker image:
```bash
docker build -t <your-dockerhub-username>/openwebui-tfgrid .
```

3. Push to Docker Hub:
```bash
docker push <your-dockerhub-username>/openwebui-tfgrid
```

***

## Convert the Docker Image to Zero-OS FList

1. Use the [TF Hub Docker Converter](https://hub.grid.tf/docker-convert)
2. Enter your Docker image name:
```text
<your-dockerhub-username>/openwebui-tfgrid:latest
```
3. Convert and get your FList URL (example):
```text
https://hub.grid.tf/<your-3bot>/openwebui-tfgrid-latest.flist
```

***

## TFGrid Deployment

### Playground Steps

1. Go to [ThreeFold Dashboard](https://dashboard.grid.tf)
2. Create a Micro VM:
- **VM Image**: Paste your FList URL
- **Entry Point**: `/sbin/zinit init` (default)
- **Resources**: Minimum 2 vCPU, 4GB RAM, 10GB disk
- **Mount**: Add a mount point at `/mnt/data`
3. Deploy
4. Set a gateway domain with port 8080 to access OpenWebUI

***

## Conclusion

This FList provides a self-contained deployment of **OpenWebUI** with Ollama on the ThreeFold Grid with:
- Automatic service management via **zinit**
- Docker container management
- Automatic container updates via Watchtower
- SSH access for maintenance
- Persistent storage for data
- Easy deployment via Docker and TF Grid

Deploy and enjoy a fully functional OpenWebUI setup on the decentralized ThreeFold Grid!
6 changes: 6 additions & 0 deletions tfgrid3/openwebui/scripts/sshd_init.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/bash

mkdir -p ~/.ssh
mkdir -p /var/run/sshd
chmod 600 ~/.ssh
chmod 600 /etc/ssh/*
22 changes: 22 additions & 0 deletions tfgrid3/openwebui/scripts/start_containers.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/bin/bash

# Wait for Docker daemon
while ! docker info >/dev/null 2>&1; do
echo "Waiting for Docker..."
sleep 2
done

# Start OpenWebUI container
docker run \
-d \
-p 8080:8080 \
-v ollama:/root/.ollama \
-v open-webui:/app/backend/data \
--name open-webui \
--restart always \
ghcr.io/open-webui/open-webui:ollama

# Start WatchTower container
docker run -d --name watchtower \
--volume /var/run/docker.sock:/var/run/docker.sock \
containrrr/watchtower -i 300 open-webui
1 change: 1 addition & 0 deletions tfgrid3/openwebui/zinit/dockerd.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
exec: /usr/bin/dockerd --data-root /mnt/data/docker
2 changes: 2 additions & 0 deletions tfgrid3/openwebui/zinit/ssh-init.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
exec: /scripts/sshd_init.sh
oneshot: true
3 changes: 3 additions & 0 deletions tfgrid3/openwebui/zinit/sshd.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
exec: bash -c "/usr/sbin/sshd -D"
after:
- ssh-init
4 changes: 4 additions & 0 deletions tfgrid3/openwebui/zinit/start_containers.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
exec: /scripts/start_containers.sh
oneshot: true
after:
- dockerd
Loading