From 35f93c663f666efb0585bb9a265c2a9b3429fe76 Mon Sep 17 00:00:00 2001 From: Marcin Tojek Date: Wed, 3 Dec 2025 09:37:54 +0000 Subject: [PATCH 01/15] feat: add open-webui module for coder-labs - Installs Open WebUI via pip (Python 3.11+ required) - Auto-installs Python 3.11 from deadsnakes PPA if not available - Configurable port, share level, logging - Subdomain support for clean URLs --- .../coder-labs/modules/open-webui/README.md | 109 ++++++++++++++++++ .../coder-labs/modules/open-webui/main.tf | 72 ++++++++++++ registry/coder-labs/modules/open-webui/run.sh | 93 +++++++++++++++ 3 files changed, 274 insertions(+) create mode 100644 registry/coder-labs/modules/open-webui/README.md create mode 100644 registry/coder-labs/modules/open-webui/main.tf create mode 100755 registry/coder-labs/modules/open-webui/run.sh diff --git a/registry/coder-labs/modules/open-webui/README.md b/registry/coder-labs/modules/open-webui/README.md new file mode 100644 index 000000000..6281560f5 --- /dev/null +++ b/registry/coder-labs/modules/open-webui/README.md @@ -0,0 +1,109 @@ +--- +display_name: Open WebUI +description: A self-hosted AI chat interface supporting various LLM providers +icon: ../../../../.icons/openai.svg +verified: false +tags: [ai, llm, chat, web-ui, python] +--- + +# Open WebUI + +Open WebUI is a user-friendly web interface for interacting with Large Language Models. It provides a ChatGPT-like interface that can connect to various LLM providers including OpenAI, Ollama, and more. + +This module installs and runs Open WebUI using Python and pip within your Coder workspace. + +## Prerequisites + +- **Python 3.11 or higher** (automatically installed from deadsnakes PPA if not present) +- `pip` package manager +- `sudo` access (for automatic Python installation if needed) +- Port 8080 (default) or your custom port must be available + +**Note:** If Python 3.11+ is not found, the module will automatically: +1. Add the deadsnakes PPA repository +2. Install Python 3.11 with venv and dev packages +3. Install pip if not available + +## Basic Usage + +```tf +module "open-webui" { + count = data.coder_workspace.me.start_count + source = "registry.coder.com/coder-labs/open-webui/coder" + version = "1.0.0" + agent_id = coder_agent.main.id +} +``` + +## Examples + +### Custom Port + +Run Open WebUI on a custom port: + +```tf +module "open-webui" { + count = data.coder_workspace.me.start_count + source = "registry.coder.com/coder-labs/open-webui/coder" + version = "1.0.0" + agent_id = coder_agent.main.id + port = 3000 +} +``` + +### Public Sharing + +Make Open WebUI accessible to authenticated Coder users: + +```tf +module "open-webui" { + count = data.coder_workspace.me.start_count + source = "registry.coder.com/coder-labs/open-webui/coder" + version = "1.0.0" + agent_id = coder_agent.main.id + share = "authenticated" +} +``` + +### Custom Log Path and Grouping + +```tf +module "open-webui" { + count = data.coder_workspace.me.start_count + source = "registry.coder.com/coder-labs/open-webui/coder" + version = "1.0.0" + agent_id = coder_agent.main.id + log_path = "/var/log/open-webui.log" + group = "AI Tools" + order = 1 +} +``` + +## Features + +- 🐍 Pure Python installation (no Docker required) +- 🔄 Automatic Python 3.11+ installation from deadsnakes PPA +- 💾 Data stored in `~/.open-webui` directory +- 🚀 Runs in background as a Python process +- 📝 Configurable logging +- 🌐 Subdomain support for clean URLs +- 🔧 Compatible with various LLM providers (OpenAI, Ollama, etc.) + +## Data Persistence + +Open WebUI data is stored in `~/.open-webui` directory in your workspace, which includes: +- User accounts +- Chat history +- Settings and configurations +- Model configurations + +## Installation Process + +The module automatically handles the installation: + +1. **Check Python Version**: Looks for Python 3.11+ (checks python3.13, python3.12, python3.11, python3, python) +2. **Install Python if Needed**: If not found, installs Python 3.11 from deadsnakes PPA +3. **Install pip**: Ensures pip is available +4. **Install Open WebUI**: Installs open-webui package via pip +5. **Start Server**: Launches Open WebUI on the specified port + diff --git a/registry/coder-labs/modules/open-webui/main.tf b/registry/coder-labs/modules/open-webui/main.tf new file mode 100644 index 000000000..3276dc644 --- /dev/null +++ b/registry/coder-labs/modules/open-webui/main.tf @@ -0,0 +1,72 @@ +terraform { + required_version = ">= 1.0" + + required_providers { + coder = { + source = "coder/coder" + version = ">= 2.5" + } + } +} + +# Add required variables for your modules and remove any unneeded variables +variable "agent_id" { + type = string + description = "The ID of a Coder agent." +} + +variable "log_path" { + type = string + description = "The path to log Open WebUI to." + default = "/tmp/open-webui.log" +} + +variable "port" { + type = number + description = "The port to run Open WebUI on." + default = 8080 +} + +variable "share" { + type = string + default = "owner" + validation { + condition = var.share == "owner" || var.share == "authenticated" || var.share == "public" + error_message = "Incorrect value. Please set either 'owner', 'authenticated', or 'public'." + } +} + +variable "order" { + type = number + description = "The order determines the position of app in the UI presentation. The lowest order is shown first and apps with equal order are sorted by name (ascending order)." + default = null +} + +variable "group" { + type = string + description = "The name of a group that this app belongs to." + default = null +} + +resource "coder_script" "open-webui" { + agent_id = var.agent_id + display_name = "open-webui" + icon = "/icon/openai.svg" + script = templatefile("${path.module}/run.sh", { + LOG_PATH : var.log_path, + PORT : var.port, + }) + run_on_start = true +} + +resource "coder_app" "open-webui" { + agent_id = var.agent_id + slug = "open-webui" + display_name = "Open WebUI" + url = "http://localhost:${var.port}" + icon = "/icon/openai.svg" + subdomain = true + share = var.share + order = var.order + group = var.group +} diff --git a/registry/coder-labs/modules/open-webui/run.sh b/registry/coder-labs/modules/open-webui/run.sh new file mode 100755 index 000000000..3a472ec29 --- /dev/null +++ b/registry/coder-labs/modules/open-webui/run.sh @@ -0,0 +1,93 @@ +#!/usr/bin/env sh + +# Convert templated variables to shell variables +# shellcheck disable=SC2269 +LOG_PATH=${LOG_PATH} +# shellcheck disable=SC2269 +PORT=${PORT} + +# shellcheck disable=SC2059 +printf '\033[0;1mInstalling Open WebUI...\n\n' + +# Function to check Python version +check_python_version() { + python_cmd="$1" + if command -v "$python_cmd" > /dev/null 2>&1; then + version=$("$python_cmd" --version 2>&1 | awk '{print $2}') + major=$(echo "$version" | cut -d. -f1) + minor=$(echo "$version" | cut -d. -f2) + if [ "$major" -eq 3 ] && [ "$minor" -ge 11 ]; then + echo "$python_cmd" + return 0 + fi + fi + return 1 +} + +# Find suitable Python version +PYTHON_CMD="" +for cmd in python3.13 python3.12 python3.11 python3 python; do + if result=$(check_python_version "$cmd"); then + PYTHON_CMD="$result" + echo "✅ Found suitable Python: $PYTHON_CMD ($($PYTHON_CMD --version 2>&1))" + break + fi +done + +if [ -z "$PYTHON_CMD" ]; then + echo "❌ Python 3.11 or higher is not installed" + echo "" + echo "Installing Python 3.11 from deadsnakes PPA..." + + # Check if we have sudo access + if ! command -v sudo > /dev/null 2>&1; then + echo "❌ sudo is not available. Please install Python 3.11+ manually" + exit 1 + fi + + # Install Python 3.11 + echo "📦 Adding deadsnakes PPA..." + sudo apt-get update -qq + sudo apt-get install -y software-properties-common + sudo add-apt-repository -y ppa:deadsnakes/ppa + sudo apt-get update -qq + + echo "📦 Installing Python 3.11..." + sudo apt-get install -y python3.11 python3.11-venv python3.11-dev + + PYTHON_CMD="python3.11" + echo "✅ Python 3.11 installed successfully" +fi + +# Check if pip is available +if ! "$PYTHON_CMD" -m pip --version > /dev/null 2>&1; then + echo "📦 Installing pip..." + curl -sS https://bootstrap.pypa.io/get-pip.py | "$PYTHON_CMD" +fi + +# Check if open-webui is already installed +if ! "$PYTHON_CMD" -m pip show open-webui > /dev/null 2>&1; then + echo "📦 Installing Open WebUI..." + "$PYTHON_CMD" -m pip install --user open-webui + echo "🥳 Open WebUI has been installed" +else + echo "✅ Open WebUI is already installed" +fi + +# Check if Open WebUI is already running +if pgrep -f "open-webui serve" > /dev/null; then + echo "✅ Open WebUI is already running" + exit 0 +fi + +echo "👷 Starting Open WebUI in background..." +echo "Check logs at $LOG_PATH" + +# Start Open WebUI +"$PYTHON_CMD" -m open_webui serve --host 0.0.0.0 --port "$PORT" > "$LOG_PATH" 2>&1 & + +# Wait a bit for the server to start +sleep 2 + +echo "🥳 Open WebUI is starting!" +echo "Access it at http://localhost:$PORT" From 504be92cf457ebd12d2f7e83810bd0aeb86deb95 Mon Sep 17 00:00:00 2001 From: Marcin Tojek Date: Wed, 3 Dec 2025 12:19:25 +0100 Subject: [PATCH 02/15] fixes --- .icons/openwebui.svg | 5 ++ .../coder-labs/modules/open-webui/README.md | 83 ++----------------- .../coder-labs/modules/open-webui/main.tf | 2 +- registry/coder-labs/modules/open-webui/run.sh | 6 -- 4 files changed, 11 insertions(+), 85 deletions(-) create mode 100644 .icons/openwebui.svg diff --git a/.icons/openwebui.svg b/.icons/openwebui.svg new file mode 100644 index 000000000..06f676458 --- /dev/null +++ b/.icons/openwebui.svg @@ -0,0 +1,5 @@ + + + + + diff --git a/registry/coder-labs/modules/open-webui/README.md b/registry/coder-labs/modules/open-webui/README.md index 6281560f5..4f1e8b445 100644 --- a/registry/coder-labs/modules/open-webui/README.md +++ b/registry/coder-labs/modules/open-webui/README.md @@ -1,8 +1,8 @@ --- display_name: Open WebUI description: A self-hosted AI chat interface supporting various LLM providers -icon: ../../../../.icons/openai.svg -verified: false +icon: ../../../../.icons/openwebui.svg +verified: true tags: [ai, llm, chat, web-ui, python] --- @@ -14,10 +14,10 @@ This module installs and runs Open WebUI using Python and pip within your Coder ## Prerequisites -- **Python 3.11 or higher** (automatically installed from deadsnakes PPA if not present) +- **Python 3.11 or higher** (automatically installed from [deadsnakes PPA](https://launchpad.net/~deadsnakes/+archive/ubuntu/ppa) if not present) - `pip` package manager - `sudo` access (for automatic Python installation if needed) -- Port 8080 (default) or your custom port must be available +- Port 7800 (default) or your custom port must be available **Note:** If Python 3.11+ is not found, the module will automatically: 1. Add the deadsnakes PPA repository @@ -33,77 +33,4 @@ module "open-webui" { version = "1.0.0" agent_id = coder_agent.main.id } -``` - -## Examples - -### Custom Port - -Run Open WebUI on a custom port: - -```tf -module "open-webui" { - count = data.coder_workspace.me.start_count - source = "registry.coder.com/coder-labs/open-webui/coder" - version = "1.0.0" - agent_id = coder_agent.main.id - port = 3000 -} -``` - -### Public Sharing - -Make Open WebUI accessible to authenticated Coder users: - -```tf -module "open-webui" { - count = data.coder_workspace.me.start_count - source = "registry.coder.com/coder-labs/open-webui/coder" - version = "1.0.0" - agent_id = coder_agent.main.id - share = "authenticated" -} -``` - -### Custom Log Path and Grouping - -```tf -module "open-webui" { - count = data.coder_workspace.me.start_count - source = "registry.coder.com/coder-labs/open-webui/coder" - version = "1.0.0" - agent_id = coder_agent.main.id - log_path = "/var/log/open-webui.log" - group = "AI Tools" - order = 1 -} -``` - -## Features - -- 🐍 Pure Python installation (no Docker required) -- 🔄 Automatic Python 3.11+ installation from deadsnakes PPA -- 💾 Data stored in `~/.open-webui` directory -- 🚀 Runs in background as a Python process -- 📝 Configurable logging -- 🌐 Subdomain support for clean URLs -- 🔧 Compatible with various LLM providers (OpenAI, Ollama, etc.) - -## Data Persistence - -Open WebUI data is stored in `~/.open-webui` directory in your workspace, which includes: -- User accounts -- Chat history -- Settings and configurations -- Model configurations - -## Installation Process - -The module automatically handles the installation: - -1. **Check Python Version**: Looks for Python 3.11+ (checks python3.13, python3.12, python3.11, python3, python) -2. **Install Python if Needed**: If not found, installs Python 3.11 from deadsnakes PPA -3. **Install pip**: Ensures pip is available -4. **Install Open WebUI**: Installs open-webui package via pip -5. **Start Server**: Launches Open WebUI on the specified port - +``` \ No newline at end of file diff --git a/registry/coder-labs/modules/open-webui/main.tf b/registry/coder-labs/modules/open-webui/main.tf index 3276dc644..087d788b1 100644 --- a/registry/coder-labs/modules/open-webui/main.tf +++ b/registry/coder-labs/modules/open-webui/main.tf @@ -24,7 +24,7 @@ variable "log_path" { variable "port" { type = number description = "The port to run Open WebUI on." - default = 8080 + default = 7800 } variable "share" { diff --git a/registry/coder-labs/modules/open-webui/run.sh b/registry/coder-labs/modules/open-webui/run.sh index 3a472ec29..62784b0f4 100755 --- a/registry/coder-labs/modules/open-webui/run.sh +++ b/registry/coder-labs/modules/open-webui/run.sh @@ -1,11 +1,5 @@ #!/usr/bin/env sh -# Convert templated variables to shell variables -# shellcheck disable=SC2269 -LOG_PATH=${LOG_PATH} -# shellcheck disable=SC2269 -PORT=${PORT} - # shellcheck disable=SC2059 printf '\033[0;1mInstalling Open WebUI...\n\n' From 25636524d3bd9ae12190cd70b93ac3f0d15aaf02 Mon Sep 17 00:00:00 2001 From: Marcin Tojek Date: Wed, 3 Dec 2025 12:34:01 +0100 Subject: [PATCH 03/15] fixes 2 --- registry/coder-labs/modules/open-webui/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/registry/coder-labs/modules/open-webui/README.md b/registry/coder-labs/modules/open-webui/README.md index 4f1e8b445..15bc16eaf 100644 --- a/registry/coder-labs/modules/open-webui/README.md +++ b/registry/coder-labs/modules/open-webui/README.md @@ -30,7 +30,7 @@ This module installs and runs Open WebUI using Python and pip within your Coder module "open-webui" { count = data.coder_workspace.me.start_count source = "registry.coder.com/coder-labs/open-webui/coder" - version = "1.0.0" + version = "0.9.0" agent_id = coder_agent.main.id } ``` \ No newline at end of file From 6e94ecc165e177406834f68b5590ee85f660d644 Mon Sep 17 00:00:00 2001 From: Marcin Tojek Date: Wed, 3 Dec 2025 11:42:17 +0000 Subject: [PATCH 04/15] fix: use venv instead of pip install --user - Remove automatic Python installation - user must have Python 3.11+ in image - Use virtual environment (~/.open-webui-venv) to avoid externally-managed-environment error - Add set -e to fail script on errors - Update README with installation instructions --- .../coder-labs/modules/open-webui/README.md | 15 +++--- registry/coder-labs/modules/open-webui/run.sh | 47 ++++++++----------- 2 files changed, 27 insertions(+), 35 deletions(-) diff --git a/registry/coder-labs/modules/open-webui/README.md b/registry/coder-labs/modules/open-webui/README.md index 15bc16eaf..3f468fa24 100644 --- a/registry/coder-labs/modules/open-webui/README.md +++ b/registry/coder-labs/modules/open-webui/README.md @@ -14,15 +14,16 @@ This module installs and runs Open WebUI using Python and pip within your Coder ## Prerequisites -- **Python 3.11 or higher** (automatically installed from [deadsnakes PPA](https://launchpad.net/~deadsnakes/+archive/ubuntu/ppa) if not present) -- `pip` package manager -- `sudo` access (for automatic Python installation if needed) +- **Python 3.11 or higher** must be installed in your image (with `venv` module) - Port 7800 (default) or your custom port must be available -**Note:** If Python 3.11+ is not found, the module will automatically: -1. Add the deadsnakes PPA repository -2. Install Python 3.11 with venv and dev packages -3. Install pip if not available +For Ubuntu/Debian, you can install Python 3.11 from [deadsnakes PPA](https://launchpad.net/~deadsnakes/+archive/ubuntu/ppa): + +```shell +sudo add-apt-repository -y ppa:deadsnakes/ppa +sudo apt-get update +sudo apt-get install -y python3.11 python3.11-venv +``` ## Basic Usage diff --git a/registry/coder-labs/modules/open-webui/run.sh b/registry/coder-labs/modules/open-webui/run.sh index 62784b0f4..d9609e392 100755 --- a/registry/coder-labs/modules/open-webui/run.sh +++ b/registry/coder-labs/modules/open-webui/run.sh @@ -1,4 +1,5 @@ #!/usr/bin/env sh +set -e # shellcheck disable=SC2059 printf '\033[0;1mInstalling Open WebUI...\n\n' @@ -29,40 +30,30 @@ for cmd in python3.13 python3.12 python3.11 python3 python; do done if [ -z "$PYTHON_CMD" ]; then - echo "❌ Python 3.11 or higher is not installed" + echo "❌ Python 3.11 or higher is required but not found." echo "" - echo "Installing Python 3.11 from deadsnakes PPA..." - - # Check if we have sudo access - if ! command -v sudo > /dev/null 2>&1; then - echo "❌ sudo is not available. Please install Python 3.11+ manually" - exit 1 - fi - - # Install Python 3.11 - echo "📦 Adding deadsnakes PPA..." - sudo apt-get update -qq - sudo apt-get install -y software-properties-common - sudo add-apt-repository -y ppa:deadsnakes/ppa - sudo apt-get update -qq - - echo "📦 Installing Python 3.11..." - sudo apt-get install -y python3.11 python3.11-venv python3.11-dev - - PYTHON_CMD="python3.11" - echo "✅ Python 3.11 installed successfully" + echo "Please install Python 3.11+ in your image. For example on Ubuntu/Debian:" + echo " sudo add-apt-repository -y ppa:deadsnakes/ppa" + echo " sudo apt-get update" + echo " sudo apt-get install -y python3.11 python3.11-venv" + exit 1 fi -# Check if pip is available -if ! "$PYTHON_CMD" -m pip --version > /dev/null 2>&1; then - echo "📦 Installing pip..." - curl -sS https://bootstrap.pypa.io/get-pip.py | "$PYTHON_CMD" +# Set up virtual environment +VENV_DIR="$HOME/.open-webui-venv" +if [ ! -d "$VENV_DIR" ]; then + echo "📦 Creating virtual environment..." + "$PYTHON_CMD" -m venv "$VENV_DIR" fi +# Activate virtual environment +# shellcheck disable=SC1091 +. "$VENV_DIR/bin/activate" + # Check if open-webui is already installed -if ! "$PYTHON_CMD" -m pip show open-webui > /dev/null 2>&1; then +if ! pip show open-webui > /dev/null 2>&1; then echo "📦 Installing Open WebUI..." - "$PYTHON_CMD" -m pip install --user open-webui + pip install open-webui echo "🥳 Open WebUI has been installed" else echo "✅ Open WebUI is already installed" @@ -78,7 +69,7 @@ echo "👷 Starting Open WebUI in background..." echo "Check logs at $LOG_PATH" # Start Open WebUI -"$PYTHON_CMD" -m open_webui serve --host 0.0.0.0 --port "$PORT" > "$LOG_PATH" 2>&1 & +open-webui serve --host 0.0.0.0 --port "$PORT" > "$LOG_PATH" 2>&1 & # Wait a bit for the server to start sleep 2 From d03588356e7c49ddd80c15ee1c8e77084eba433a Mon Sep 17 00:00:00 2001 From: Marcin Tojek Date: Wed, 3 Dec 2025 13:22:04 +0000 Subject: [PATCH 05/15] fix: remove running process check --- registry/coder-labs/modules/open-webui/run.sh | 6 ------ 1 file changed, 6 deletions(-) diff --git a/registry/coder-labs/modules/open-webui/run.sh b/registry/coder-labs/modules/open-webui/run.sh index d9609e392..4e41f1d3a 100755 --- a/registry/coder-labs/modules/open-webui/run.sh +++ b/registry/coder-labs/modules/open-webui/run.sh @@ -59,12 +59,6 @@ else echo "✅ Open WebUI is already installed" fi -# Check if Open WebUI is already running -if pgrep -f "open-webui serve" > /dev/null; then - echo "✅ Open WebUI is already running" - exit 0 -fi - echo "👷 Starting Open WebUI in background..." echo "Check logs at $LOG_PATH" From d6a18d8419287f9d96ce5f2c2d55ccf74e03299c Mon Sep 17 00:00:00 2001 From: Marcin Tojek Date: Wed, 3 Dec 2025 13:52:40 +0000 Subject: [PATCH 06/15] fix: restore LOG_PATH and PORT variable assignments from templatefile --- registry/coder-labs/modules/open-webui/run.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/registry/coder-labs/modules/open-webui/run.sh b/registry/coder-labs/modules/open-webui/run.sh index 4e41f1d3a..6220e0ca3 100755 --- a/registry/coder-labs/modules/open-webui/run.sh +++ b/registry/coder-labs/modules/open-webui/run.sh @@ -1,6 +1,9 @@ #!/usr/bin/env sh set -e +LOG_PATH=${LOG_PATH} +PORT=${PORT} + # shellcheck disable=SC2059 printf '\033[0;1mInstalling Open WebUI...\n\n' From 5335c8549522180545c7ab35da8e5736f31ecc82 Mon Sep 17 00:00:00 2001 From: Marcin Tojek Date: Wed, 3 Dec 2025 14:55:09 +0100 Subject: [PATCH 07/15] fixes --- registry/coder-labs/modules/open-webui/run.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/registry/coder-labs/modules/open-webui/run.sh b/registry/coder-labs/modules/open-webui/run.sh index 6220e0ca3..25a3e6c2c 100755 --- a/registry/coder-labs/modules/open-webui/run.sh +++ b/registry/coder-labs/modules/open-webui/run.sh @@ -1,8 +1,8 @@ #!/usr/bin/env sh set -e -LOG_PATH=${LOG_PATH} -PORT=${PORT} +LOG_PATH=$${LOG_PATH} +PORT=$${PORT} # shellcheck disable=SC2059 printf '\033[0;1mInstalling Open WebUI...\n\n' From abe133afe817fe065036ba556f7dbcd2378ac005 Mon Sep 17 00:00:00 2001 From: Marcin Tojek Date: Wed, 3 Dec 2025 14:56:35 +0100 Subject: [PATCH 08/15] fixes --- registry/coder-labs/modules/open-webui/run.sh | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/registry/coder-labs/modules/open-webui/run.sh b/registry/coder-labs/modules/open-webui/run.sh index 25a3e6c2c..a761b209c 100755 --- a/registry/coder-labs/modules/open-webui/run.sh +++ b/registry/coder-labs/modules/open-webui/run.sh @@ -1,9 +1,6 @@ #!/usr/bin/env sh set -e -LOG_PATH=$${LOG_PATH} -PORT=$${PORT} - # shellcheck disable=SC2059 printf '\033[0;1mInstalling Open WebUI...\n\n' @@ -63,13 +60,13 @@ else fi echo "👷 Starting Open WebUI in background..." -echo "Check logs at $LOG_PATH" +echo "Check logs at $${LOG_PATH}" # Start Open WebUI -open-webui serve --host 0.0.0.0 --port "$PORT" > "$LOG_PATH" 2>&1 & +open-webui serve --host 0.0.0.0 --port "$${PORT}" > "$${LOG_PATH}" 2>&1 & # Wait a bit for the server to start sleep 2 echo "🥳 Open WebUI is starting!" -echo "Access it at http://localhost:$PORT" +echo "Access it at http://localhost:$${PORT}" From 520a2947e1b0019a9777d860eed96b409ba52c47 Mon Sep 17 00:00:00 2001 From: Marcin Tojek Date: Wed, 3 Dec 2025 15:01:42 +0100 Subject: [PATCH 09/15] Revert "fixes" This reverts commit abe133afe817fe065036ba556f7dbcd2378ac005. --- registry/coder-labs/modules/open-webui/run.sh | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/registry/coder-labs/modules/open-webui/run.sh b/registry/coder-labs/modules/open-webui/run.sh index a761b209c..25a3e6c2c 100755 --- a/registry/coder-labs/modules/open-webui/run.sh +++ b/registry/coder-labs/modules/open-webui/run.sh @@ -1,6 +1,9 @@ #!/usr/bin/env sh set -e +LOG_PATH=$${LOG_PATH} +PORT=$${PORT} + # shellcheck disable=SC2059 printf '\033[0;1mInstalling Open WebUI...\n\n' @@ -60,13 +63,13 @@ else fi echo "👷 Starting Open WebUI in background..." -echo "Check logs at $${LOG_PATH}" +echo "Check logs at $LOG_PATH" # Start Open WebUI -open-webui serve --host 0.0.0.0 --port "$${PORT}" > "$${LOG_PATH}" 2>&1 & +open-webui serve --host 0.0.0.0 --port "$PORT" > "$LOG_PATH" 2>&1 & # Wait a bit for the server to start sleep 2 echo "🥳 Open WebUI is starting!" -echo "Access it at http://localhost:$${PORT}" +echo "Access it at http://localhost:$PORT" From 019d735fddc25850c1e6a134341abe4a3518715c Mon Sep 17 00:00:00 2001 From: Marcin Tojek Date: Wed, 3 Dec 2025 14:07:06 +0000 Subject: [PATCH 10/15] fix: rename variables to HTTP_SERVER_PORT and HTTP_SERVER_LOG_PATH --- registry/coder-labs/modules/open-webui/main.tf | 4 ++-- registry/coder-labs/modules/open-webui/run.sh | 18 +++++------------- 2 files changed, 7 insertions(+), 15 deletions(-) diff --git a/registry/coder-labs/modules/open-webui/main.tf b/registry/coder-labs/modules/open-webui/main.tf index 087d788b1..45667770f 100644 --- a/registry/coder-labs/modules/open-webui/main.tf +++ b/registry/coder-labs/modules/open-webui/main.tf @@ -53,8 +53,8 @@ resource "coder_script" "open-webui" { display_name = "open-webui" icon = "/icon/openai.svg" script = templatefile("${path.module}/run.sh", { - LOG_PATH : var.log_path, - PORT : var.port, + HTTP_SERVER_LOG_PATH : var.log_path, + HTTP_SERVER_PORT : var.port, }) run_on_start = true } diff --git a/registry/coder-labs/modules/open-webui/run.sh b/registry/coder-labs/modules/open-webui/run.sh index 25a3e6c2c..2b942ba9d 100755 --- a/registry/coder-labs/modules/open-webui/run.sh +++ b/registry/coder-labs/modules/open-webui/run.sh @@ -1,13 +1,12 @@ #!/usr/bin/env sh set -e -LOG_PATH=$${LOG_PATH} -PORT=$${PORT} +HTTP_SERVER_LOG_PATH=$${HTTP_SERVER_LOG_PATH} +HTTP_SERVER_PORT=$${HTTP_SERVER_PORT} # shellcheck disable=SC2059 printf '\033[0;1mInstalling Open WebUI...\n\n' -# Function to check Python version check_python_version() { python_cmd="$1" if command -v "$python_cmd" > /dev/null 2>&1; then @@ -22,7 +21,6 @@ check_python_version() { return 1 } -# Find suitable Python version PYTHON_CMD="" for cmd in python3.13 python3.12 python3.11 python3 python; do if result=$(check_python_version "$cmd"); then @@ -42,18 +40,15 @@ if [ -z "$PYTHON_CMD" ]; then exit 1 fi -# Set up virtual environment VENV_DIR="$HOME/.open-webui-venv" if [ ! -d "$VENV_DIR" ]; then echo "📦 Creating virtual environment..." "$PYTHON_CMD" -m venv "$VENV_DIR" fi -# Activate virtual environment # shellcheck disable=SC1091 . "$VENV_DIR/bin/activate" -# Check if open-webui is already installed if ! pip show open-webui > /dev/null 2>&1; then echo "📦 Installing Open WebUI..." pip install open-webui @@ -63,13 +58,10 @@ else fi echo "👷 Starting Open WebUI in background..." -echo "Check logs at $LOG_PATH" +echo "Check logs at $HTTP_SERVER_LOG_PATH" -# Start Open WebUI -open-webui serve --host 0.0.0.0 --port "$PORT" > "$LOG_PATH" 2>&1 & +open-webui serve --host 0.0.0.0 --port "$HTTP_SERVER_PORT" > "$HTTP_SERVER_LOG_PATH" 2>&1 & -# Wait a bit for the server to start sleep 2 -echo "🥳 Open WebUI is starting!" -echo "Access it at http://localhost:$PORT" +echo "🥳 Open WebUI is ready. HTTP server is listening on port $HTTP_SERVER_PORT" From 82c86db196285fc71b3cd946e1c45ffa02ee1871 Mon Sep 17 00:00:00 2001 From: Marcin Tojek Date: Wed, 3 Dec 2025 15:12:00 +0100 Subject: [PATCH 11/15] test --- registry/coder-labs/modules/open-webui/main.tf | 4 ++-- registry/coder-labs/modules/open-webui/run.sh | 10 +++++++--- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/registry/coder-labs/modules/open-webui/main.tf b/registry/coder-labs/modules/open-webui/main.tf index 45667770f..7ebd772a7 100644 --- a/registry/coder-labs/modules/open-webui/main.tf +++ b/registry/coder-labs/modules/open-webui/main.tf @@ -51,7 +51,7 @@ variable "group" { resource "coder_script" "open-webui" { agent_id = var.agent_id display_name = "open-webui" - icon = "/icon/openai.svg" + icon = "/icon/openwebui.svg" script = templatefile("${path.module}/run.sh", { HTTP_SERVER_LOG_PATH : var.log_path, HTTP_SERVER_PORT : var.port, @@ -64,7 +64,7 @@ resource "coder_app" "open-webui" { slug = "open-webui" display_name = "Open WebUI" url = "http://localhost:${var.port}" - icon = "/icon/openai.svg" + icon = "/icon/openwebui.svg" subdomain = true share = var.share order = var.order diff --git a/registry/coder-labs/modules/open-webui/run.sh b/registry/coder-labs/modules/open-webui/run.sh index 2b942ba9d..91ac046ab 100755 --- a/registry/coder-labs/modules/open-webui/run.sh +++ b/registry/coder-labs/modules/open-webui/run.sh @@ -1,8 +1,12 @@ #!/usr/bin/env sh -set -e -HTTP_SERVER_LOG_PATH=$${HTTP_SERVER_LOG_PATH} -HTTP_SERVER_PORT=$${HTTP_SERVER_PORT} +set -eu + +echo "1. $${HTTP_SERVER_LOG_PATH}" +echo "2. ${HTTP_SERVER_LOG_PATH}" + +HTTP_SERVER_LOG_PATH=${HTTP_SERVER_LOG_PATH} +HTTP_SERVER_PORT=${HTTP_SERVER_PORT} # shellcheck disable=SC2059 printf '\033[0;1mInstalling Open WebUI...\n\n' From 8fa6be0edfa86d0235b3fbf7b8a306adc61eccbc Mon Sep 17 00:00:00 2001 From: Marcin Tojek Date: Wed, 3 Dec 2025 15:14:04 +0100 Subject: [PATCH 12/15] test --- registry/coder-labs/modules/open-webui/main.tf | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/registry/coder-labs/modules/open-webui/main.tf b/registry/coder-labs/modules/open-webui/main.tf index 7ebd772a7..6729bc447 100644 --- a/registry/coder-labs/modules/open-webui/main.tf +++ b/registry/coder-labs/modules/open-webui/main.tf @@ -15,13 +15,13 @@ variable "agent_id" { description = "The ID of a Coder agent." } -variable "log_path" { +variable "http_server_log_path" { type = string description = "The path to log Open WebUI to." default = "/tmp/open-webui.log" } -variable "port" { +variable "http_server_port" { type = number description = "The port to run Open WebUI on." default = 7800 @@ -53,8 +53,8 @@ resource "coder_script" "open-webui" { display_name = "open-webui" icon = "/icon/openwebui.svg" script = templatefile("${path.module}/run.sh", { - HTTP_SERVER_LOG_PATH : var.log_path, - HTTP_SERVER_PORT : var.port, + HTTP_SERVER_LOG_PATH : var.http_server_log_path, + HTTP_SERVER_PORT : var.http_server_port, }) run_on_start = true } @@ -63,7 +63,7 @@ resource "coder_app" "open-webui" { agent_id = var.agent_id slug = "open-webui" display_name = "Open WebUI" - url = "http://localhost:${var.port}" + url = "http://localhost:${var.http_server_port}" icon = "/icon/openwebui.svg" subdomain = true share = var.share From 1be384252efcbd996facac8bdd74dde9426161c0 Mon Sep 17 00:00:00 2001 From: Marcin Tojek Date: Wed, 3 Dec 2025 15:26:01 +0100 Subject: [PATCH 13/15] test --- registry/coder-labs/modules/open-webui/run.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/registry/coder-labs/modules/open-webui/run.sh b/registry/coder-labs/modules/open-webui/run.sh index 91ac046ab..74605c053 100755 --- a/registry/coder-labs/modules/open-webui/run.sh +++ b/registry/coder-labs/modules/open-webui/run.sh @@ -2,8 +2,8 @@ set -eu -echo "1. $${HTTP_SERVER_LOG_PATH}" -echo "2. ${HTTP_SERVER_LOG_PATH}" +echo "1. ${HTTP_SERVER_LOG_PATH}" +echo "2. $${HTTP_SERVER_LOG_PATH}" HTTP_SERVER_LOG_PATH=${HTTP_SERVER_LOG_PATH} HTTP_SERVER_PORT=${HTTP_SERVER_PORT} From e07e2896980e491aeca9a82a850357ddaf8c8329 Mon Sep 17 00:00:00 2001 From: Marcin Tojek Date: Wed, 3 Dec 2025 15:28:23 +0100 Subject: [PATCH 14/15] test --- registry/coder-labs/modules/open-webui/run.sh | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/registry/coder-labs/modules/open-webui/run.sh b/registry/coder-labs/modules/open-webui/run.sh index 74605c053..caec4a97a 100755 --- a/registry/coder-labs/modules/open-webui/run.sh +++ b/registry/coder-labs/modules/open-webui/run.sh @@ -2,11 +2,8 @@ set -eu -echo "1. ${HTTP_SERVER_LOG_PATH}" -echo "2. $${HTTP_SERVER_LOG_PATH}" - -HTTP_SERVER_LOG_PATH=${HTTP_SERVER_LOG_PATH} -HTTP_SERVER_PORT=${HTTP_SERVER_PORT} +echo "HTTP_SERVER_LOG_PATH = ${HTTP_SERVER_LOG_PATH}" +echo "HTTP_SERVER_PORT = ${HTTP_SERVER_PORT}" # shellcheck disable=SC2059 printf '\033[0;1mInstalling Open WebUI...\n\n' @@ -50,9 +47,15 @@ if [ ! -d "$VENV_DIR" ]; then "$PYTHON_CMD" -m venv "$VENV_DIR" fi +echo "2. HTTP_SERVER_LOG_PATH = ${HTTP_SERVER_LOG_PATH}" +echo "2. HTTP_SERVER_PORT = ${HTTP_SERVER_PORT}" + # shellcheck disable=SC1091 . "$VENV_DIR/bin/activate" +echo "3. HTTP_SERVER_LOG_PATH = ${HTTP_SERVER_LOG_PATH}" +echo "3. HTTP_SERVER_PORT = ${HTTP_SERVER_PORT}" + if ! pip show open-webui > /dev/null 2>&1; then echo "📦 Installing Open WebUI..." pip install open-webui @@ -62,10 +65,10 @@ else fi echo "👷 Starting Open WebUI in background..." -echo "Check logs at $HTTP_SERVER_LOG_PATH" +echo "Check logs at ${HTTP_SERVER_LOG_PATH}" -open-webui serve --host 0.0.0.0 --port "$HTTP_SERVER_PORT" > "$HTTP_SERVER_LOG_PATH" 2>&1 & +open-webui serve --host 0.0.0.0 --port "${HTTP_SERVER_PORT}" > "${HTTP_SERVER_LOG_PATH}" 2>&1 & sleep 2 -echo "🥳 Open WebUI is ready. HTTP server is listening on port $HTTP_SERVER_PORT" +echo "🥳 Open WebUI is ready. HTTP server is listening on port ${HTTP_SERVER_PORT}" From 9525e2d4d1a1dbd1b6cba94d1afb353387cd32d7 Mon Sep 17 00:00:00 2001 From: Marcin Tojek Date: Wed, 3 Dec 2025 15:49:43 +0100 Subject: [PATCH 15/15] cleanup --- registry/coder-labs/modules/open-webui/run.sh | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/registry/coder-labs/modules/open-webui/run.sh b/registry/coder-labs/modules/open-webui/run.sh index caec4a97a..aef089392 100755 --- a/registry/coder-labs/modules/open-webui/run.sh +++ b/registry/coder-labs/modules/open-webui/run.sh @@ -2,10 +2,6 @@ set -eu -echo "HTTP_SERVER_LOG_PATH = ${HTTP_SERVER_LOG_PATH}" -echo "HTTP_SERVER_PORT = ${HTTP_SERVER_PORT}" - -# shellcheck disable=SC2059 printf '\033[0;1mInstalling Open WebUI...\n\n' check_python_version() { @@ -46,16 +42,8 @@ if [ ! -d "$VENV_DIR" ]; then echo "📦 Creating virtual environment..." "$PYTHON_CMD" -m venv "$VENV_DIR" fi - -echo "2. HTTP_SERVER_LOG_PATH = ${HTTP_SERVER_LOG_PATH}" -echo "2. HTTP_SERVER_PORT = ${HTTP_SERVER_PORT}" - -# shellcheck disable=SC1091 . "$VENV_DIR/bin/activate" -echo "3. HTTP_SERVER_LOG_PATH = ${HTTP_SERVER_LOG_PATH}" -echo "3. HTTP_SERVER_PORT = ${HTTP_SERVER_PORT}" - if ! pip show open-webui > /dev/null 2>&1; then echo "📦 Installing Open WebUI..." pip install open-webui @@ -69,6 +57,4 @@ echo "Check logs at ${HTTP_SERVER_LOG_PATH}" open-webui serve --host 0.0.0.0 --port "${HTTP_SERVER_PORT}" > "${HTTP_SERVER_LOG_PATH}" 2>&1 & -sleep 2 - echo "🥳 Open WebUI is ready. HTTP server is listening on port ${HTTP_SERVER_PORT}"