21 Commits
Author SHA1 Message Date
Brooke e243371a14 add further reading to README 2026-09-27 18:49:55 -04:00
Brooke f99eefa24f chore: publish 1.1.0+v1.9.6 release 2026-09-27 18:43:48 -04:00
Brooke e7cd73435d actually use entrypoint, expose secret with looser permissions 2026-09-27 18:43:14 -04:00
Brooke 24712e5e7b revert, suppress warnings in abra.sh 2026-09-27 18:09:09 -04:00
Brooke b0ca0cbbc9 suppress python warnings 2026-09-27 18:01:45 -04:00
Brooke 2b4acbd63f chore: publish 1.0.0+v1.9.6 release 2026-09-27 17:51:12 -04:00
Brooke 6909bc35bb rename error message 2026-09-27 17:30:34 -04:00
Brooke d5cfd98c4b update entrypoint 2026-09-27 17:29:37 -04:00
Brooke 94784c57fe use simplier method for exporting auth token 2026-09-27 17:29:10 -04:00
Brooke 47b4078425 add shebang to abra.sh 2026-09-27 17:21:53 -04:00
Brooke 5c52fbf13a update usage in readme 2026-09-27 17:17:10 -04:00
Brooke 14ada81718 revert 2026-09-27 17:16:57 -04:00
Brooke f170a09dd9 Booleans need to be capitalized 2026-09-27 17:16:46 -04:00
Brooke 4ca1ef53a7 use request limit instead of under attack 2026-09-27 16:49:52 -04:00
Brooke bc1c473d7c rename keys to key in abra.sh commands 2026-09-27 16:41:37 -04:00
Brooke 1db637f635 incorect name used to load metrics_auth_token in compose 2026-09-27 16:26:43 -04:00
Brooke 08f8bb4163 init custom entrypoint 2026-09-27 16:25:02 -04:00
Brooke 9e93213ab2 load metrics secret, add options to reflect new .env section, add custom entrypoint for auth_token_file and format. 2026-09-27 16:24:50 -04:00
Brooke cb7699ea13 add api key functions to abra.sh 2026-09-27 16:23:53 -04:00
Brooke 66fe0bcea6 add metrics and api options to .env list 2026-09-27 16:23:25 -04:00
Brooke 0d9cb4c4e4 update readme 2026-09-27 16:23:10 -04:00
6 changed files with 171 additions and 12 deletions
+8 -2
View File
@@ -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
+48 -3
View File
@@ -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/
+25 -2
View File
@@ -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
View File
@@ -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
+61
View File
@@ -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()'
+1
View File
@@ -0,0 +1 @@
fixed: warnings cluttering output when attempting to run abra cmd