Skip to content

Commit 3a4fb6f

Browse files
authored
feat(entrypoint): optionally prepare extra endpoints (#1405)
entrypoint: optionally prepare extra endpoints Signed-off-by: Ettore Di Giacinto <[email protected]>
1 parent b181503 commit 3a4fb6f

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

docs/content/advanced/_index.en.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -348,6 +348,7 @@ there are additional environment variables available that modify the behavior of
348348
| `BUILD_TYPE` | | Build type. Available: `cublas`, `openblas`, `clblas` |
349349
| `GO_TAGS` | | Go tags. Available: `stablediffusion` |
350350
| `HUGGINGFACEHUB_API_TOKEN` | | Special token for interacting with HuggingFace Inference API, required only when using the `langchain-huggingface` backend |
351+
| `EXTRA_BACKENDS` | | A space separated list of backends to prepare. For example `EXTRA_BACKENDS="backend/python/diffusers backend/python/transformers"` prepares the conda environment on start |
351352

352353
Here is how to configure these variables:
353354

@@ -372,7 +373,7 @@ By default, all the backends are built.
372373

373374
LocalAI can be extended with extra backends. The backends are implemented as `gRPC` services and can be written in any language. The container images that are built and published on [quay.io](https://quay.io/repository/go-skynet/local-ai?tab=tags) contain a set of images split in core and extra. By default Images bring all the dependencies and backends supported by LocalAI (we call those `extra` images). The `-core` images instead bring only the strictly necessary dependencies to run LocalAI without only a core set of backends.
374375

375-
If you wish to build a custom container image with extra backends, you can use the core images and build only the backends you are interested into. For instance, to use the diffusers backend:
376+
If you wish to build a custom container image with extra backends, you can use the core images and build only the backends you are interested into or prepare the environment on startup by using the `EXTRA_BACKENDS` environment variable. For instance, to use the diffusers backend:
376377

377378
```Dockerfile
378379
FROM quay.io/go-skynet/local-ai:master-ffmpeg-core
@@ -395,3 +396,11 @@ ENV EXTERNAL_GRPC_BACKENDS="diffusers:/build/backend/python/diffusers/run.sh"
395396
You can specify remote external backends or path to local files. The syntax is `backend-name:/path/to/backend` or `backend-name:host:port`.
396397

397398
{{% /notice %}}
399+
400+
#### In runtime
401+
402+
When using the `-core` container image it is possible to prepare the python backends you are interested into by using the `EXTRA_BACKENDS` variable, for instance:
403+
404+
```bash
405+
docker run --env EXTRA_BACKENDS="backend/python/diffusers" quay.io/go-skynet/local-ai:master-ffmpeg-core
406+
```

entrypoint.sh

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,16 @@ set -e
33

44
cd /build
55

6+
# If we have set EXTRA_BACKENDS, then we need to prepare the backends
7+
if [ -n "$EXTRA_BACKENDS" ]; then
8+
echo "EXTRA_BACKENDS: $EXTRA_BACKENDS"
9+
# Space separated list of backends
10+
for backend in $EXTRA_BACKENDS; do
11+
echo "Preparing backend: $backend"
12+
make -C $backend
13+
done
14+
fi
15+
616
if [ "$REBUILD" != "false" ]; then
717
rm -rf ./local-ai
818
make build -j${BUILD_PARALLELISM:-1}

0 commit comments

Comments
 (0)