mirror of
https://github.com/open-webui/pipelines
synced 2025-05-10 07:30:47 +00:00
add minimum image type
This commit is contained in:
parent
ce236ef074
commit
625d620970
@ -1,2 +1,11 @@
|
||||
.venv
|
||||
.env
|
||||
.git
|
||||
.gitignore
|
||||
.github
|
||||
Dockerfile
|
||||
examples
|
||||
docs
|
||||
*.md
|
||||
dev.sh
|
||||
dev-docker.sh
|
||||
|
132
.github/workflows/docker-build.yaml
vendored
132
.github/workflows/docker-build.yaml
vendored
@ -188,6 +188,93 @@ jobs:
|
||||
if-no-files-found: error
|
||||
retention-days: 1
|
||||
|
||||
build-minimum-image:
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
contents: read
|
||||
packages: write
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
platform:
|
||||
- linux/amd64
|
||||
- linux/arm64
|
||||
|
||||
steps:
|
||||
- name: Prepare
|
||||
run: |
|
||||
platform=${{ matrix.platform }}
|
||||
echo "PLATFORM_PAIR=${platform//\//-}" >> $GITHUB_ENV
|
||||
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Set up QEMU
|
||||
uses: docker/setup-qemu-action@v3
|
||||
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v3
|
||||
|
||||
- name: Log in to the Container registry
|
||||
uses: docker/login-action@v3
|
||||
with:
|
||||
registry: ${{ env.REGISTRY }}
|
||||
username: ${{ github.actor }}
|
||||
password: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- name: Extract metadata for Docker images (default latest tag)
|
||||
id: meta
|
||||
uses: docker/metadata-action@v5
|
||||
with:
|
||||
images: ${{ env.FULL_IMAGE_NAME }}
|
||||
tags: |
|
||||
type=ref,event=branch
|
||||
type=ref,event=tag
|
||||
type=sha,prefix=git-
|
||||
type=semver,pattern={{version}}
|
||||
type=semver,pattern={{major}}.{{minor}}
|
||||
flavor: |
|
||||
latest=${{ github.ref == 'refs/heads/main' }}
|
||||
|
||||
- name: Extract metadata for Docker cache
|
||||
id: cache-meta
|
||||
uses: docker/metadata-action@v5
|
||||
with:
|
||||
images: ${{ env.FULL_IMAGE_NAME }}
|
||||
tags: |
|
||||
type=ref,event=branch
|
||||
flavor: |
|
||||
prefix=cache-${{ matrix.platform }}-
|
||||
|
||||
- name: Build Docker image (latest)
|
||||
uses: docker/build-push-action@v5
|
||||
id: build
|
||||
with:
|
||||
context: .
|
||||
push: true
|
||||
platforms: ${{ matrix.platform }}
|
||||
labels: ${{ steps.meta.outputs.labels }}
|
||||
outputs: type=image,name=${{ env.FULL_IMAGE_NAME }},push-by-digest=true,name-canonical=true,push=true
|
||||
cache-from: type=registry,ref=${{ steps.cache-meta.outputs.tags }}
|
||||
cache-to: type=registry,ref=${{ steps.cache-meta.outputs.tags }},mode=max
|
||||
build-args: |
|
||||
BUILD_HASH=${{ github.sha }}
|
||||
MINIMUM_BUILD=true
|
||||
|
||||
- name: Export digest
|
||||
run: |
|
||||
mkdir -p /tmp/digests
|
||||
digest="${{ steps.build.outputs.digest }}"
|
||||
touch "/tmp/digests/${digest#sha256:}"
|
||||
|
||||
- name: Upload digest
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: digests-minimum-${{ env.PLATFORM_PAIR }}
|
||||
path: /tmp/digests/*
|
||||
if-no-files-found: error
|
||||
retention-days: 1
|
||||
|
||||
merge-main-images:
|
||||
runs-on: ubuntu-latest
|
||||
needs: [build-main-image]
|
||||
@ -275,3 +362,48 @@ jobs:
|
||||
- name: Inspect image
|
||||
run: |
|
||||
docker buildx imagetools inspect ${{ env.FULL_IMAGE_NAME }}:${{ steps.meta.outputs.version }}
|
||||
|
||||
merge-minimum-images:
|
||||
runs-on: ubuntu-latest
|
||||
needs: [build-minimum-image]
|
||||
steps:
|
||||
- name: Download digests
|
||||
uses: actions/download-artifact@v4
|
||||
with:
|
||||
pattern: digests-minimum-*
|
||||
path: /tmp/digests
|
||||
merge-multiple: true
|
||||
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v3
|
||||
|
||||
- name: Log in to the Container registry
|
||||
uses: docker/login-action@v3
|
||||
with:
|
||||
registry: ${{ env.REGISTRY }}
|
||||
username: ${{ github.actor }}
|
||||
password: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- name: Extract metadata for Docker images (default latest tag)
|
||||
id: meta
|
||||
uses: docker/metadata-action@v5
|
||||
with:
|
||||
images: ${{ env.FULL_IMAGE_NAME }}
|
||||
tags: |
|
||||
type=ref,event=branch
|
||||
type=ref,event=tag
|
||||
type=sha,prefix=git-
|
||||
type=raw,enable=${{ github.ref == 'refs/heads/main' }},prefix=,suffix=,value=minimum
|
||||
flavor: |
|
||||
latest=${{ github.ref == 'refs/heads/main' }}
|
||||
suffix=-minimum,onlatest=true
|
||||
|
||||
- name: Create manifest list and push
|
||||
working-directory: /tmp/digests
|
||||
run: |
|
||||
docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \
|
||||
$(printf '${{ env.FULL_IMAGE_NAME }}@sha256:%s ' *)
|
||||
|
||||
- name: Inspect image
|
||||
run: |
|
||||
docker buildx imagetools inspect ${{ env.FULL_IMAGE_NAME }}:${{ steps.meta.outputs.version }}
|
||||
|
21
Dockerfile
21
Dockerfile
@ -1,6 +1,7 @@
|
||||
FROM python:3.11-slim-bookworm as base
|
||||
FROM python:3.11-slim-bookworm AS base
|
||||
|
||||
# Use args
|
||||
ARG MINIMUM_BUILD
|
||||
ARG USE_CUDA
|
||||
ARG USE_CUDA_VER
|
||||
|
||||
@ -8,11 +9,12 @@ ARG USE_CUDA_VER
|
||||
ENV ENV=prod \
|
||||
PORT=9099 \
|
||||
# pass build args to the build
|
||||
MINIMUM_BUILD=${MINIMUM_BUILD} \
|
||||
USE_CUDA_DOCKER=${USE_CUDA} \
|
||||
USE_CUDA_DOCKER_VER=${USE_CUDA_VER}
|
||||
|
||||
|
||||
# Install GCC and build tools
|
||||
# Install GCC and build tools.
|
||||
# These are kept in the final image to enable installing packages on the fly.
|
||||
RUN apt-get update && \
|
||||
apt-get install -y gcc build-essential curl git && \
|
||||
apt-get clean && \
|
||||
@ -22,13 +24,20 @@ WORKDIR /app
|
||||
|
||||
# Install Python dependencies
|
||||
COPY ./requirements.txt .
|
||||
RUN pip3 install uv && \
|
||||
if [ "$USE_CUDA" = "true" ]; then \
|
||||
COPY ./requirements-minimum.txt .
|
||||
RUN pip3 install uv
|
||||
RUN if [ "$MINIMUM_BUILD" != "true" ]; then \
|
||||
if [ "$USE_CUDA_DOCKER" = "true" ]; then \
|
||||
pip3 install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/$USE_CUDA_DOCKER_VER --no-cache-dir; \
|
||||
else \
|
||||
pip3 install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cpu --no-cache-dir; \
|
||||
fi \
|
||||
fi
|
||||
RUN if [ "$MINIMUM_BUILD" = "true" ]; then \
|
||||
uv pip install --system -r requirements-minimum.txt --no-cache-dir; \
|
||||
else \
|
||||
uv pip install --system -r requirements.txt --no-cache-dir; \
|
||||
fi
|
||||
RUN uv pip install --system -r requirements.txt --no-cache-dir
|
||||
|
||||
# Copy the application code
|
||||
COPY . .
|
||||
|
15
requirements-minimum.txt
Normal file
15
requirements-minimum.txt
Normal file
@ -0,0 +1,15 @@
|
||||
fastapi==0.111.0
|
||||
uvicorn[standard]==0.22.0
|
||||
pydantic==2.7.1
|
||||
python-multipart==0.0.9
|
||||
python-socketio
|
||||
grpcio
|
||||
|
||||
passlib==1.7.4
|
||||
passlib[bcrypt]
|
||||
PyJWT[crypto]
|
||||
|
||||
requests==2.32.2
|
||||
aiohttp==3.9.5
|
||||
httpx
|
||||
|
Loading…
Reference in New Issue
Block a user