[PR #255] [MERGED] feat(open-webui): optional command and args overrides for open-webui and copy-app-data containers #285

Closed
opened 2026-02-15 19:17:13 -05:00 by yindo · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/open-webui/helm-charts/pull/255
Author: @bdriggersTorch
Created: 6/12/2025
Status: Merged
Merged: 6/19/2025
Merged by: @westbrook-ai

Base: mainHead: openwebui-command-override


📝 Commits (3)

  • ce05f9e feat(open-webui): add optional command and args overrides for open-webui container
  • fab19a9 feat(open-webui): add optional command args overrides for open-webui copyAppData init container
  • 5dc11a8 Merge remote-tracking branch 'upstream/main' into openwebui-command-override

📊 Changes

4 files changed (+30 additions, -3 deletions)

View changed files

📝 charts/open-webui/Chart.yaml (+1 -1)
📝 charts/open-webui/README.md (+5 -1)
📝 charts/open-webui/templates/workload-manager.yaml (+14 -1)
📝 charts/open-webui/values.yaml (+10 -0)

📄 Description

Added optional command and args overrides for the open-webui container and copy-app-data init container for use with custom images, etc.

Tested with minikube using the below values.yaml and custom open-webui image:

image:
  repository: open-webui-python
  tag: custom

copyAppData:
  command: ['sh', '-c', 'cp -R -n /usr/local/lib/python3.12/site-packages/open_webui/data/* /tmp/app-data/']

command:
  - python
args:
  - /app/scripts/open-webui-tls.py

volumeMounts:
  container:
    - name: open-webui-tls-entrypoint
      mountPath: /app/scripts
      readOnly: true
    - name: open-webui-tls-secret
      mountPath: /opt/ssl/open-webui
      readOnly: true
volumes:
  - name: open-webui-tls-entrypoint
    configMap:
      name: open-webui-tls-entrypoint
  - name: open-webui-tls-secret
    secret:
      secretName: openwebui-tls-secret

extraResources:         
  # Custom entrypoint script for Open WebUI to launch Open WebUI with TLS enabled. 
  - apiVersion: v1
    kind: ConfigMap
    metadata:
      name: open-webui-tls-entrypoint
    data:
      open-webui-tls.py: |
        import base64
        import os
        import random
        from pathlib import Path
        import uvicorn
        import typer

        KEY_FILE = Path.cwd() / ".webui_secret_key"

        os.environ["FROM_INIT_PY"] = "true"
        if os.getenv("WEBUI_SECRET_KEY") is None:
            typer.echo(
                "Loading WEBUI_SECRET_KEY from file, not provided as an environment variable."
            )
            if not KEY_FILE.exists():
                typer.echo(f"Generating a new secret key and saving it to {KEY_FILE}")
                KEY_FILE.write_bytes(base64.b64encode(random.randbytes(12)))
            typer.echo(f"Loading WEBUI_SECRET_KEY from {KEY_FILE}")
            os.environ["WEBUI_SECRET_KEY"] = KEY_FILE.read_text()

        if os.getenv("USE_CUDA_DOCKER", "false") == "true":
            typer.echo(
                "CUDA is enabled, appending LD_LIBRARY_PATH to include torch/cudnn & cublas libraries."
            )
            LD_LIBRARY_PATH = os.getenv("LD_LIBRARY_PATH", "").split(":")
            os.environ["LD_LIBRARY_PATH"] = ":".join(
                LD_LIBRARY_PATH
                + [
                    "/usr/local/lib/python3.11/site-packages/torch/lib",
                    "/usr/local/lib/python3.11/site-packages/nvidia/cudnn/lib",
                ]
            )
            try:
                import torch

                assert torch.cuda.is_available(), "CUDA not available"
                typer.echo("CUDA seems to be working")
            except Exception as e:
                typer.echo(
                    "Error when testing CUDA but USE_CUDA_DOCKER is true. "
                    "Resetting USE_CUDA_DOCKER to false and removing "
                    f"LD_LIBRARY_PATH modifications: {e}"
                )
                os.environ["USE_CUDA_DOCKER"] = "false"
                os.environ["LD_LIBRARY_PATH"] = ":".join(LD_LIBRARY_PATH)

        import open_webui.main  # we need set environment variables before importing main
        from open_webui.env import UVICORN_WORKERS  # Import the workers setting

        uvicorn.run(
            open_webui.main.app,
            host="0.0.0.0",
            port="8080",
            forwarded_allow_ips="*",
            workers=UVICORN_WORKERS,
            ssl_keyfile="/opt/ssl/open-webui/tls.key",
            ssl_certfile="/opt/ssl/open-webui/tls.crt",
        )
FROM python:3.12-slim

RUN apt-get update && \
    apt-get install -y \
    curl \
    git \
    build-essential \
    libssl-dev \
    libffi-dev \
    libxml2-dev \
    libxmlsec1-dev \
    libxslt1-dev \
    zlib1g-dev \
    libjpeg-dev \
    liblcms2-dev \
    libblas-dev \
    liblapack-dev \
    gfortran \
    && rm -rf /var/lib/apt/lists/*

WORKDIR /app

RUN pip install --no-cache-dir open-webui==0.6.14

EXPOSE 8080

ENTRYPOINT ["open-webui", "serve"]

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/open-webui/helm-charts/pull/255 **Author:** [@bdriggersTorch](https://github.com/bdriggersTorch) **Created:** 6/12/2025 **Status:** ✅ Merged **Merged:** 6/19/2025 **Merged by:** [@westbrook-ai](https://github.com/westbrook-ai) **Base:** `main` ← **Head:** `openwebui-command-override` --- ### 📝 Commits (3) - [`ce05f9e`](https://github.com/open-webui/helm-charts/commit/ce05f9ee3854bf229318b403e84c884552ab73c1) feat(open-webui): add optional command and args overrides for open-webui container - [`fab19a9`](https://github.com/open-webui/helm-charts/commit/fab19a9666b1a33e48d095d352d5694deb596c19) feat(open-webui): add optional command args overrides for open-webui copyAppData init container - [`5dc11a8`](https://github.com/open-webui/helm-charts/commit/5dc11a8179c7eff051e6b5f6f84a938f967a3d26) Merge remote-tracking branch 'upstream/main' into openwebui-command-override ### 📊 Changes **4 files changed** (+30 additions, -3 deletions) <details> <summary>View changed files</summary> 📝 `charts/open-webui/Chart.yaml` (+1 -1) 📝 `charts/open-webui/README.md` (+5 -1) 📝 `charts/open-webui/templates/workload-manager.yaml` (+14 -1) 📝 `charts/open-webui/values.yaml` (+10 -0) </details> ### 📄 Description Added optional `command` and `args` overrides for the open-webui container and copy-app-data init container for use with custom images, etc. Tested with minikube using the below `values.yaml` and custom open-webui image: ```yaml image: repository: open-webui-python tag: custom copyAppData: command: ['sh', '-c', 'cp -R -n /usr/local/lib/python3.12/site-packages/open_webui/data/* /tmp/app-data/'] command: - python args: - /app/scripts/open-webui-tls.py volumeMounts: container: - name: open-webui-tls-entrypoint mountPath: /app/scripts readOnly: true - name: open-webui-tls-secret mountPath: /opt/ssl/open-webui readOnly: true volumes: - name: open-webui-tls-entrypoint configMap: name: open-webui-tls-entrypoint - name: open-webui-tls-secret secret: secretName: openwebui-tls-secret extraResources: # Custom entrypoint script for Open WebUI to launch Open WebUI with TLS enabled. - apiVersion: v1 kind: ConfigMap metadata: name: open-webui-tls-entrypoint data: open-webui-tls.py: | import base64 import os import random from pathlib import Path import uvicorn import typer KEY_FILE = Path.cwd() / ".webui_secret_key" os.environ["FROM_INIT_PY"] = "true" if os.getenv("WEBUI_SECRET_KEY") is None: typer.echo( "Loading WEBUI_SECRET_KEY from file, not provided as an environment variable." ) if not KEY_FILE.exists(): typer.echo(f"Generating a new secret key and saving it to {KEY_FILE}") KEY_FILE.write_bytes(base64.b64encode(random.randbytes(12))) typer.echo(f"Loading WEBUI_SECRET_KEY from {KEY_FILE}") os.environ["WEBUI_SECRET_KEY"] = KEY_FILE.read_text() if os.getenv("USE_CUDA_DOCKER", "false") == "true": typer.echo( "CUDA is enabled, appending LD_LIBRARY_PATH to include torch/cudnn & cublas libraries." ) LD_LIBRARY_PATH = os.getenv("LD_LIBRARY_PATH", "").split(":") os.environ["LD_LIBRARY_PATH"] = ":".join( LD_LIBRARY_PATH + [ "/usr/local/lib/python3.11/site-packages/torch/lib", "/usr/local/lib/python3.11/site-packages/nvidia/cudnn/lib", ] ) try: import torch assert torch.cuda.is_available(), "CUDA not available" typer.echo("CUDA seems to be working") except Exception as e: typer.echo( "Error when testing CUDA but USE_CUDA_DOCKER is true. " "Resetting USE_CUDA_DOCKER to false and removing " f"LD_LIBRARY_PATH modifications: {e}" ) os.environ["USE_CUDA_DOCKER"] = "false" os.environ["LD_LIBRARY_PATH"] = ":".join(LD_LIBRARY_PATH) import open_webui.main # we need set environment variables before importing main from open_webui.env import UVICORN_WORKERS # Import the workers setting uvicorn.run( open_webui.main.app, host="0.0.0.0", port="8080", forwarded_allow_ips="*", workers=UVICORN_WORKERS, ssl_keyfile="/opt/ssl/open-webui/tls.key", ssl_certfile="/opt/ssl/open-webui/tls.crt", ) ``` ```Dockerfile FROM python:3.12-slim RUN apt-get update && \ apt-get install -y \ curl \ git \ build-essential \ libssl-dev \ libffi-dev \ libxml2-dev \ libxmlsec1-dev \ libxslt1-dev \ zlib1g-dev \ libjpeg-dev \ liblcms2-dev \ libblas-dev \ liblapack-dev \ gfortran \ && rm -rf /var/lib/apt/lists/* WORKDIR /app RUN pip install --no-cache-dir open-webui==0.6.14 EXPOSE 8080 ENTRYPOINT ["open-webui", "serve"] ``` --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
yindo added the pull-request label 2026-02-15 19:17:13 -05:00
yindo closed this issue 2026-02-15 19:17:13 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: open-webui/helm-charts#285