mirror of
https://github.com/open-webui/open-webui
synced 2025-05-01 19:44:38 +00:00
Make Dockerfile and docker compose ready for build
This commit is contained in:
parent
07a6fbbb5f
commit
641cf04a6e
@ -26,6 +26,9 @@ ARG BUILD_HASH
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
# Set the Node.js memory limit to 8GB
|
||||
ENV NODE_OPTIONS="--max-old-space-size=8240"
|
||||
|
||||
COPY package.json package-lock.json ./
|
||||
RUN npm ci
|
||||
|
||||
|
@ -59,7 +59,6 @@ class Model(Base):
|
||||
"""
|
||||
The model's id as used in the API. If set to an existing model, it will override the model.
|
||||
"""
|
||||
user_id = Column(Text)
|
||||
|
||||
base_model_id = Column(Text, nullable=True)
|
||||
"""
|
||||
@ -108,7 +107,6 @@ class Model(Base):
|
||||
|
||||
class ModelModel(BaseModel):
|
||||
id: str
|
||||
user_id: str
|
||||
base_model_id: Optional[str] = None
|
||||
|
||||
name: str
|
||||
@ -151,12 +149,11 @@ class ModelForm(BaseModel):
|
||||
|
||||
class ModelsTable:
|
||||
def insert_new_model(
|
||||
self, form_data: ModelForm, user_id: str, company_id: str
|
||||
self, form_data: ModelForm, company_id: str
|
||||
) -> Optional[ModelModel]:
|
||||
model = ModelModel(
|
||||
**{
|
||||
**form_data.model_dump(),
|
||||
"user_id": user_id,
|
||||
"company_id": company_id,
|
||||
"created_at": int(time.time()),
|
||||
"updated_at": int(time.time()),
|
||||
|
@ -0,0 +1,67 @@
|
||||
"""Remove user_id column, add company_id column in model table
|
||||
|
||||
Revision ID: 6eb174dec7b4
|
||||
Revises: 9ca43b058511
|
||||
Create Date: 2025-02-10 16:14:39.127920
|
||||
|
||||
"""
|
||||
from typing import Sequence, Union
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
import open_webui.internal.db
|
||||
from sqlalchemy.engine.reflection import Inspector
|
||||
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision: str = '6eb174dec7b4'
|
||||
down_revision: Union[str, None] = '9ca43b058511'
|
||||
branch_labels: Union[str, Sequence[str], None] = None
|
||||
depends_on: Union[str, Sequence[str], None] = None
|
||||
|
||||
def column_exists(table, column):
|
||||
conn = op.get_bind()
|
||||
inspector = Inspector.from_engine(conn)
|
||||
columns = inspector.get_columns(table)
|
||||
return any(c["name"] == column for c in columns)
|
||||
|
||||
|
||||
def upgrade() -> None:
|
||||
# Add company_id column if it doesn't exist
|
||||
if not column_exists("model", "company_id"):
|
||||
op.add_column('model', sa.Column('company_id', sa.String(), nullable=True))
|
||||
|
||||
# Make columns non-nullable
|
||||
with op.batch_alter_table('model', schema=None) as batch_op:
|
||||
batch_op.alter_column('company_id', nullable=False)
|
||||
|
||||
# Delete user_id column if it exists
|
||||
if column_exists("model", "user_id"):
|
||||
batch_op.drop_column('user_id')
|
||||
|
||||
# Add foreign key constraint if it doesn't exist
|
||||
conn = op.get_bind()
|
||||
inspector = Inspector.from_engine(conn)
|
||||
foreign_keys = inspector.get_foreign_keys('model')
|
||||
if not any(fk['referred_table'] == 'company' for fk in foreign_keys):
|
||||
with op.batch_alter_table('model', schema=None) as batch_op:
|
||||
batch_op.create_foreign_key(
|
||||
'fk_user_company_id', 'company',
|
||||
['company_id'], ['id'], ondelete='CASCADE'
|
||||
)
|
||||
|
||||
|
||||
def downgrade() -> None:
|
||||
with op.batch_alter_table('model', schema=None) as batch_op:
|
||||
# Remove foreign key constraint if it exists
|
||||
foreign_keys = Inspector.from_engine(op.get_bind()).get_foreign_keys('model')
|
||||
if any(fk['name'] == 'fk_user_company_id' for fk in foreign_keys):
|
||||
batch_op.drop_constraint('fk_user_company_id', type_='foreignkey')
|
||||
|
||||
# Drop columns if they exist
|
||||
if column_exists("model", "company_id"):
|
||||
batch_op.drop_column('company_id')
|
||||
|
||||
# Add back user_id column if it doesn't exist
|
||||
if not column_exists("model", "user_id"):
|
||||
batch_op.add_column(sa.Column('user_id', sa.String(), nullable=True))
|
@ -10,10 +10,10 @@ from beyond_the_loop.models.models import (
|
||||
from open_webui.constants import ERROR_MESSAGES
|
||||
from fastapi import APIRouter, Depends, HTTPException, Request, status
|
||||
|
||||
|
||||
from open_webui.utils.auth import get_admin_user, get_verified_user
|
||||
from open_webui.utils.access_control import has_access, has_permission
|
||||
|
||||
from beyond_the_loop.models.companies import Companies
|
||||
|
||||
router = APIRouter()
|
||||
|
||||
@ -68,7 +68,9 @@ async def create_new_model(
|
||||
)
|
||||
|
||||
else:
|
||||
model = Models.insert_new_model(form_data, user.id)
|
||||
company = Companies.get_company_by_id(user.company_id)
|
||||
|
||||
model = Models.insert_new_model(form_data, company.id)
|
||||
if model:
|
||||
return model
|
||||
else:
|
||||
|
@ -1,34 +1,37 @@
|
||||
version: '3.8'
|
||||
|
||||
services:
|
||||
ollama:
|
||||
volumes:
|
||||
- ollama:/root/.ollama
|
||||
container_name: ollama
|
||||
pull_policy: always
|
||||
tty: true
|
||||
litellm:
|
||||
container_name: litellm
|
||||
image: ghcr.io/berriai/litellm:main-stable
|
||||
restart: unless-stopped
|
||||
image: ollama/ollama:${OLLAMA_DOCKER_TAG-latest}
|
||||
ports:
|
||||
- "4000:4000"
|
||||
volumes:
|
||||
- ./litellm-config.yaml:/app/config.yaml
|
||||
command: ["--config", "/app/config.yaml", "--port", "4000"]
|
||||
extra_hosts:
|
||||
- host.docker.internal:host-gateway
|
||||
|
||||
open-webui:
|
||||
build:
|
||||
context: .
|
||||
args:
|
||||
OLLAMA_BASE_URL: '/ollama'
|
||||
LITELLM_BASE_URL: '/litellm'
|
||||
dockerfile: Dockerfile
|
||||
image: ghcr.io/open-webui/open-webui:${WEBUI_DOCKER_TAG-main}
|
||||
container_name: open-webui
|
||||
volumes:
|
||||
- open-webui:/app/backend/data
|
||||
depends_on:
|
||||
- ollama
|
||||
- litellm
|
||||
ports:
|
||||
- ${OPEN_WEBUI_PORT-3000}:8080
|
||||
- "8080:8080" # Open Web UI port
|
||||
environment:
|
||||
- 'OLLAMA_BASE_URL=http://ollama:11434'
|
||||
- 'WEBUI_SECRET_KEY='
|
||||
- "OPENAI_API_BASE_URL=http://litellm:4000/v1" # Point Open Web UI to LiteLLM
|
||||
extra_hosts:
|
||||
- host.docker.internal:host-gateway
|
||||
restart: unless-stopped
|
||||
|
||||
volumes:
|
||||
ollama: {}
|
||||
open-webui: {}
|
||||
|
Loading…
Reference in New Issue
Block a user