Implement persistent extensions with optional runtime build

- Extensions are now explicitly copied from source to named volume
- Optional rebuild at runtime allows for extensions not present during build
- Closes #3
pull/10/head
Atinoda 11 months ago
parent 7caaaa4a7c
commit 19f9c1b1ac

@ -57,9 +57,10 @@ ENV PYTHONUNBUFFERED=1
ARG BUILD_DATE
ENV BUILD_DATE=$BUILD_DATE
RUN echo "$BUILD_DATE" > /build_date.txt
# Copy and enable all scripts
COPY ./scripts /scripts
RUN chmod +x /scripts/*
# Run
COPY ./scripts/docker-entrypoint.sh /scripts/docker-entrypoint.sh
RUN chmod +x /scripts/docker-entrypoint.sh
ENTRYPOINT ["/scripts/docker-entrypoint.sh"]

@ -52,7 +52,9 @@ Three commonly used ports are exposed:
*Extensions may use additional ports - check the application documentation for more details.*
### Volumes
The provided example docker compose maps several volumes from the local `config` directory into the container: `loras, models, presets, prompts, training`. If these folders are empty, they will be initialised when the container is run.
The provided example docker compose maps several volumes from the local `config` directory into the container: `loras, models, presets, prompts, training, extensions`. If these folders are empty, they will be initialised when the container is run.
Extensions will persist their state between container launches if you use the mapped folder - **but they will not automatically update when a new image is released, so this feature is disabled by default.** You must uncomment the mapping in `docker-compose.yml` to enable this extension persistence.
*If you are getting an error about missing files, try clearing these folders and letting the service re-populate them.*
@ -61,6 +63,13 @@ Extra launch arguments can be defined in the environment variable `EXTRA_LAUNCH_
*Launch arguments should be defined as a space-separated list, just like writing them on the command line. These arguments are passed to the `server.py` module.*
### Runtime extension build
Extra launch arguments can be defined in the environment variable `BUILD_EXTENSIONS_LIVE` (e.g., `"silero_tts whisper_stt"`, will rebuild those extensions at launch). This feature may be useful if you are developing a third-party extension and need its dependencies refresh at launch.
**Startup times will be much slower** if you use this feature, because it will rebuild the named extensions every time the container is started (i.e., don't use this feature unless you are certain that you need it.)
*Extension names for runtime build should be defined as a space-separated list.*
### Updates
These projects are moving quickly! To update to the most recent version on Docker hub, pull the latest image:

@ -5,6 +5,7 @@ services:
container_name: text-generation-webui
environment:
- EXTRA_LAUNCH_ARGS="--listen --verbose" # Custom launch args (e.g., --model MODEL_NAME)
# - BUILD_EXTENSIONS_LIVE="silero_tts whisper_stt" # Install named extensions during every container launch. THIS WILL SIGNIFICANLTLY SLOW LAUNCH TIME.
ports:
- 7860:7860 # Default web port
# - 5000:5000 # Default API port
@ -17,6 +18,7 @@ services:
- ./config/prompts:/app/prompts
- ./config/softprompts:/app/softprompts
- ./config/training:/app/training
- ./config/extensions:/app/extensions
logging:
driver: json-file
options:

@ -9,6 +9,7 @@ services:
container_name: text-generation-webui
environment:
- EXTRA_LAUNCH_ARGS="--listen --verbose" # Custom launch args (e.g., --model MODEL_NAME)
# - BUILD_EXTENSIONS_LIVE="silero_tts whisper_stt" # Install named extensions during every container launch. THIS WILL SIGNIFICANLTLY SLOW LAUNCH TIME.
ports:
- 7860:7860 # Default web port
# - 5000:5000 # Default API port
@ -21,6 +22,7 @@ services:
- ./config/prompts:/app/prompts
- ./config/softprompts:/app/softprompts
- ./config/training:/app/training
- ./config/extensions:/app/extensions
logging:
driver: json-file
options:

@ -10,7 +10,7 @@ function ctrl_c {
trap ctrl_c SIGTERM SIGINT SIGQUIT SIGHUP
# Generate default configs if empty
CONFIG_DIRECTORIES=("loras" "models" "presets" "prompts" "training/datasets" "training/formats")
CONFIG_DIRECTORIES=("loras" "models" "presets" "prompts" "training/datasets" "training/formats" "extensions")
for config_dir in "${CONFIG_DIRECTORIES[@]}"; do
if [ -z "$(ls /app/"$config_dir")" ]; then
echo "*** Initialising config for: '$config_dir' ***"
@ -19,6 +19,12 @@ for config_dir in "${CONFIG_DIRECTORIES[@]}"; do
fi
done
# Runtime extension build
if [[ -n "$BUILD_EXTENSIONS_LIVE" ]]; then
eval "live_extensions=($BUILD_EXTENSIONS_LIVE)"
. /scripts/extensions_runtime_rebuild.sh $live_extensions
fi
# Print variant
VARIANT=$(cat /variant.txt)
echo "=== Running text-generation-webui variant: '$VARIANT' ==="

@ -0,0 +1,32 @@
#!/bin/bash
# Note starting directory
cur_dir=$(pwd)
# Specify the directory containing the top-level folders
directory="/app/extensions"
# Iterate over the extensions passed in args
for extension in "$@"; do
echo $extension
folder="$directory/$extension"
if [ -d "$folder" ]; then
# Change directory to the current folder
cd "$folder"
# Check if requirements.txt file exists
if [ -f "requirements.txt" ]; then
echo "Live installing requirements for $folder..."
pip3 install -r requirements.txt
echo "Requirements installed in $folder"
else
echo "Skipping live install of $folder: requirements.txt not found"
fi
# Change back to the original directory
cd "$directory"
fi
done
# Return to starting directory
cd $cur_dir
Loading…
Cancel
Save