From f85bf702ea3b000c51550ac786c737bf764ce56f Mon Sep 17 00:00:00 2001 From: Atinoda <61033436+Atinoda@users.noreply.github.com> Date: Mon, 28 Aug 2023 15:21:03 +0100 Subject: [PATCH] Implement versioned builds - Introduce new build arg `VERSION_TAG` - Update version freshness checking - Rename docker-compose build example file --- Dockerfile | 13 +++++++++-- README.md | 1 + ...pose.yml.build => docker-compose.build.yml | 4 +++- scripts/checkout_src_version.sh | 22 +++++++++++++++++++ scripts/docker-entrypoint.sh | 7 +++--- 5 files changed, 41 insertions(+), 6 deletions(-) rename docker-compose.yml.build => docker-compose.build.yml (88%) create mode 100644 scripts/checkout_src_version.sh diff --git a/Dockerfile b/Dockerfile index 3777c78..4d7aebc 100644 --- a/Dockerfile +++ b/Dockerfile @@ -12,10 +12,17 @@ ENV PATH="$VIRTUAL_ENV/bin:$PATH" RUN pip3 install --upgrade pip setuptools && \ pip3 install torch torchvision torchaudio -FROM env_base AS app_base +FROM env_base AS app_base +# Copy and enable all scripts +COPY ./scripts /scripts +RUN chmod +x /scripts/* ### DEVELOPERS/ADVANCED USERS ### # Clone oobabooga/text-generation-webui RUN git clone https://github.com/oobabooga/text-generation-webui /src +# Use script to check out specific version +ARG VERSION_TAG +ENV VERSION_TAG=${VERSION_TAG} +RUN . /scripts/checkout_src_version.sh # To use local source: comment out the git clone command then set the build arg `LCL_SRC_DIR` #ARG LCL_SRC_DIR="text-generation-webui" #COPY ${LCL_SRC_DIR} /src @@ -26,7 +33,6 @@ RUN cp -ar /src /app # Install oobabooga/text-generation-webui RUN --mount=type=cache,target=/root/.cache/pip pip3 install -r /app/requirements.txt # Install extensions -COPY ./scripts/build_extensions.sh /scripts/build_extensions.sh RUN --mount=type=cache,target=/root/.cache/pip \ chmod +x /scripts/build_extensions.sh && . /scripts/build_extensions.sh # Clone default GPTQ @@ -58,6 +64,9 @@ ENV PYTHONUNBUFFERED=1 ARG BUILD_DATE ENV BUILD_DATE=$BUILD_DATE RUN echo "$BUILD_DATE" > /build_date.txt +ARG VERSION_TAG +ENV VERSION_TAG=$VERSION_TAG +RUN echo "$VERSION_TAG" > /version_tag.txt # Copy and enable all scripts COPY ./scripts /scripts RUN chmod +x /scripts/* diff --git a/README.md b/README.md index a094462..bb674b1 100644 --- a/README.md +++ b/README.md @@ -26,6 +26,7 @@ Each variant has the 'extras' incuded in `default` but has some changes made as | `llama-cpu` | GPU supported is REMOVED from `llama-cpp`. Suitable for systems without a CUDA-capable GPU. *This is only for when GPU acceleration is not available and is a slower way to run models!* | | `monkey-patch` | Use LoRAs in 4-Bit `GPTQ-for-llama` mode. ***DEPRECATION WARNING:** This version is outdated, but will remain for now.* | | `llama-cublas` | CUDA GPU offloading enabled for `llama-cpp`. Use by setting option `n-gpu-layers` > 0. ***DEPRECATION WARNING:** This capability has been rolled into the default. The variant will be removed if the upstream dependency does not conflict with `default`.* | +| `{VARIANT}-version` | Build of each {VARIANT} tagged with the release version of the text-generation-webui (e.g., `default-v1.5`). *Visit [obabooga/text-generation-webui/releases](https://github.com/oobabooga/text-generation-webui/releases) for details.* | *See: [oobabooga/text-generation-webui/blob/main/docs/GPTQ-models-(4-bit-mode).md](https://github.com/oobabooga/text-generation-webui/blob/main/docs/GPTQ-models-(4-bit-mode).md), [obabooga/text-generation-webui/blob/main/docs/llama.cpp-models.md](https://github.com/oobabooga/text-generation-webui/blob/main/docs/llama.cpp-models.md), and [oobabooga/text-generation-webui/blob/main/docs/ExLlama.md](https://github.com/oobabooga/text-generation-webui/blob/main/docs/ExLlama.md) for more information on variants.* diff --git a/docker-compose.yml.build b/docker-compose.build.yml similarity index 88% rename from docker-compose.yml.build rename to docker-compose.build.yml index 5d4e2f3..2bcabbd 100644 --- a/docker-compose.yml.build +++ b/docker-compose.build.yml @@ -4,7 +4,9 @@ services: build: context: . target: default # Specify the variant to build -# args: + args: + - VERSION_TAG="v1.5" # Checkout this specific tag from upstream. Omit or set `nightly` for latest. +# - BUILD_DATE="1970-01-01" # Set the build date as desired # - LCL_SRC_DIR=text-generation-webui # Developers - see Dockerfile app_base container_name: text-generation-webui environment: diff --git a/scripts/checkout_src_version.sh b/scripts/checkout_src_version.sh new file mode 100644 index 0000000..a81c2e9 --- /dev/null +++ b/scripts/checkout_src_version.sh @@ -0,0 +1,22 @@ +#!/bin/bash + +set -x + +# Get current directory +cur_dir=$(pwd) +src_dir="/src" + +# Go to source code +cd $src_dir + +# If the version number is not an empty string +if [ -n "$VERSION_TAG" ]; then + # If NOT the tag is "nightly"... + if [ "$VERSION_TAG" != "nightly" ]; then + # Use the version number as a tag to checkout + git checkout -b $VERSION_TAG $VERSION_TAG + fi +fi + +# Go back to the original directory +cd $cur_dir \ No newline at end of file diff --git a/scripts/docker-entrypoint.sh b/scripts/docker-entrypoint.sh index cd51e2f..8788762 100644 --- a/scripts/docker-entrypoint.sh +++ b/scripts/docker-entrypoint.sh @@ -39,7 +39,8 @@ fi # Print variant VARIANT=$(cat /variant.txt) -echo "=== Running text-generation-webui variant: '$VARIANT' ===" +VERSION_TAG_STR=$(cat /version_tag.txt) +echo "=== Running text-generation-webui variant: '$VARIANT' $VERSION_TAG_STR ===" # Print version freshness cur_dir=$(pwd) @@ -51,9 +52,9 @@ if [ $? -ne 0 ]; then COMMITS_BEHIND="UNKNOWN" else # The command executed successfully - COMMITS_BEHIND=$(git rev-list HEAD..origin --count) + COMMITS_BEHIND=$(git rev-list HEAD..main --count) fi -echo "=== (This version is $COMMITS_BEHIND commits behind origin) ===" +echo "=== (This version is $COMMITS_BEHIND commits behind origin main) ===" cd $cur_dir # Print build date