mirror of
https://github.com/open-webui/open-webui.git
synced 2026-11-22 21:50:42 -05:00
feat: build the Docker image from locked, hash-verified dependencies (#33981)
The image used to install only the directly pinned packages and resolved everything below them fresh from PyPI on every build, so the same commit could produce different images. The standard and slim images now install from lock files that pin every package with hashes, except PyTorch and its few own dependencies, which still come from the PyTorch index so the CPU and CUDA variants keep working. A new CI check fails when a requirements file changes without regenerating its lock, and the script that regenerates them sits next to the requirements. Fixes #33979
This commit is contained in:
1 parent
9ad2519c6c
commit
1c58242b4f
6 files changed
+12690
-5
No files matched your search
@@ -1,5 +1,5 @@
|
||||
# ─────────────────────────────────────────────────────────────────────────────
|
||||
# Backend CI — Python formatting checks via Ruff
|
||||
# Backend CI — Python formatting checks via Ruff and lock file check
|
||||
# Runs on pushes and PRs to main/dev when backend files change
|
||||
# ─────────────────────────────────────────────────────────────────────────────
|
||||
name: Python CI
|
||||
@@ -41,3 +41,24 @@ jobs:
|
||||
|
||||
- name: Detect logic errors
|
||||
run: ruff check --select=F --ignore=F401,F403,F405,F541,F811,F841 --output-format=github .
|
||||
|
||||
# ── Dockerfile lock files match the requirements files ───────────────────
|
||||
lock-check:
|
||||
name: Requirements locks up to date
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 10
|
||||
steps:
|
||||
- uses: actions/checkout@v5.1.0
|
||||
|
||||
- uses: actions/setup-python@v6.3.0
|
||||
with:
|
||||
python-version: '3.12'
|
||||
|
||||
- name: Install uv
|
||||
run: pip install uv==0.12.10
|
||||
|
||||
- name: Regenerate locks
|
||||
run: backend/update-locks.sh
|
||||
|
||||
- name: Verify locks are up to date
|
||||
run: test -z "$(git status --porcelain -- backend)"
|
||||
+4
-4
@@ -154,7 +154,7 @@ RUN apt-get update && \
|
||||
fi && rm -rf /var/lib/apt/lists/*
|
||||
|
||||
# install python dependencies
|
||||
COPY --chown=$UID:$GID ./backend/requirements*.txt ./
|
||||
COPY --chown=$UID:$GID ./backend/requirements*.lock ./
|
||||
|
||||
# Set UV_LINK_MODE to copy to prevent 0-byte file corruption in QEMU arm64 cross-builds
|
||||
ENV UV_LINK_MODE=copy
|
||||
@@ -162,19 +162,19 @@ ENV UV_LINK_MODE=copy
|
||||
RUN --mount=from=ghcr.io/astral-sh/uv:0.12.10,source=/uv,target=/bin/uv \
|
||||
set -e; \
|
||||
if [ "$USE_SLIM" = "true" ]; then \
|
||||
uv pip install --system -r requirements-slim.txt --no-cache-dir; \
|
||||
uv pip install --system --no-deps --require-hashes -r requirements-slim.lock --no-cache-dir; \
|
||||
elif [ "$USE_CUDA" = "true" ]; then \
|
||||
# If you use CUDA the whisper and embedding model will be downloaded on first use
|
||||
# fix: pin torch<=2.9.1 - torch 2.10.0 aarch64 wheels cause SIGILL on ARM devices (RPi 4 Cortex-A72) #21349
|
||||
pip3 install 'torch<=2.9.1' torchvision torchaudio --index-url https://download.pytorch.org/whl/$USE_CUDA_DOCKER_VER --no-cache-dir; \
|
||||
uv pip install --system -r requirements.txt --no-cache-dir; \
|
||||
uv pip install --system --no-deps --require-hashes -r requirements.lock --no-cache-dir; \
|
||||
python -c "import os; from sentence_transformers import SentenceTransformer; SentenceTransformer(os.environ['RAG_EMBEDDING_MODEL'], device='cpu')"; \
|
||||
python -c "import os; from sentence_transformers import SentenceTransformer; SentenceTransformer(os.environ.get('AUXILIARY_EMBEDDING_MODEL', 'TaylorAI/bge-micro-v2'), device='cpu')"; \
|
||||
python -c "import os; from faster_whisper import WhisperModel; WhisperModel(os.environ['WHISPER_MODEL'], device='cpu', compute_type='int8', download_root=os.environ['WHISPER_MODEL_DIR'])"; \
|
||||
python -c "import os; import tiktoken; tiktoken.get_encoding(os.environ['TIKTOKEN_ENCODING_NAME'])"; \
|
||||
else \
|
||||
pip3 install 'torch<=2.9.1' torchvision torchaudio --index-url https://download.pytorch.org/whl/cpu --no-cache-dir; \
|
||||
uv pip install --system -r requirements.txt --no-cache-dir; \
|
||||
uv pip install --system --no-deps --require-hashes -r requirements.lock --no-cache-dir; \
|
||||
if [ "$USE_SLIM" != "true" ]; then \
|
||||
python -c "import os; from sentence_transformers import SentenceTransformer; SentenceTransformer(os.environ['RAG_EMBEDDING_MODEL'], device='cpu')"; \
|
||||
python -c "import os; from sentence_transformers import SentenceTransformer; SentenceTransformer(os.environ.get('AUXILIARY_EMBEDDING_MODEL', 'TaylorAI/bge-micro-v2'), device='cpu')"; \
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
File diff suppressed because it is too large.
Load diff
Executable
+8
@@ -0,0 +1,8 @@
|
||||
#!/usr/bin/env bash
|
||||
# Regenerates the Dockerfile lock files; torch is overridden out because the Dockerfile installs it from the PyTorch index.
|
||||
set -euo pipefail
|
||||
cd "$(dirname "$0")"
|
||||
|
||||
flags=(--universal --python-version 3.12 --generate-hashes --no-header --quiet)
|
||||
uv pip compile requirements-slim.txt "${flags[@]}" -o requirements-slim.lock
|
||||
uv pip compile requirements.txt "${flags[@]}" --override <(echo "torch; python_version < '0'") -o requirements.lock
|
||||
@@ -191,6 +191,9 @@ exclude = [
|
||||
".webui_secret_key",
|
||||
"dev.sh",
|
||||
"requirements.txt",
|
||||
"requirements.lock",
|
||||
"requirements-slim.lock",
|
||||
"update-locks.sh",
|
||||
"start.sh",
|
||||
"start_windows.bat",
|
||||
"webui.db",
|
||||
|
||||
Reference in new issue
Block a user