Skip to content

Commit 80a796b

Browse files
Custom open-webui Docker image; configuring MCP server directly inside open-webui DB; adding open-webui volume
1 parent 30408a7 commit 80a796b

4 files changed

Lines changed: 181 additions & 14 deletions

File tree

.github/workflows/docker.yml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: Build & Push Proxy
2+
3+
on:
4+
push:
5+
branches: [ "main" ]
6+
release:
7+
types: [published]
8+
workflow_dispatch:
9+
10+
permissions:
11+
contents: read
12+
packages: write
13+
14+
env:
15+
IMAGE_NAME: ghcr.io/lsfusion/open-webui
16+
17+
jobs:
18+
build:
19+
runs-on: ubuntu-latest
20+
steps:
21+
- name: Checkout
22+
uses: actions/checkout@v4
23+
24+
- name: Login to GHCR
25+
uses: docker/login-action@v3
26+
with:
27+
registry: ghcr.io
28+
username: ${{ github.actor }}
29+
password: ${{ secrets.GITHUB_TOKEN }}
30+
31+
- name: Build and push
32+
uses: docker/build-push-action@v6
33+
with:
34+
context: ./open-webui
35+
push: true
36+
tags: |
37+
${{ env.IMAGE_NAME }}:latest
38+
${{ env.IMAGE_NAME }}:${{ github.sha }}

docker-compose.yml

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -39,29 +39,33 @@ services:
3939
- mcp
4040
restart: unless-stopped
4141

42-
mcp-bridge:
43-
image: ghcr.io/secretiveshell/mcp-bridge/mcp-bridge:0.5.1
44-
volumes:
45-
- ./mcp-bridge/config.json:/mcp_bridge/config.json:ro
46-
environment:
47-
MCP_BRIDGE__CONFIG__FILE: /mcp_bridge/config.json
48-
depends_on:
49-
- proxy-mcp
50-
- mcp
51-
expose:
52-
- "9090"
53-
restart: unless-stopped
42+
# mcp-bridge:
43+
# image: ghcr.io/secretiveshell/mcp-bridge/mcp-bridge:0.5.1
44+
# volumes:
45+
# - ./mcp-bridge/config.json:/mcp_bridge/config.json:ro
46+
# environment:
47+
# MCP_BRIDGE__CONFIG__FILE: /mcp_bridge/config.json
48+
# depends_on:
49+
# - proxy-mcp
50+
# - mcp
51+
# expose:
52+
# - "9090"
53+
# restart: unless-stopped
5454

5555
openwebui:
56-
image: ghcr.io/open-webui/open-webui:latest
57-
56+
image: ghcr.io/lsfusion/open-webui:latest
57+
volumes:
58+
- ./open-webui:/app/backend/data
5859
environment:
5960
- OPENAI_API_BASE_URL=https://${DOMAIN}/${OPENAI_PATH}/mcp/v1
6061
# image: lobehub/lobe-chat:latest
6162
# environment:
6263
# - OPENAI_PROXY_URL=https://${DOMAIN}/${OPENAI_PATH}/v1
6364
# - OPENAI_API_BASE_URL=https://${DOMAIN}/${OPENAI_PATH}/v1
6465
- DEFAULT_MODEL=${MODEL_ID}
66+
- MCP_URL=http://proxy-mcp:8000
67+
- MCP_ID=lsf-mcp
68+
- MCP_NAME=lsFusion MCP
6569
expose:
6670
# - "3210"
6771
- "8080"

open-webui/Dockerfile

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
FROM ghcr.io/open-webui/open-webui:latest
2+
3+
COPY entrypoint.sh /entrypoint.sh
4+
RUN chmod +x /entrypoint.sh
5+
6+
ENTRYPOINT ["/entrypoint.sh"]

