Compare commits
21
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e243371a14 | ||
|
|
f99eefa24f | ||
|
|
e7cd73435d | ||
|
|
24712e5e7b | ||
|
|
b0ca0cbbc9 | ||
|
|
2b4acbd63f | ||
|
|
6909bc35bb | ||
|
|
d5cfd98c4b | ||
|
|
94784c57fe | ||
|
|
47b4078425 | ||
|
|
5c52fbf13a | ||
|
|
14ada81718 | ||
|
|
f170a09dd9 | ||
|
|
4ca1ef53a7 | ||
|
|
bc1c473d7c | ||
|
|
1db637f635 | ||
|
|
08f8bb4163 | ||
|
|
9e93213ab2 | ||
|
|
cb7699ea13 | ||
|
|
66fe0bcea6 | ||
|
|
0d9cb4c4e4 |
+8
-2
@@ -7,6 +7,12 @@ FRONTEND_TITLE="LibreTranslate"
|
||||
|
||||
# Choosing only some languages will drastically improve the time to download and update models
|
||||
# For language options see https://www.argosopentech.com/argospm/index/
|
||||
LANG="all"
|
||||
# Use the syntax from this example: "en,es,pt"
|
||||
LANG="All"
|
||||
|
||||
API_KEYS="true"
|
||||
API_KEYS="True"
|
||||
REQUIRE_API_KEY="True"
|
||||
DISABLE_WEB_UI="False"
|
||||
|
||||
METRICS="False"
|
||||
SECRET_METRICS_AUTH_TOKEN_VERSION=v1
|
||||
@@ -1,10 +1,10 @@
|
||||
# libretranslate
|
||||
# LibreTranslate
|
||||
|
||||
> Free and Open Source Machine Translation API. Self-hosted, offline capable and easy to setup.
|
||||
|
||||
<!-- metadata -->
|
||||
|
||||
* **Maintainer**:
|
||||
* **Maintainer**: [brooke](https://git.coopcloud.tech/Brooke)
|
||||
* **Category**: Apps
|
||||
* **Status**: 0
|
||||
* **Image**: [`libretranslate`](https://hub.docker.com/r/libretranslate/libretranslate), 4, upstream
|
||||
@@ -12,7 +12,7 @@
|
||||
* **Backups**: No
|
||||
* **Email**: No
|
||||
* **Tests**: No
|
||||
* **SSO**: No
|
||||
* **SSO**: N/A
|
||||
|
||||
<!-- endmetadata -->
|
||||
|
||||
@@ -23,3 +23,48 @@
|
||||
* `abra app deploy <app-name>`
|
||||
|
||||
For more, see [`docs.coopcloud.tech`](https://docs.coopcloud.tech).
|
||||
|
||||
## API Keys
|
||||
|
||||
Below is a list of commands you can use to generate/remove/view API keys. prefix any of the below commands with `abra app cmd <app-domain> app`
|
||||
|
||||
```sh
|
||||
# Add a key (120 requests/minute by default)
|
||||
key_add
|
||||
|
||||
# Add a key with a custom rate limit
|
||||
key_add 60
|
||||
|
||||
# Add a key with a character limit
|
||||
key_add 120 5000
|
||||
|
||||
# Remove a key
|
||||
key_remove "api-key"
|
||||
|
||||
# View all keys
|
||||
keys_view
|
||||
```
|
||||
|
||||
## Metrics
|
||||
|
||||
Metrics are exported Prometheus-compatible, in this recipe they also require a key.
|
||||
|
||||
Once you set `METRICS` to `true` you can use `https://<app-domain>/metrics` in your `prometheus.yml` and `SECRET_METRICS_AUTH_TOKEN` which was generated when you setup the app.
|
||||
|
||||
## Selecting Languages
|
||||
|
||||
By default [all available languages](https://www.argosopentech.com/argospm/index/) are loaded. Even though the Argo Translate models are very efficient they are too large to include in the image.
|
||||
|
||||
Expect `All` languages to take up between 8-10 GB of storage space. Depending on the host this can take between 10-20 minutes to setup.
|
||||
|
||||
If you choose to load languages individually keep in mind there's no one "language file" each Argos model is a from *and* to model. So, if you set `LANG` to `en,es` you will need both the *from* `es` and *to* `es` model files. So two languages will require two model files, 3 languages will require 6 model files.
|
||||
|
||||
## Backups
|
||||
|
||||
Backups only preserve API keys for the purpose of ensuring authentication stays consistent across restorations.
|
||||
|
||||
## Further reading
|
||||
|
||||
Please refer to https://docs.libretranslate.com/
|
||||
|
||||
For an incomplete list of projects that the LibreTranslate API will work with see https://docs.libretranslate.com/guides/integrations/
|
||||
@@ -1,2 +1,25 @@
|
||||
# Set any config versions here
|
||||
# Docs: https://docs.coopcloud.tech/maintainers/handbook/#manage-configs
|
||||
#!/bin/bash
|
||||
|
||||
export ENTRYPOINT_VERSION=v6
|
||||
export PYTHONWARNINGS="ignore"
|
||||
|
||||
key_add() {
|
||||
REQUESTS_PER_MINUTE=${1:-120}
|
||||
CHAR_LIMIT=${2:-}
|
||||
|
||||
if [ -n "$CHAR_LIMIT" ]; then
|
||||
ltmanage keys add "$REQUESTS_PER_MINUTE" --char-limit "$CHAR_LIMIT"
|
||||
else
|
||||
ltmanage keys add "$REQUESTS_PER_MINUTE"
|
||||
fi
|
||||
}
|
||||
|
||||
key_remove() {
|
||||
API_KEY=$1
|
||||
|
||||
ltmanage keys remove "$API_KEY"
|
||||
}
|
||||
|
||||
keys_view() {
|
||||
ltmanage keys
|
||||
}
|
||||
|
||||
+28
-5
@@ -5,6 +5,13 @@ services:
|
||||
networks:
|
||||
- proxy
|
||||
tty: true
|
||||
configs:
|
||||
- source: entrypoint
|
||||
target: /app/scripts/custom-entrypoint.sh
|
||||
mode: 0555
|
||||
secrets:
|
||||
- source: metrics_auth_token
|
||||
mode: 0444
|
||||
deploy:
|
||||
restart_policy:
|
||||
condition: on-failure
|
||||
@@ -18,30 +25,46 @@ services:
|
||||
- "traefik.http.middlewares.${STACK_NAME}-redirectscheme.redirectscheme.scheme=https"
|
||||
- "traefik.http.middlewares.${STACK_NAME}-redirectscheme.redirectscheme.permanent=true"
|
||||
## When you're ready for release, run "abra recipe sync <name>" to set this
|
||||
- "coop-cloud.${STACK_NAME}.version=0.1.0+v1.9.6"
|
||||
- "coop-cloud.${STACK_NAME}.version=1.1.0+v1.9.6"
|
||||
## Enable backups: https://docs.coopcloud.tech/maintainers/handbook/#how-do-i-configure-backuprestore
|
||||
- "backupbot.backup=true"
|
||||
- "backupbot.backup.volumes.libretranslate_api_keys=true"
|
||||
healthcheck:
|
||||
test: ['CMD-SHELL', './venv/bin/python scripts/healthcheck.py']
|
||||
test: ["CMD-SHELL", "./venv/bin/python scripts/healthcheck.py"]
|
||||
interval: 10s
|
||||
timeout: 4s
|
||||
retries: 4
|
||||
start_period: 5s
|
||||
entrypoint: /app/scripts/custom-entrypoint.sh
|
||||
environment:
|
||||
- LT_FRONTEND_TITLE=${FRONTEND_TITLE}
|
||||
- LT_API_KEYS=${API_KEYS}
|
||||
- LT_UNDER_ATTACK=${REQUIRE_API_KEY}
|
||||
- LT_DISABLE_WEB_UI=${DISABLE_WEB_UI}
|
||||
- LT_METRICS=${METRICS}
|
||||
- LT_API_KEYS_DB_PATH=/app/db/api_keys.db
|
||||
- LT_UPDATE_MODELS=true
|
||||
- LT_LOAD_ONLY=${LANG}
|
||||
- ARGOS_CHUNK_TYPE=MINISBD
|
||||
volumes:
|
||||
- libretranslate_api_keys:/app/db
|
||||
- libretranslate_models:/home/libretranslate/.local:rw
|
||||
|
||||
networks:
|
||||
proxy:
|
||||
secrets:
|
||||
metrics_auth_token:
|
||||
external: true
|
||||
name: ${STACK_NAME}_metrics_auth_token_${SECRET_METRICS_AUTH_TOKEN_VERSION}
|
||||
|
||||
configs:
|
||||
entrypoint:
|
||||
name: ${STACK_NAME}_entrypoint_${ENTRYPOINT_VERSION}
|
||||
file: entrypoint.sh.tmpl
|
||||
template_driver: golang
|
||||
|
||||
volumes:
|
||||
libretranslate_api_keys:
|
||||
libretranslate_models:
|
||||
libretranslate_models:
|
||||
|
||||
networks:
|
||||
proxy:
|
||||
external: true
|
||||
@@ -0,0 +1,61 @@
|
||||
#!/bin/bash
|
||||
|
||||
__dirname=$(cd "$(dirname "$0")"; pwd -P)
|
||||
cd "${__dirname}/.."
|
||||
|
||||
echo ""
|
||||
echo "░█░░░▀█▀░█▀▄░█▀▄░█▀▀░▀█▀░█▀▄░█▀█░█▀█░█▀▀░█░░░█▀█░▀█▀░█▀▀"
|
||||
echo "░█░░░░█░░█▀▄░█▀▄░█▀▀░░█░░█▀▄░█▀█░█░█░▀▀█░█░░░█▀█░░█░░█▀▀"
|
||||
echo "░▀▀▀░▀▀▀░▀▀░░▀░▀░▀▀▀░░▀░░▀░▀░▀░▀░▀░▀░▀▀▀░▀▀▀░▀░▀░░▀░░▀▀▀"
|
||||
|
||||
echo "v$(cat VERSION)"
|
||||
echo ""
|
||||
|
||||
echo Booting...
|
||||
touch /tmp/booting.flag
|
||||
export PYTHONWARNINGS="ignore"
|
||||
|
||||
if [[ -f ./venv/bin/libretranslate ]]; then
|
||||
LT_POWERCYCLE=1 ./venv/bin/libretranslate "$@"
|
||||
else
|
||||
echo "WARNING: Cannot powercycle LibreTranslate (if you are in development mode, that's fine..)"
|
||||
fi
|
||||
|
||||
rm -f /tmp/booting.flag
|
||||
|
||||
eval $(./venv/bin/python ./scripts/print_args_env.py "$@")
|
||||
|
||||
if [[ $LT_HOST == "127.0.0.1" ]]; then
|
||||
# Default
|
||||
BIND_ADDR="0.0.0.0"
|
||||
if [[ -f /proc/sys/net/ipv6/conf/all/disable_ipv6 ]]; then
|
||||
IPV6_STATUS=$(cat /proc/sys/net/ipv6/conf/all/disable_ipv6)
|
||||
if [[ $IPV6_STATUS -eq 0 ]]; then
|
||||
BIND_ADDR="[::]"
|
||||
fi
|
||||
fi
|
||||
else
|
||||
BIND_ADDR="$LT_HOST"
|
||||
fi
|
||||
|
||||
# Do not update models when workers restart
|
||||
unset LT_UPDATE_MODELS
|
||||
unset FORCE_UPDATE_MODELS
|
||||
|
||||
# Setup prometheus metrics db
|
||||
export PROMETHEUS_MULTIPROC_DIR=$(realpath "${__dirname}/../db/prometheus")
|
||||
if [[ -e "$PROMETHEUS_MULTIPROC_DIR" ]]; then
|
||||
find "$PROMETHEUS_MULTIPROC_DIR" -name '*.db' -delete
|
||||
else
|
||||
mkdir -p "$PROMETHEUS_MULTIPROC_DIR"
|
||||
fi
|
||||
|
||||
export OMP_NUM_THREADS=1
|
||||
|
||||
if [ -f /run/secrets/metrics_auth_token ]; then
|
||||
export LT_METRICS_AUTH_TOKEN=$(cat /run/secrets/metrics_auth_token)
|
||||
else
|
||||
echo "Metrics secret not found, skipping."
|
||||
fi
|
||||
|
||||
./venv/bin/gunicorn -c scripts/gunicorn_conf.py --workers $LT_THREADS --max-requests 250 --timeout ${LT_TIMEOUT:-2400} --bind $BIND_ADDR:$LT_PORT 'wsgi:app()'
|
||||
@@ -0,0 +1 @@
|
||||
fixed: warnings cluttering output when attempting to run abra cmd
|
||||
Reference in New Issue
Block a user