Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 7922d42e73 |
70
Dockerfile
70
Dockerfile
@ -1,51 +1,51 @@
|
||||
FROM nvcr.io/nvidia/cuda:12.9.1-cudnn-runtime-ubuntu22.04
|
||||
# ---------- Stage 1: Frontend ----------
|
||||
FROM node:20-bullseye-slim AS frontend
|
||||
|
||||
# Install Python 3.11 and system dependencies
|
||||
WORKDIR /app
|
||||
# Pull source with all submodules
|
||||
RUN apt-get update && apt-get install -y git \
|
||||
&& git clone --branch main --recurse-submodules https://github.com/open-webui/open-webui.git . \
|
||||
&& git submodule update --init --recursive
|
||||
|
||||
# Build frontend
|
||||
ENV NODE_OPTIONS="--max_old_space_size=8192"
|
||||
RUN npm ci --legacy-peer-deps && npm run build
|
||||
# Optional check
|
||||
RUN ls -la /app/build
|
||||
|
||||
# ---------- Stage 2: Backend ----------
|
||||
FROM nvidia/cuda:12.9.1-cudnn-runtime-ubuntu22.04
|
||||
|
||||
# Install system deps
|
||||
RUN apt-get update && apt-get install -y \
|
||||
python3.11 python3-pip git curl libgl1 libglib2.0-0 ffmpeg \
|
||||
&& curl -fsSL https://deb.nodesource.com/setup_20.x | bash - && \
|
||||
apt-get install -y nodejs \
|
||||
&& apt-get clean && rm -rf /var/lib/apt/lists/*
|
||||
&& apt-get clean && rm -rf /var/lib/apt/lists/*
|
||||
|
||||
RUN update-alternatives --install /usr/bin/python python /usr/bin/python3.11 1 && \
|
||||
update-alternatives --install /usr/bin/pip pip /usr/bin/pip3 1
|
||||
RUN update-alternatives --install /usr/bin/python python /usr/bin/python3.11 1 \
|
||||
&& update-alternatives --install /usr/bin/pip pip /usr/bin/pip3 1
|
||||
|
||||
RUN python -m pip install --upgrade pip
|
||||
|
||||
# Set working directory
|
||||
# Clone backend code
|
||||
WORKDIR /app
|
||||
RUN git clone --branch main --recurse-submodules https://github.com/open-webui/open-webui.git . \
|
||||
&& git submodule update --init --recursive
|
||||
|
||||
# Clone Open WebUI
|
||||
RUN git clone https://github.com/open-webui/open-webui.git .
|
||||
# Patch (if needed) for logging API change
|
||||
RUN sed -i 's/logging.getLevelNamesMapping()/logging._nameToLevel/' backend/open_webui/env.py
|
||||
|
||||
# Patch env.py for Python 3.11 compatibility
|
||||
RUN sed -i 's/logging.getLevelNamesMapping()/logging._nameToLevel/' /app/backend/open_webui/env.py
|
||||
# Copy frontend build from Stage 1
|
||||
COPY --from=frontend /app/build /app/build
|
||||
|
||||
# Set Node.js memory limit for build
|
||||
ENV NODE_OPTIONS="--max_old_space_size=8192"
|
||||
|
||||
# Build frontend
|
||||
WORKDIR /app/frontend
|
||||
RUN npm install y-protocols --legacy-peer-deps
|
||||
RUN npm install --legacy-peer-deps
|
||||
|
||||
# Build the frontend with verbose logging
|
||||
RUN npm run build --verbose || true
|
||||
|
||||
# Change ownership of the backend directory
|
||||
RUN chown -R 1001:1001 /app/backend
|
||||
|
||||
# Install backend dependencies
|
||||
# Install Python deps
|
||||
WORKDIR /app/backend
|
||||
RUN python -m pip install --no-cache-dir -r requirements.txt uvicorn
|
||||
RUN pip install --no-cache-dir -r requirements.txt uvicorn \
|
||||
&& pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu121
|
||||
|
||||
# Install PyTorch with CUDA 12.x support
|
||||
RUN pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu121
|
||||
|
||||
# Set the DATABASE_URL environment variable (uncomment if needed)
|
||||
# ENV DATABASE_URL='sqlite:////home/llm/open-webui/database.db'
|
||||
# RUN python -m peewee_migrate migrate
|
||||
# Force Python to see /app as a top‑level package location
|
||||
WORKDIR /app
|
||||
ENV PYTHONPATH=/app:/app/backend
|
||||
|
||||
EXPOSE 3000
|
||||
|
||||
CMD ["uvicorn", "open_webui.main:app", "--host", "0.0.0.0", "--port", "3000"]
|
||||
CMD ["uvicorn", "backend.open_webui.main:app", "--host", "0.0.0.0", "--port", "3000"]
|
||||
|
||||
Reference in New Issue
Block a user