open-webui/entrypoint.sh

Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
#!/bin/bash
2+
set -e
3+
4+
DB_FILE="/app/backend/data/webui.db"
5+
START_SCRIPT="/app/backend/start.sh"
6+
7+
MCP_ID="${MCP_ID:-default_id}"
8+
MCP_NAME="${MCP_NAME:-Default MCP}"
9+
MCP_URL="${MCP_URL:-http://localhost}"
10+
MCP_PATH="${MCP_PATH:-openapi.json}"
11+
12+
mkdir -p /app/backend/data
13+
14+
echo "Initializing OpenWebUI configuration..."
15+
16+
NEED_INIT=0
17+
if [ ! -f "$DB_FILE" ]; then
18+
echo "Database file not found, will initialize schema."
19+
NEED_INIT=1
20+
else
21+
echo "Database file exists, checking schema..."
22+
if ! sqlite3 "$DB_FILE" "SELECT name FROM sqlite_master WHERE type='table' AND name='config';" | grep -q "config"; then
23+
echo "Config table missing — need initialization."
24+
NEED_INIT=1
25+
fi
26+
fi
27+
28+
if [ "$NEED_INIT" -eq 1 ]; then
29+
echo "Running OpenWebUI once to auto-create schema..."
30+
31+
bash "$START_SCRIPT" &
32+
PID=$!
33+
34+
echo "Waiting for database creation..."
35+
while [ ! -f "$DB_FILE" ]; do
36+
sleep 1
37+
done
38+
39+
# waiting for config table
40+
until sqlite3 "$DB_FILE" "SELECT name FROM sqlite_master WHERE type='table' AND name='config';" | grep -q "config"; do
41+
sleep 1
42+
done
43+
44+
echo "Schema ready. Killing bootstrap instance..."
45+
kill $PID || true
46+
sleep 2
47+
else
48+
echo "Database schema already initialized. Skipping bootstrap."
49+
fi
50+
51+
echo "Updating config table..."
52+
53+
python3 <<EOF
54+
import sqlite3, json
55+
56+
db = "${DB_FILE}"
57+
58+
conn = sqlite3.connect(db)
59+
cur = conn.cursor()
60+
61+
cur.execute("SELECT id, data FROM config LIMIT 1;")
62+
row = cur.fetchone()
63+
64+
if row is None:
65+
base = {"version": 0, "ui": {}, "tool_server": {"connections": []}}
66+
cur.execute("INSERT INTO config (id, data, version) VALUES (1, ?, 0)", (json.dumps(base),))
67+
conn.commit()
68+
cur.execute("SELECT id, data FROM config LIMIT 1;")
69+
row = cur.fetchone()
70+
71+
config_id, data_json = row
72+
data = json.loads(data_json)
73+
74+
tool_server = data.setdefault("tool_server", {})
75+
connections = tool_server.setdefault("connections", [])
76+
77+
mcp_id = "${MCP_ID}"
78+
mcp_name = "${MCP_NAME}"
79+
mcp_url = "${MCP_URL}"
80+
mcp_path = "${MCP_PATH}"
81+
82+
found = next((c for c in connections if c.get("url") == mcp_url), None)
83+
84+
new_item = {
85+
"url": mcp_url,
86+
"path": mcp_path,
87+
"type": "mcp",
88+
"auth_type": "none",
89+
"key": "",
90+
"config": {
91+
"enable": True,
92+
"access_control": {
93+
"read": {"group_ids": [], "user_ids": []},
94+
"write": {"group_ids": [], "user_ids": []}
95+
}
96+
},
97+
"spec_type": "url",
98+
"spec": "",
99+
"info": {
100+
"id": mcp_id,
101+
"name": mcp_name,
102+
"description": ""
103+
}
104+
}
105+
106+
if found:
107+
found.update(new_item)
108+
else:
109+
connections.append(new_item)
110+
111+
cur.execute("UPDATE config SET data = ? WHERE id = ?;", (json.dumps(data), config_id))
112+
conn.commit()
113+
conn.close()
114+
EOF
115+
116+
echo "Config update complete."
117+
118+
echo "Starting OpenWebUI..."
119+
exec bash "$START_SCRIPT"

0 commit comments

Comments
 (0)