使用 Docker 安裝¶
With dockerized Weblate deployment you can get your personal Weblate instance up and running in seconds. All of Weblate's dependencies are already included. PostgreSQL is set up as the default database and Valkey as a caching backend.
硬體要求¶
Weblate should run on any contemporary hardware without problems, the following is the minimal configuration required to run Weblate on a single host (Weblate, database and web server):
3 GB 的記憶體
2 CPU 核心
1 GB 的儲存空間
備註
根據 Weblate 中管理的翻譯大小,安裝 Weblate 的實際要求差異很大。
記憶體使用情況¶
The more memory the better - it is used for caching on all levels (file system, database and Weblate). For hundreds of translation components, at least 4 GB of RAM is recommended.
提示
For systems with less memory than recommended, Single-process Celery setup is recommended.
CPU 使用¶
大量並行使用者會提高需要的 CPU 核心數。
儲存空間使用¶
The typical database storage usage is around 300 MB per 1 million hosted words.
Storage space needed for cloned repositories varies, but Weblate tries to keep their size minimal by doing shallow clones.
Nodes¶
For small and medium-sized sites (millions of hosted words), all Weblate components (see 架構概覽) can be run on a single node.
When you grow to hundreds of millions of hosted words, it is recommended to have a dedicated node for database (see Weblate 的資料庫設定).
安裝¶
提示
以下範例假設您擁有一個正常運作的 Docker 環境,並安裝了 docker-compose。請查看 Docker 說明文件以取得說明。
This creates a Weblate deployment server via HTTP, so you should place it behind HTTPS terminating proxy. You can also deploy with a HTTPS proxy, see 使用 Let’s Encrypt 自動產生 SSL 憑證. For larger setups, please see 平行擴充.
複製 weblate-docker 儲存庫:
git clone https://github.com/WeblateOrg/docker-compose.git weblate-docker cd weblate-docker
建立一個
docker-compose.override.yml檔案並調整為您所需的設定。參閱 Docker 環境變數 瞭解更多相關設定參數。services: weblate: image: weblate/weblate:latest environment: WEBLATE_EMAIL_HOST: smtp.example.com WEBLATE_EMAIL_HOST_USER: user WEBLATE_EMAIL_HOST_PASSWORD: pass WEBLATE_SERVER_EMAIL: weblate@example.com WEBLATE_DEFAULT_FROM_EMAIL: weblate@example.com WEBLATE_SITE_DOMAIN: weblate.example.com WEBLATE_ADMIN_PASSWORD: password for the admin user WEBLATE_ADMIN_EMAIL: weblate.admin@example.com ports: - 80:8080
備註
如果未設定
WEBLATE_ADMIN_PASSWORD,則使用首次啟動時顯示的隨機密碼建立管理員使用者。提供的範例使 Weblate 偵聽連接埠 80,在
docker-compose.override.yml檔案中編輯連接埠映射來變更。啟動 Weblate 容器:
docker compose up
享受您的 Weblate 部署,可以在 weblate 容器的連接埠 80 上進行存取。
選擇 Docker 映像註冊表¶
Weblate containers are published to following registries:
Docker Hub,請參閱 https://hub.docker.com/r/weblate/weblate
GitHub 套件註冊表,請參閱 https://github.com/WeblateOrg/docker/pkgs/container/weblate
備註
All examples currently fetch images from Docker Hub, please adjust the configuration accordingly to use a different registry.
選擇 Docker 映像標籤¶
Please choose a tag that matches your environment and expectations:
標籤名稱 |
描述 |
用例 |
|---|---|---|
|
Weblate 穩定版本,符合最新版本的發佈 |
在正式環境中滾動式更新 |
|
Weblate 穩定版本 |
Rolling updates within a calendar year in a production environment |
|
Weblate 穩定版本 |
Rolling updates within a monthly release in a production environment |
|
Weblate 穩定版本 |
明確定義其佈署版本於正式環境中 |
|
基於 Weblate 穩定版本作開發修正於 Docker 容器(例如更新依賴套件) |
滾動式更新於暫存環境中 |
|
基於 Weblate 穩定版本作開發修正於 Docker 容器(例如更新依賴套件) |
明確定義其佈署版本於暫存環境中 |
|
依 Git 上的 Weblate 開發版本 |
Rolling updates to test upcoming Weblate features |
|
依 Git 上的 Weblate 開發版本 |
明確定義其佈署版本來設定即將發佈的 Weblate 功能 |
Every image is tested by our CI before it gets published, so even the bleeding version should be quite safe to use.
Full list of published tags can be found at GitHub Packages
具有 HTTPS 支援的 Docker 容器¶
請參閱 安裝 以取得常規部署說明,本節僅提及與之相比的差異。
SSL terminating proxy¶
SSL can be terminated outside Weblate container. To make this work well together, several headers need to be passed to the container so that it is aware of its actual environment. In more detail, these headers are described in 在反向代理後面執行.
location / {
proxy_pass http://127.0.0.1:8080;
proxy_read_timeout 3600s;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-Proto https;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Host $server_name;
}
WEBLATE_ENABLE_HTTPS=1
WEBLATE_IP_PROXY_HEADER=HTTP_X_FORWARDED_FOR
使用自己的 SSL 憑證¶
如果您要使用自己的 SSL 憑證,只需將檔案放入 Weblate 資料儲存區中(請參閱 Docker 容器 volumes):
ssl/fullchain.pem包含憑證,包括任何需要的 CA 憑證ssl/privkey.pem包含有私鑰
擁有這兩個檔案的使用者必須與啟動 docker 容器並將檔案遮罩設定為 600 (僅擁有使用者可讀可寫)的使用者為同一使用者。
此外,Weblate 容器現在將在連接埠 4443 上接受 SSL 連接,您將要在 docker compose override 中包括 HTTPS 的連接埠轉發:
version: '3'
services:
weblate:
ports:
- 80:8080
- 443:4443
如果您已經在同一伺服器上託管其他站點,則反向代理(例如 NGINX )可能會使用連接埠 80 和 443。要將 HTTPS 連線從 NGINX 傳遞到 docker 容器,可以使用以下配置:
server {
listen 443 ssl;
listen [::]:443 ssl;
server_name <SITE_URL>;
ssl_certificate /etc/letsencrypt/live/<SITE>/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/<SITE>/privkey.pem;
location / {
proxy_set_header HOST $host;
proxy_set_header X-Forwarded-Proto https;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Host $server_name;
proxy_pass https://127.0.0.1:<EXPOSED_DOCKER_PORT>;
}
}
將 <SITE_URL>,<SITE> 和 <EXPOSED_DOCKER_PORT> 替換為您環境中的實際值。
使用 Let’s Encrypt 自動產生 SSL 憑證¶
In case you want to use Let’s Encrypt
automatically generated SSL certificates on public installation, you need to
add a reverse HTTPS proxy an additional Docker container, https-portal will be used for that.
This is made use of in the docker-compose-https.yml file. Then create
a docker-compose-https.override.yml file with your settings:
version: '3'
services:
weblate:
environment:
WEBLATE_EMAIL_HOST: smtp.example.com
WEBLATE_EMAIL_HOST_USER: user
WEBLATE_EMAIL_HOST_PASSWORD: pass
WEBLATE_SITE_DOMAIN: weblate.example.com
WEBLATE_ADMIN_PASSWORD: password for admin user
https-portal:
environment:
DOMAINS: 'weblate.example.com -> http://weblate:8080'
每當呼叫 docker compose 時,您都需要將兩個檔案都傳遞給它,然後執行以下操作:
docker compose -f docker-compose-https.yml -f docker-compose-https.override.yml build
docker compose -f docker-compose-https.yml -f docker-compose-https.override.yml up
升級 Docker 容器¶
通常,只更新 Weblate 容器並保持 PostgreSQL 容器為您的版本是一個好主意,因為升級 PostgreSQL 會很痛苦,並且在大多數情況下不會帶來很多好處。
您可以通過堅持使用現有的 docker-compose,並且只是拉取最新映像,然後重新啟動,來執行此操作:
# Fetch latest versions of the images
docker compose pull
# Stop and destroy the containers
docker compose down
# Spawn new containers in the background
docker compose up -d
# Follow the logs during upgrade
docker compose logs -f
Weblate 資料庫應在首次啟動時自動遷移,並且不需要其他手動操作。
備註
Direct upgrades are only supported for releases from the current or previous calendar year. If you need to upgrade from an older release, upgrade first to an intermediate version listed in 版本特定說明.
You might also want to update the docker-compose repository, though it's
not needed in most case. See 升級 PostgreSQL 容器 for upgrading the PostgreSQL server.
升級 PostgreSQL 容器¶
備註
PostgreSQL 18 changed the default data directory inside the container. A
common older setup mounted the database volume at
/var/lib/postgresql/data, while PostgreSQL 18 now uses
/var/lib/postgresql by default.
If you are upgrading from an older version, either update the mount target
in your Docker configuration to the new path, or keep the old mount target
and set PGDATA accordingly.
Leaving the old mount target unchanged without setting PGDATA can cause
PostgreSQL to write its data outside the persisted volume.
See PGDATA documentation for more information.
PostgreSQL containers do not support automatic upgrading between version, you need to perform the upgrade manually. Following steps show one of the options of upgrading.
停止 Weblate 容器:
docker compose stop weblate cache
備份資料庫:
docker compose exec database pg_dumpall --clean --if-exists --username weblate > backup.sql
停止資料庫容器:
docker compose stop database
移除 PostgreSQL volume:
docker compose rm -v database docker volume remove weblate-docker_postgres-data
提示
The volume name contains name of the Docker Compose project, which is by default the directory name what is
weblate-dockerin this documentation.調整
docker-compose.yml以使用新的 PostgreSQL 版本。啟動資料庫容器:
docker compose up -d database
從備份中恢復資料庫:
cat backup.sql | docker compose exec -T database psql --username weblate --dbname weblate
提示
Please check that the database name matches
POSTGRES_DB.(Optional) Update password for the Weblate user. This might be needed when migrating to PostgreSQL 14 or 15 as way of storing passwords has been changed:
docker compose exec -T database psql --username weblate --dbname weblate -c "ALTER USER weblate WITH PASSWORD 'weblate'"
提示
Please check that the database name matches
POSTGRES_DB.啟動所有剩下的容器:
docker compose up -d
系統管理員登入¶
設定容器之後,您可以使用 WEBLATE_ADMIN_PASSWORD 中提供的密碼以 管理員 使用者身分登入,或者如果未設定該密碼,則在首次啟動時產生隨機密碼。
要重設 管理員 密碼,請在 WEBLATE_ADMIN_PASSWORD 設定為新密碼的情況下重啟容器。
程式數量和記憶體消耗¶
The number of worker processes for both WSGI and Celery is determined automatically based on number of CPUs. This works well for most cloud virtual machines as these typically have few CPUs and good amount of memory.
在您有很多 CPU 核心並且碰到記憶體用盡問題情況下,嘗試減少 worker 的數量:
environment:
WEBLATE_WORKERS: 2
您還可以微調單個 worker 類別:
environment:
WEB_WORKERS: 4
CELERY_MAIN_OPTIONS: --concurrency 2
CELERY_NOTIFY_OPTIONS: --concurrency 1
CELERY_TRANSLATE_OPTIONS: --concurrency 1
Memory usage can be further reduced by running only a single Celery process:
environment:
CELERY_SINGLE_PROCESS: 1
平行擴充¶
在 4.6 版被加入.
You can run multiple Weblate containers to scale the service horizontally. The
/app/data volume has to be shared by all containers, it is recommended
to use cluster filesystem such as GlusterFS for this. The /app/cache
volume should be separate for each container.
Each Weblate container has defined role using WEBLATE_SERVICE
environment variable. Please follow carefully the documentation as some of the
services should be running just once in the cluster, and the order of the
services matters as well.
You can find example setup in the docker-compose repo as
docker-compose-split.yml.
Docker 環境變數¶
許多 Weblate 的 配置 可以透過環境變數設定到 Docker 容器中。
If you need to define a setting not exposed through Docker environment variables, see 環境變數以外的配置.
傳遞秘密¶
在 5.0 版被加入.
Weblate container supports passing secrets as files. To utilize that, append
_FILE suffix to the environment variable and pass secret file via Docker.
Related docker-compose.yml might look like:
services:
weblate:
environment:
POSTGRES_PASSWORD_FILE: /run/secrets/db_password
secrets:
- db_password
database:
environment:
POSTGRES_PASSWORD_FILE: /run/secrets/db_password
secrets:
- db_password
secrets:
db_password:
file: db_password.txt
通用設定¶
- WEBLATE_LOGLEVEL¶
Configures the logging verbosity. Set this to
DEBUGto get more detailed logs.Defaults to
INFOwhenWEBLATE_DEBUGis turned off,DEBUGis used when debug mode is turned on.For more silent logging use
ERRORorWARNING.
- WEBLATE_LOGLEVEL_DATABASE¶
Configures the logging of the database queries verbosity.
- WEBLATE_LOG_GELF_HOST¶
在 5.9 版被加入.
Configures remote logging using GELF TCP connection. Can be used to integrate with Graylog.
- WEBLATE_LOG_GELF_PORT¶
在 5.9 版被加入.
Use custom port for
WEBLATE_LOG_GELF_HOST, defaults to 12201.
- WEBLATE_SITE_TITLE¶
變更所有頁面頁眉上顯示的站點標題。
- WEBLATE_SITE_DOMAIN¶
Configures the site domain. This parameter is required.
Include port if using a non-standard one.
範例:
environment: WEBLATE_SITE_DOMAIN: example.com:8080
也參考
- WEBLATE_ADMIN_NAME¶
- WEBLATE_ADMIN_EMAIL¶
配置站點管理員的姓名和電子郵件。它用於
ADMINS設定和建立 管理員 使用者(有關此資訊,請參閱WEBLATE_ADMIN_PASSWORD)。範例:
environment: WEBLATE_ADMIN_NAME: Weblate admin WEBLATE_ADMIN_EMAIL: noreply@example.com
- WEBLATE_ADMIN_PASSWORD¶
設定 管理員 使用者的密碼。
如果未設定並且 管理員 使用者不存在,則會使用首次啟動容器時顯示的隨機密碼來建立它。
如果未設定並且 管理員 使用者存在,則不執行任何操作。
如果設定,則在每次容器啟動時都會對 管理員 使用者進行調整,以匹配
WEBLATE_ADMIN_PASSWORD,WEBLATE_ADMIN_NAME和WEBLATE_ADMIN_EMAIL。
警告
將密碼儲存在配置檔案中可能會帶來安全風險。考慮僅將此變數用於初始設定(或讓 Weblate 在初始啟動時產生隨機密碼)或用於密碼恢復。
- WEBLATE_ADMIN_NOTIFY_ERROR¶
Whether to send e-mail to admins upon server error. Turned on by default.
You might want to use other error collection like Sentry or Rollbar and turn this off.
- WEBLATE_SERVER_EMAIL¶
The email address that error messages are sent from.
也參考
- WEBLATE_DEFAULT_FROM_EMAIL¶
配置外發電子郵件的地址。
- WEBLATE_ADMINS_CONTACT¶
配置
ADMINS_CONTACT。
- WEBLATE_CONTACT_FORM¶
配置聯繫表單行為,請參閱
CONTACT_FORM。
- WEBLATE_ALLOWED_HOSTS¶
使用
ALLOWED_HOSTS配置允許的 HTTP 主機名。預設為
*來允許所有的主機名稱。範例:
environment: WEBLATE_ALLOWED_HOSTS: weblate.example.com,example.com
- WEBLATE_REGISTRATION_OPEN¶
通過切換
REGISTRATION_OPEN配置是否開啟註冊。範例:
environment: WEBLATE_REGISTRATION_OPEN: 0
- WEBLATE_REGISTRATION_CAPTCHA¶
在 5.10 版被加入.
Configures whether captcha is used for registration and other unauthenticated actions, see
REGISTRATION_CAPTCHA.範例:
environment: WEBLATE_REGISTRATION_CAPTCHA: 0
- WEBLATE_REGISTRATION_ALLOW_BACKENDS¶
配置可用於通過
REGISTRATION_ALLOW_BACKENDS建立新帳號的身分驗證方法。範例:
environment: WEBLATE_REGISTRATION_OPEN: 0 WEBLATE_REGISTRATION_ALLOW_BACKENDS: azuread-oauth2,azuread-tenant-oauth2
- WEBLATE_REGISTRATION_REBIND¶
在 4.16 版被加入.
- WEBLATE_REGISTRATION_ALLOW_DISPOSABLE_EMAILS¶
在 5.16.1 版被加入.
配置
REGISTRATION_ALLOW_DISPOSABLE_EMAILS。範例:
environment: WEBLATE_REGISTRATION_ALLOW_DISPOSABLE_EMAILS: 1
- WEBLATE_PROJECT_WEB_RESTRICT_PRIVATE¶
在 5.17 版被加入.
配置
PROJECT_WEB_RESTRICT_PRIVATE。預設為啟用。
- WEBLATE_WEBHOOK_RESTRICT_PRIVATE¶
在 5.17 版被加入.
預設為啟用。
- WEBLATE_WEBHOOK_PRIVATE_ALLOWLIST¶
在 5.17 版被加入.
- WEBLATE_ASSET_RESTRICT_PRIVATE¶
在 2025.5 版被加入.
Configures
ASSET_RESTRICT_PRIVATE.預設為啟用。
- WEBLATE_ASSET_PRIVATE_ALLOWLIST¶
在 2025.5 版被加入.
Configures
ASSET_PRIVATE_ALLOWLIST.
- WEBLATE_TIME_ZONE¶
在 Weblate 中配置使用的時區,請參閱
TIME_ZONE。備註
為了變更 Docker 自己的時區,使用
TZ環境變數。範例:
environment: WEBLATE_TIME_ZONE: Europe/Prague
- WEBLATE_ENABLE_HTTPS¶
讓 Weblate 假定在反向 HTTPS 代理後面操作,這使 Weblate 在電子郵件和 API 連結中使用 HTTPS,或者在 cookies 上設定安全標記。
提示
可能的警告請參閱
ENABLE_HTTPS說明文件。備註
這不會使 Weblate 容器接受 HTTPS 連線,您同樣需要配置它,範例請參閱 具有 HTTPS 支援的 Docker 容器。
範例:
environment: WEBLATE_ENABLE_HTTPS: 1
- WEBLATE_NGINX_IPV6¶
在 5.17 版被加入.
Controls whether the bundled NGINX listens on IPv6 addresses.
Supported values are:
autoto enable IPv6 listeners only when IPv6 is available in the container runtime. This is the default.onto always enable IPv6 listeners.offto disable IPv6 listeners.
範例:
environment: WEBLATE_NGINX_IPV6: auto
- WEBLATE_IP_PROXY_HEADER¶
讓 Weblate 從任何給定的 HTTP 標頭中取回 IP 地址。在使用 Weblate 容器之前的反向代理時使用它。
允許
IP_BEHIND_REVERSE_PROXY並設定IP_PROXY_HEADER。備註
格式必須符合 Django 的要求。 Django transforms 原始 HTTP 標頭如下命名:
將所有字元裝換為大寫
用下劃線替換任何連字元
前面新增
HTTP_前綴字
所以
X-Forwarded-For將被映射到HTTP_X_FORWARDED_FOR。範例:
environment: WEBLATE_IP_PROXY_HEADER: HTTP_X_FORWARDED_FOR
- WEBLATE_IP_PROXY_OFFSET¶
在 5.0.1 版被加入.
配置
IP_PROXY_OFFSET。
- WEBLATE_USE_X_FORWARDED_PORT¶
在 5.0.1 版被加入.
A boolean that specifies whether to use the X-Forwarded-Port header in preference to the SERVER_PORT META variable. This should only be enabled if a proxy which sets this header is in use.
備註
This is a boolean setting (use
"true"or"false").
- WEBLATE_SECURE_PROXY_SSL_HEADER¶
A tuple representing an HTTP header/value combination that signifies a request is secure. This is needed when Weblate is running behind a reverse proxy doing SSL termination which does not pass standard HTTPS headers.
範例:
environment: WEBLATE_SECURE_PROXY_SSL_HEADER: HTTP_X_FORWARDED_PROTO,https
- WEBLATE_REQUIRE_LOGIN¶
啟用
REQUIRE_LOGIN而在整個 Weblate 上強制認證。範例:
environment: WEBLATE_REQUIRE_LOGIN: 1
- WEBLATE_LEGAL_INTEGRATION¶
Enables the 法律模組 module in Docker deployments. By default, the integration is disabled; leave this variable unset or empty to disable it.
Supported values are:
tos-confirmto enable the legal module and enforce terms of service confirmation during social authentication and for signed-in users.wllegalto enable the same integration and additionally load the hosted legal document templates fromwllegal. These templates are used by services operated by Weblate s.r.o. and are not intended for general use.
To provide your own legal documents in Docker, override the templates in
/app/data/python/customize/templates/legal/documents, see 替換 logo 和其它靜態檔案.範例:
environment: WEBLATE_LEGAL_INTEGRATION: tos-confirm
也參考
- WEBLATE_PUBLIC_ENGAGE¶
啟用
PUBLIC_ENGAGE。
- WEBLATE_GOOGLE_ANALYTICS_ID¶
通過
GOOGLE_ANALYTICS_ID來配置用於 Google Analytics 的 ID。
- WEBLATE_DEFAULT_PULL_MESSAGE¶
Configures the default title and message for pull requests via API by changing
DEFAULT_PULL_MESSAGE.
- WEBLATE_SIMPLIFY_LANGUAGES¶
配置語言簡化策略,請參閱
SIMPLIFY_LANGUAGES。
- WEBLATE_HIDE_SHARED_GLOSSARY_COMPONENTS¶
Hides glossary components when shared to other projects, see
HIDE_SHARED_GLOSSARY_COMPONENTS.
- WEBLATE_DEFAULT_ACCESS_CONTROL¶
為新專案配置預設的 存取控制,請參閱
DEFAULT_ACCESS_CONTROL。
- WEBLATE_DEFAULT_TRANSLATION_REVIEW¶
在 5.16 版被加入.
Configures the default value for 啟用檢閱, turned off by default.
- WEBLATE_DEFAULT_SOURCE_REVIEW¶
在 5.16 版被加入.
Configures the default value for 啟用來源檢閱, turned off by default.
- WEBLATE_DEFAULT_RESTRICTED_COMPONENT¶
為新組件的 受限制的存取 配置預設值,請參閱
DEFAULT_RESTRICTED_COMPONENT。
- WEBLATE_DEFAULT_TRANSLATION_PROPAGATION¶
為新組件的 允許翻譯再用 配置預設值,請參閱
DEFAULT_TRANSLATION_PROPAGATION。
- WEBLATE_DEFAULT_COMMITER_EMAIL¶
- WEBLATE_DEFAULT_COMMITER_NAME¶
- WEBLATE_DEFAULT_SHARED_TM¶
- WEBLATE_DEFAULT_AUTOCLEAN_TM¶
- WEBLATE_COMMIT_PENDING_HOURS¶
Configures the default value for 變更後提交的經過時間 for new components, see
COMMIT_PENDING_HOURS.
- WEBLATE_GPG_IDENTITY¶
配置提交的 GPG 簽名,請參閱
WEBLATE_GPG_IDENTITY。
- WEBLATE_URL_PREFIX¶
配置 Weblate 執行的 URL 前綴,請參閱
URL_PREFIX。
- WEBLATE_SILENCED_SYSTEM_CHECKS¶
配置您不想要顯示的檢查,請參閱
SILENCED_SYSTEM_CHECKS。
- WEBLATE_CSP_SCRIPT_SRC¶
- WEBLATE_CSP_IMG_SRC¶
- WEBLATE_CSP_CONNECT_SRC¶
- WEBLATE_CSP_STYLE_SRC¶
- WEBLATE_CSP_FONT_SRC¶
- WEBLATE_CSP_FORM_SRC¶
Allows to customize Content-Security-Policy HTTP header.
- WEBLATE_LICENSE_FILTER¶
配置
LICENSE_FILTER.
- WEBLATE_LICENSE_REQUIRED¶
配置
LICENSE_REQUIRED。
- WEBLATE_WEBSITE_REQUIRED¶
配置
WEBSITE_REQUIRED。
- WEBLATE_VERSION_DISPLAY¶
配置
VERSION_DISPLAY。
- WEBLATE_HIDE_VERSION¶
配置
HIDE_VERSION。
- WEBLATE_BASIC_LANGUAGES¶
配置
BASIC_LANGUAGES.
- WEBLATE_DEFAULT_AUTO_WATCH¶
- WEBLATE_RATELIMIT_ATTEMPTS¶
- WEBLATE_RATELIMIT_LOCKOUT¶
- WEBLATE_RATELIMIT_WINDOW¶
在 4.6 版被加入.
配置速率限制器。
提示
You can set configuration for any rate limiter scopes. To do that add
WEBLATE_prefix to any of setting described in 速率限制.
- WEBLATE_API_RATELIMIT_ANON¶
- WEBLATE_API_RATELIMIT_USER¶
在 4.11 版被加入.
Configures API rate limiting. Defaults to
100/dayfor anonymous and5000/hourfor authenticated users.也參考
- WEBLATE_ENABLE_HOOKS¶
在 4.13 版被加入.
配置
ENABLE_HOOKS。
- WEBLATE_ENABLE_AVATARS¶
在 4.6.1 版被加入.
配置
ENABLE_AVATARS.
- WEBLATE_AVATAR_URL_PREFIX¶
在 4.15 版被加入.
- WEBLATE_LIMIT_TRANSLATION_LENGTH_BY_SOURCE_LENGTH¶
在 4.9 版被加入.
- WEBLATE_SSH_EXTRA_ARGS¶
在 4.9 版被加入.
配置
SSH_EXTRA_ARGS。
- WEBLATE_BORG_EXTRA_ARGS¶
在 4.9 版被加入.
Configures
BORG_EXTRA_ARGSas a comma separated list of args.範例:
environment: WEBLATE_BORG_EXTRA_ARGS: --exclude,vcs/
- WEBLATE_ENABLE_SHARING¶
在 4.14.1 版被加入.
配置
ENABLE_SHARING。
- WEBLATE_SUPPORT_STATUS_CHECK¶
在 5.5 版被加入.
- WEBLATE_EXTRA_HTML_HEAD¶
在 4.15 版被加入.
配置
EXTRA_HTML_HEAD。
- WEBLATE_PRIVATE_COMMIT_EMAIL_TEMPLATE¶
在 4.15 版被加入.
- WEBLATE_PRIVATE_COMMIT_EMAIL_OPT_IN¶
在 4.15 版被加入.
- WEBLATE_PRIVATE_COMMIT_NAME_TEMPLATE¶
在 5.16 版被加入.
- WEBLATE_PRIVATE_COMMIT_NAME_OPT_IN¶
在 5.16 版被加入.
- WEBLATE_UNUSED_ALERT_DAYS¶
在 4.17 版被加入.
- WEBLATE_UPDATE_LANGUAGES¶
在 4.3.2 版被加入.
配置
UPDATE_LANGUAGES。
- WEBLATE_VCS_ALLOW_HOSTS¶
在 5.15 版被加入.
配置
VCS_ALLOW_HOSTS。
- WEBLATE_VCS_ALLOW_SCHEMES¶
在 5.15 版被加入.
- WEBLATE_VCS_RESTRICT_PRIVATE¶
在 5.17 版被加入.
- WEBLATE_VCS_CLONE_DEPTH¶
在 5.4 版被加入.
配置
VCS_CLONE_DEPTH。
- WEBLATE_VCS_API_DELAY¶
在 5.4 版被加入.
配置
VCS_API_DELAY。
- WEBLATE_VCS_API_TIMEOUT¶
在 5.15 版被加入.
配置
VCS_API_TIMEOUT。
- WEBLATE_CORS_ALLOWED_ORIGINS¶
在 4.16 版被加入.
Allow CORS requests to API from given origins.
範例:
environment: WEBLATE_CORS_ALLOWED_ORIGINS: https://example.com,https://weblate.org
- WEBLATE_CORS_ALLOW_ALL_ORIGINS¶
在 5.6.1 版被加入: Allows CORS requests to API from all origins.
- WEBLATE_WEBSITE_ALERTS_ENABLED¶
在 5.17 版被加入.
- CLIENT_MAX_BODY_SIZE¶
在 4.16.3 版被加入.
Configures maximal body size accepted by the built-in web server.
environment: CLIENT_MAX_BODY_SIZE: 200m
提示
This variable intentionally lacks
WEBLATE_prefix as it is shared with third-party container used in 使用 Let’s Encrypt 自動產生 SSL 憑證.
Code hosting sites credentials¶
In the Docker container, the code hosting credentials can be configured either in separate variables or using a Python dictionary to set them at once. The following examples are for GitHub 拉取請求, but apply to all 版本控制整合 with appropriately changed variable names.
重要
All environment variable names must include the WEBLATE_ prefix. For example,
to configure GitHub credentials, use WEBLATE_GITHUB_USERNAME, not GITHUB_USERNAME.
This applies whether you're configuring for pull requests or any other VCS integration.
An example configuration for GitHub pull requests might look like:
WEBLATE_GITHUB_USERNAME=api-user
WEBLATE_GITHUB_TOKEN=api-token
WEBLATE_GITHUB_HOST=api.github.com
Will be used as:
GITHUB_CREDENTIALS = {
"api.github.com": {
"username": "api-user",
"token": "api-token",
}
}
Alternatively the Python dictionary can be provided as a string:
WEBLATE_GITHUB_CREDENTIALS='{ "api.github.com": { "username": "api-user", "token": "api-token", } }'
Or the path to a file containing the Python dictionary:
echo '{ "api.github.com": { "username": "api-user", "token": "api-token", } }' > /path/to/github-credentials
WEBLATE_GITHUB_CREDENTIALS_FILE='/path/to/github-credentials'
- WEBLATE_GITHUB_USERNAME¶
- WEBLATE_GITHUB_TOKEN¶
- WEBLATE_GITHUB_HOST¶
- WEBLATE_GITHUB_CREDENTIALS¶
Configures GitHub 拉取請求 by changing
GITHUB_CREDENTIALS.
- WEBLATE_GITLAB_USERNAME¶
- WEBLATE_GITLAB_TOKEN¶
- WEBLATE_GITLAB_HOST¶
- WEBLATE_GITLAB_CREDENTIALS¶
Configures GitLab 合併請求 by changing
GITLAB_CREDENTIALS.
- WEBLATE_GITEA_USERNAME¶
- WEBLATE_GITEA_TOKEN¶
- WEBLATE_GITEA_HOST¶
- WEBLATE_GITEA_CREDENTIALS¶
Configures Gitea 拉取請求 by changing
GITEA_CREDENTIALS.
- WEBLATE_PAGURE_USERNAME¶
- WEBLATE_PAGURE_TOKEN¶
- WEBLATE_PAGURE_HOST¶
- WEBLATE_PAGURE_CREDENTIALS¶
Configures Pagure 合併請求 by changing
PAGURE_CREDENTIALS.
- WEBLATE_BITBUCKETSERVER_USERNAME¶
- WEBLATE_BITBUCKETSERVER_TOKEN¶
- WEBLATE_BITBUCKETSERVER_HOST¶
- WEBLATE_BITBUCKETSERVER_CREDENTIALS¶
Configures Bitbucket Data Center pull requests by changing
BITBUCKETSERVER_CREDENTIALS.
- WEBLATE_BITBUCKETCLOUD_USERNAME¶
- WEBLATE_BITBUCKETCLOUD_WORKSPACE¶
- WEBLATE_BITBUCKETCLOUD_TOKEN¶
- WEBLATE_BITBUCKETCLOUD_HOST¶
- WEBLATE_BITBUCKETCLOUD_CREDENTIALS¶
Configures Bitbucket Cloud 拉取請求 by changing
BITBUCKETCLOUD_CREDENTIALS.
- WEBLATE_AZURE_DEVOPS_USERNAME¶
- WEBLATE_AZURE_DEVOPS_ORGANIZATION¶
- WEBLATE_AZURE_DEVOPS_TOKEN¶
- WEBLATE_AZURE_DEVOPS_HOST¶
- WEBLATE_AZURE_DEVOPS_CREDENTIALS¶
Configures Azure DevOps 拉取請求 by changing
AZURE_DEVOPS_CREDENTIALS.
自動建議設定¶
在 4.13 版的變更: Automatic suggestion services are now configured in the user interface, see 自動建議.
The existing environment variables are imported during the migration to Weblate 4.13, but changing them will not have any further effect.
身分驗證設定¶
提示
The e-mail based authentication is turned on unless disabled by WEBLATE_NO_EMAIL_AUTH.
LDAP¶
- WEBLATE_AUTH_LDAP_SERVER_URI¶
- WEBLATE_AUTH_LDAP_USER_DN_TEMPLATE¶
- WEBLATE_AUTH_LDAP_USER_ATTR_MAP¶
- WEBLATE_AUTH_LDAP_BIND_DN¶
- WEBLATE_AUTH_LDAP_BIND_PASSWORD¶
- WEBLATE_AUTH_LDAP_CONNECTION_OPTION_REFERRALS¶
- WEBLATE_AUTH_LDAP_USER_SEARCH¶
- WEBLATE_AUTH_LDAP_USER_SEARCH_FILTER¶
- WEBLATE_AUTH_LDAP_USER_SEARCH_UNION¶
- WEBLATE_AUTH_LDAP_USER_SEARCH_UNION_DELIMITER¶
LDAP authentication configuration.
直接綁定範例:
environment: WEBLATE_AUTH_LDAP_SERVER_URI: ldap://ldap.example.org WEBLATE_AUTH_LDAP_USER_DN_TEMPLATE: uid=%(user)s,ou=People,dc=example,dc=net # map weblate 'full_name' to ldap 'name' and weblate 'email' attribute to 'mail' ldap attribute. # another example that can be used with OpenLDAP: 'full_name:cn,email:mail' WEBLATE_AUTH_LDAP_USER_ATTR_MAP: full_name:name,email:mail
搜尋與綁定範例:
environment: WEBLATE_AUTH_LDAP_SERVER_URI: ldap://ldap.example.org WEBLATE_AUTH_LDAP_BIND_DN: CN=ldap,CN=Users,DC=example,DC=com WEBLATE_AUTH_LDAP_BIND_PASSWORD: password WEBLATE_AUTH_LDAP_USER_ATTR_MAP: full_name:name,email:mail WEBLATE_AUTH_LDAP_USER_SEARCH: CN=Users,DC=example,DC=com
聯合搜尋與綁定範例:
environment: WEBLATE_AUTH_LDAP_SERVER_URI: ldap://ldap.example.org WEBLATE_AUTH_LDAP_BIND_DN: CN=ldap,CN=Users,DC=example,DC=com WEBLATE_AUTH_LDAP_BIND_PASSWORD: password WEBLATE_AUTH_LDAP_USER_ATTR_MAP: full_name:name,email:mail WEBLATE_AUTH_LDAP_USER_SEARCH_UNION: ou=users,dc=example,dc=com|ou=otherusers,dc=example,dc=com
針對作用中的目錄的搜尋與綁定範例:
environment: WEBLATE_AUTH_LDAP_BIND_DN: CN=ldap,CN=Users,DC=example,DC=com WEBLATE_AUTH_LDAP_BIND_PASSWORD: password WEBLATE_AUTH_LDAP_SERVER_URI: ldap://ldap.example.org WEBLATE_AUTH_LDAP_CONNECTION_OPTION_REFERRALS: 0 WEBLATE_AUTH_LDAP_USER_ATTR_MAP: full_name:name,email:mail WEBLATE_AUTH_LDAP_USER_SEARCH: CN=Users,DC=example,DC=com WEBLATE_AUTH_LDAP_USER_SEARCH_FILTER: (sAMAccountName=%(user)s)
GitHub¶
- WEBLATE_SOCIAL_AUTH_GITHUB_KEY¶
- WEBLATE_SOCIAL_AUTH_GITHUB_SECRET¶
- WEBLATE_SOCIAL_AUTH_GITHUB_ORG_KEY¶
- WEBLATE_SOCIAL_AUTH_GITHUB_ORG_SECRET¶
- WEBLATE_SOCIAL_AUTH_GITHUB_ORG_NAME¶
- WEBLATE_SOCIAL_AUTH_GITHUB_TEAM_KEY¶
- WEBLATE_SOCIAL_AUTH_GITHUB_TEAM_SECRET¶
GitHub 企業版¶
- WEBLATE_SOCIAL_AUTH_GITHUB_ENTERPRISE_KEY¶
- WEBLATE_SOCIAL_AUTH_GITHUB_ENTERPRISE_SECRET¶
- WEBLATE_SOCIAL_AUTH_GITHUB_ENTERPRISE_URL¶
- WEBLATE_SOCIAL_AUTH_GITHUB_ENTERPRISE_API_URL¶
- WEBLATE_SOCIAL_AUTH_GITHUB_ENTERPRISE_SCOPE¶
允許 GitHub EE 身分驗證。
Bitbucket¶
- WEBLATE_SOCIAL_AUTH_BITBUCKET_OAUTH2_KEY¶
- WEBLATE_SOCIAL_AUTH_BITBUCKET_OAUTH2_SECRET¶
允許 Butbucket 驗證。
Facebook¶
- WEBLATE_SOCIAL_AUTH_FACEBOOK_KEY¶
- WEBLATE_SOCIAL_AUTH_FACEBOOK_SECRET¶
允許 Facebook OAuth 2.
Google¶
- WEBLATE_SOCIAL_AUTH_GOOGLE_OAUTH2_KEY¶
- WEBLATE_SOCIAL_AUTH_GOOGLE_OAUTH2_SECRET¶
- WEBLATE_SOCIAL_AUTH_GOOGLE_OAUTH2_WHITELISTED_DOMAINS¶
- WEBLATE_SOCIAL_AUTH_GOOGLE_OAUTH2_WHITELISTED_EMAILS¶
允許 Google OAuth 2。
GitLab¶
- WEBLATE_SOCIAL_AUTH_GITLAB_KEY¶
- WEBLATE_SOCIAL_AUTH_GITLAB_SECRET¶
- WEBLATE_SOCIAL_AUTH_GITLAB_API_URL¶
允許 GitLab OAuth 2。
Gitea¶
- WEBLATE_SOCIAL_AUTH_GITEA_API_URL¶
- WEBLATE_SOCIAL_AUTH_GITEA_KEY¶
- WEBLATE_SOCIAL_AUTH_GITEA_SECRET¶
啟用 Gitea 身分驗證。
Microsoft Entra ID¶
- WEBLATE_SOCIAL_AUTH_AZUREAD_OAUTH2_KEY¶
- WEBLATE_SOCIAL_AUTH_AZUREAD_OAUTH2_SECRET¶
啟用 Microsoft Entra ID 身分驗證,請參閱 Microsoft Entra ID。
支援 Tenant 的 Microsoft Entra ID¶
- WEBLATE_SOCIAL_AUTH_AZUREAD_TENANT_OAUTH2_KEY¶
- WEBLATE_SOCIAL_AUTH_AZUREAD_TENANT_OAUTH2_SECRET¶
- WEBLATE_SOCIAL_AUTH_AZUREAD_TENANT_OAUTH2_TENANT_ID¶
啟用支援 Tenant 的 Microsoft Entra ID,請參閱 Microsoft Entra ID。
Keycloak¶
- WEBLATE_SOCIAL_AUTH_KEYCLOAK_KEY¶
- WEBLATE_SOCIAL_AUTH_KEYCLOAK_SECRET¶
- WEBLATE_SOCIAL_AUTH_KEYCLOAK_PUBLIC_KEY¶
- WEBLATE_SOCIAL_AUTH_KEYCLOAK_ALGORITHM¶
- WEBLATE_SOCIAL_AUTH_KEYCLOAK_AUTHORIZATION_URL¶
- WEBLATE_SOCIAL_AUTH_KEYCLOAK_ACCESS_TOKEN_URL¶
- WEBLATE_SOCIAL_AUTH_KEYCLOAK_TITLE¶
- WEBLATE_SOCIAL_AUTH_KEYCLOAK_IMAGE¶
啟用 Keycloak 身分驗證,請參閱 Keycloak - Open Source Red Hat SSO。
- WEBLATE_SOCIAL_AUTH_KEYCLOAK_ID_KEY¶
在 5.17 版被加入.
Configures which claim is used as the unique user identifier from Keycloak. Defaults to
email.提示
When Keycloak is configured to abstract third-party IDP, you will need to configure
WEBLATE_CSP_FORM_SRCfor the third-party IDP domain.Example when Keycloak is passing authentication to Microsoft.¶environment: WEBLATE_CSP_FORM_SRC: login.microsoftonline.com
Linux 供應商¶
您可以通過將後面的變數設定為任何值,使用 Linux 銷售商身分驗證服務來允許身分驗證。
- WEBLATE_SOCIAL_AUTH_FEDORA¶
- WEBLATE_SOCIAL_AUTH_OPENSUSE¶
- WEBLATE_SOCIAL_AUTH_OPENINFRA¶
- WEBLATE_SOCIAL_AUTH_UBUNTU¶
Slack¶
- WEBLATE_SOCIAL_AUTH_SLACK_KEY¶
OpenID 連結¶
在 4.13-1 版被加入.
- WEBLATE_SOCIAL_AUTH_OIDC_OIDC_ENDPOINT¶
- WEBLATE_SOCIAL_AUTH_OIDC_KEY¶
- WEBLATE_SOCIAL_AUTH_OIDC_SECRET¶
- WEBLATE_SOCIAL_AUTH_OIDC_USERNAME_KEY¶
- WEBLATE_SOCIAL_AUTH_OIDC_TITLE¶
- WEBLATE_SOCIAL_AUTH_OIDC_IMAGE¶
Configures generic OpenID Connect integration.
Fedora OpenID Connect¶
在 5.15 版被加入.
- WEBLATE_SOCIAL_AUTH_FEDORA_OIDC_KEY¶
SAML¶
在第一次啟動容器時自動產生自簽名的 SAML 金鑰。在您想要使用自己的金鑰的情況下,將憑證和私鑰放置在 /app/data/ssl/saml.crt 和 /app/data/ssl/saml.key 中。
- WEBLATE_SAML_IDP_ENTITY_ID¶
- WEBLATE_SAML_IDP_URL¶
- WEBLATE_SAML_IDP_X509CERT¶
- WEBLATE_SAML_IDP_IMAGE¶
- WEBLATE_SAML_ID_ATTR_FULL_NAME¶
- WEBLATE_SAML_ID_ATTR_FIRST_NAME¶
- WEBLATE_SAML_ID_ATTR_LAST_NAME¶
- WEBLATE_SAML_ID_ATTR_USERNAME¶
- WEBLATE_SAML_ID_ATTR_EMAIL¶
- WEBLATE_SAML_ID_ATTR_USER_PERMANENT_ID¶
在 4.18 版被加入.
SAML attributes mapping.
其他身分驗證設定¶
PostgreSQL 資料庫設定¶
資料庫由 docker-compose.yml 建立,所以這些設定影響 Weblate 和 PostgreSQL 容器。
也參考
- POSTGRES_USER¶
PostgreSQL 使用者名。
- POSTGRES_DB¶
PostgreSQL 資料庫名稱。
- POSTGRES_HOST¶
PostgreSQL 伺服器主機名成或 IP 地址。預設為
database。
- POSTGRES_PORT¶
PostgreSQL 伺服器連接埠。預設為無(使用預設值)。
- POSTGRES_SSL_MODE¶
Configure how PostgreSQL handles SSL in connection to the server, for possible choices see SSL Mode Descriptions.
- POSTGRES_ALTER_ROLE¶
Configures name of the PostgreSQL role to alter during the database migration, see 配置 Weblate 來使用 PostgreSQL.
預設為
POSTGRES_USER。
- POSTGRES_CONN_MAX_AGE¶
在 4.8.1 版被加入.
The lifetime of a database connection, as an integer of seconds. Use 0 to close database connections at the end of each request.
在 5.1 版的變更: The default behavior is to have unlimited persistent database connections.
Enabling connection persistence will typically, cause more open connection to the database. Please adjust your database configuration prior enabling.
配置範例:
environment: POSTGRES_CONN_MAX_AGE: 3600
- POSTGRES_DISABLE_SERVER_SIDE_CURSORS¶
在 4.9.1 版被加入.
Disable server side cursors in the database. This is necessary in some pgbouncer setups.
配置範例:
environment: POSTGRES_DISABLE_SERVER_SIDE_CURSORS: 1
- WEBLATE_DATABASES¶
在 5.1 版被加入.
Set to false to disable environment based configuration of the database connection. Use 資料 volume 的覆寫設定 to configure the database connection manually.
資料庫備份設定¶
也參考
- WEBLATE_DATABASE_BACKUP¶
使用
DATABASE_BACKUP配置每日資料庫傾印。預設為plain。
資料儲存伺服器設定¶
Using Valkey or Redis is required by the Weblate container and you have to provide a connection parameters when running Weblate in Docker.
也參考
- REDIS_HOST¶
資料儲存伺服器主機名稱或 IP 位址。預設為
cache。
- REDIS_PORT¶
資料儲存伺服器連接埠。預設為
6379。
- REDIS_DB¶
資料儲存資料庫編號,預設為
1。
- REDIS_USER¶
在 5.13 版被加入: 資料儲存資料庫使用者,預設不使用。
- REDIS_TLS¶
啟用對資料儲存連線使用 SSL。
- REDIS_VERIFY_SSL¶
可用於為資料儲存連線停用 SSL 憑證驗證。
郵件伺服器設定¶
要使外發電子郵件正常工作,您需要提供一個郵件伺服器。
TLS 設定範例:
environment:
WEBLATE_EMAIL_HOST: smtp.example.com
WEBLATE_EMAIL_HOST_USER: user
WEBLATE_EMAIL_HOST_PASSWORD: pass
SSL 設定範例:
environment:
WEBLATE_EMAIL_HOST: smtp.example.com
WEBLATE_EMAIL_PORT: 465
WEBLATE_EMAIL_HOST_USER: user
WEBLATE_EMAIL_HOST_PASSWORD: pass
WEBLATE_EMAIL_USE_TLS: 0
WEBLATE_EMAIL_USE_SSL: 1
也參考
- WEBLATE_EMAIL_HOST¶
郵件伺服器主機名或 IP 地址。
- WEBLATE_EMAIL_PORT¶
郵件伺服器連接埠,預設為 25。
也參考
- WEBLATE_EMAIL_HOST_USER¶
電子郵件驗證使用者。
也參考
- WEBLATE_EMAIL_HOST_PASSWORD¶
電子郵件身分驗證密碼。
- WEBLATE_EMAIL_USE_SSL¶
與 SMTP 伺服器通訊時是否使用隱式 TLS(安全)連線。在大多數電子郵件檔案中,這種 TLS 連線類型稱為 SSL。通常在連接埠 465 上使用。如果遇到問題,請參閱顯式 TLS 設定
WEBLATE_EMAIL_USE_TLS。在 4.11 版的變更: 支援 SSL/TLS 將依
WEBLATE_EMAIL_PORT自動啟用。
- WEBLATE_EMAIL_USE_TLS¶
與 SMTP 伺服器通訊時是否使用 TLS(安全)連接。這用於顯式 TLS 連線,通常在連接埠 587 或 25 上。如果您遇到掛起的連接,請參閱隱式 TLS 設定
WEBLATE_EMAIL_USE_SSL。在 4.11 版的變更: 支援 SSL/TLS 將依
WEBLATE_EMAIL_PORT自動啟用。
- WEBLATE_EMAIL_BACKEND¶
將 Django 後端配置為用於發送電子郵件。
也參考
- WEBLATE_AUTO_UPDATE¶
配置 Weblate 應該如何更新儲存庫。
也參考
備註
這是布林值的設定(使用
"true"或"false")。
網站整合¶
- WEBLATE_GET_HELP_URL¶
配置
GET_HELP_URL.
- WEBLATE_STATUS_URL¶
配置
STATUS_URL.
- WEBLATE_PRIVACY_URL¶
配置
PRIVACY_URL。
- WEBLATE_PASSWORD_RESET_URL¶
Collecting error reports and monitoring performance¶
推薦從安裝中系統地收集錯誤,請參閱 Collecting error reports and monitoring performance。
要啟用對 Rollbar 的支援,請進行以下設定:
- ROLLBAR_KEY¶
您的 Rollbar 發佈伺服器存取權杖。
- ROLLBAR_ENVIRONMENT¶
您的 Rollbar 環境,預設為
production。
要啟用對 Sentry 的支援,請進行以下設定:
- SENTRY_DSN¶
您的 Sentry DSN,請參閱
SENTRY_DSN。
- SENTRY_ENVIRONMENT¶
您的 Sentry 環境(可選),預設為
WEBLATE_SITE_DOMAIN。
- SENTRY_MONITOR_BEAT_TASKS¶
Whether to monitor Celery Beat tasks with Sentry, defaults to
True.
- SENTRY_TRACES_SAMPLE_RATE¶
-
範例:
environment: SENTRY_TRACES_SAMPLE_RATE: 0.5
- SENTRY_PROFILES_SAMPLE_RATE¶
配置
SENTRY_PROFILES_SAMPLE_RATE。範例:
environment: SENTRY_PROFILES_SAMPLE_RATE: 0.5
- SENTRY_SEND_PII¶
配置
SENTRY_SEND_PII。
在地化 CDN¶
- WEBLATE_LOCALIZE_CDN_URL¶
- WEBLATE_LOCALIZE_CDN_PATH¶
在 4.2.1 版被加入.
JavaScript 在地化 CDN 的配置。
WEBLATE_LOCALIZE_CDN_PATH是容器內的路徑。它應該儲存在持久儲存區上,而不能儲存在臨時儲存體中。一種可能性是儲存在 Weblate 資料目錄中:
environment: WEBLATE_LOCALIZE_CDN_URL: https://cdn.example.com/ WEBLATE_LOCALIZE_CDN_PATH: /app/data/l10n-cdn
備註
您負責設定Weblate產生的文件的服務,它只在配置的位置儲存文件。
Changing enabled apps, checks, add-ons, machine translation or autofixes¶
可以通過後面的變數來調整允許的檢查、附加元件或自動修復的內建配置:
- WEBLATE_ADD_APPS¶
- WEBLATE_REMOVE_APPS¶
- WEBLATE_ADD_CHECK¶
- WEBLATE_REMOVE_CHECK¶
- WEBLATE_ADD_AUTOFIX¶
- WEBLATE_REMOVE_AUTOFIX¶
- WEBLATE_ADD_ADDONS¶
- WEBLATE_REMOVE_ADDONS¶
- WEBLATE_ADD_MACHINERY¶
在 5.6.1 版被加入.
- WEBLATE_REMOVE_MACHINERY¶
在 5.6.1 版被加入.
範例:
environment:
WEBLATE_REMOVE_AUTOFIX: weblate.trans.autofixes.whitespace.SameBookendingWhitespace
WEBLATE_ADD_ADDONS: customize.addons.MyAddon,customize.addons.OtherAddon
容器設定¶
- WEBLATE_WORKERS¶
在 4.6.1 版被加入.
在容器中執行的工人行程基數。未設定時,基於可用的CPU核心數,在容器啟動時自動確定。
It is used to determine
CELERY_MAIN_OPTIONS,CELERY_NOTIFY_OPTIONS,CELERY_MEMORY_OPTIONS,CELERY_TRANSLATE_OPTIONS,CELERY_BACKUP_OPTIONS,CELERY_BEAT_OPTIONS, andWEB_WORKERS. You can use these settings to fine-tune.
- CELERY_MAIN_OPTIONS¶
- CELERY_NOTIFY_OPTIONS¶
- CELERY_MEMORY_OPTIONS¶
- CELERY_TRANSLATE_OPTIONS¶
- CELERY_BACKUP_OPTIONS¶
- CELERY_BEAT_OPTIONS¶
這些變數允許您調整 Celery worker 選項。它可以用於調整併發性(
--concurrency 16),或使用不同的池實作(--pool=gevent)。預設情況下,平行工作人員的數量基於
WEBLATE_WORKERS。範例:
environment: CELERY_MAIN_OPTIONS: --concurrency 16
- CELERY_SINGLE_PROCESS¶
在 5.7.1 版被加入: This variable can be set to
1to run only one celery process. This reduces memory usage but may impact Weblate performance.environment: CELERY_SINGLE_PROCESS: 1
- WEB_WORKERS¶
在 5.13 版的變更:
WEB_WORKERSconfigures how many worker processes will used by granian.
- WEBLATE_SERVICE¶
定義應在容器內執行哪些服務,使用對象 平行擴充。
Following services are defined:
celery-beatCelery工作分派程式,只能執行一個實例。該容器也負責資料庫結構遷移,並且應該在其他人之前啟動。
celery-backup凱利工人備份,只能執行一個範例。
celery-celeryGeneric Celery worker.
celery-memory翻譯記憶 Celery worker。
celery-notify通知 Celery worker。
celery-translate自動翻譯 Celery worker。
webWeb 伺服器。
也參考
- WEBLATE_ANUBIS_URL¶
在 5.11.4 版被加入.
URL of Anubis server to handle subrequest authentication. This can be useful to filter incoming HTTP requests using proof-of-work to stop AI crawlers. You need to configure Anubis for Subrequest Authentication to make it work.
Docker 容器 volumes¶
There are two volumes (data and cache) exported by the Weblate
container.
備註
The other service containers (such as PostgreSQL or Valkey) have their data volumes as well and are required to maintain Weblate persistence.
The PostgreSQL container stores the database in the
/var/lib/postgresql volume and Valkey in the /data volume.
Valkey container does not save the data by default and needs additional
configuration to enable persistence.
Base your configuration on Weblate-provided examples or consult their documentation for more information.
The data volume is mounted as /app/data and is used to store
Weblate persistent data such as cloned repositories or to customize Weblate
installation. DATA_DIR describes in more detail what is stored here.
The data volume is also place to store Weblate customization such as
資料 volume 的覆寫設定, 替換 logo 和其它靜態檔案 or
自訂代碼.
The placement of the Docker volume on host system depends on your Docker
configuration, but usually it is stored in
/var/lib/docker/volumes/weblate-docker_weblate-data/_data/ (the path
consist of name of your docker-compose directory, container, and volume names).
The cache volume is mounted as /app/cache and is used to store static
files and CACHE_DIR. Its content is recreated on container startup
and the volume can be mounted using ephemeral filesystem such as tmpfs, but
the mount has to allow execution because Weblate stores generated helper files
there.
When mounting /app/cache explicitly as tmpfs in Docker Compose,
enable execution:
tmpfs:
- /app/cache:exec
When also setting ownership options, keep the exec option:
tmpfs:
- /app/cache:exec,uid=1000,gid=1000
當手動建立 volumes 時,請在容器中指定的資料夾擁有者權限設定為 UID 1000。
Weblate container can also be executed with a read-only root file system. In
this case, two additional tmpfs volumes should be mounted: /tmp and
/run.
唯讀根檔案系統¶
在 4.18 版被加入.
When running the container with a read-only root filesystem, two additional
tmpfs volumes are required - /tmp and /run.
環境變數以外的配置¶
Docker environment variables are intended to expose most configuration settings of relevance for Weblate installations.
If you find a setting that is not exposed as an environment variable, and you believe that it should be, feel free to ask for it to be exposed in a future version of Weblate.
If you need to modify a setting that is not exposed as a Docker environment variable, you can still do so, either from the data volume or extending the Docker image.
也參考
資料 volume 的覆寫設定¶
You can create a file at /app/data/settings-override.py, i.e. at the
root of the data volume, to extend or override settings
defined through environment variables.
Overriding settings by extending the Docker image¶
To override settings at the Docker image level instead of from the data volume:
Add a module to your package that imports all settings from
weblate.settings_docker.For example, within the example package structure defined at 建立 Python 模組, you could create a file at
weblate_customization/weblate_customization/settings.pywith the following initial code:from weblate.settings_docker import *
Create a custom
Dockerfilethat inherits from the official Weblate Docker image, and then installs your package and points theDJANGO_SETTINGS_MODULEenvironment variable to your settings module:FROM weblate/weblate USER root COPY weblate_customization /usr/src/weblate_customization RUN source /app/venv/bin/activate && uv pip install --no-cache-dir /usr/src/weblate_customization ENV DJANGO_SETTINGS_MODULE=weblate_customization.settings USER 1000
Instead of using the official Weblate Docker image, build a custom image from this
Dockerfilefile.There is no clean way to do this with
docker-compose.override.yml. You could addbuild: .to theweblatenode in that file, but then your custom image will be tagged asweblate/weblatein your system, which could be problematic.So, instead of using the
docker-compose.ymlstraight from the official repository, unmodified, and extending it throughdocker-compose.override.yml, you may want to make a copy of the officialdocker-compose.ymlfile, and edit your copy to replaceimage: weblate/weblatewithbuild: ..See the Compose file build reference for details on building images from source when using
docker-compose.Extend your custom settings module to define or redefine settings.
You can define settings before or after the import statement above to determine which settings take precedence. Settings defined before the import statement can be overridden by environment variables and setting overrides defined in the data volume. Setting defined after the import statement cannot be overridden.
You can also go further. For example, you can reproduce some of the things that
weblate.docker_settingsdoes, such as exposing settings as environment variables, or allow overriding settings from Python files in the data volume.
替換 logo 和其它靜態檔案¶
Weblate 附帶的靜態文件可以通過放置到 /app/data/python/customize/static 中來覆寫(請參閱 Docker 容器 volumes)。例如,建立 /app/data/python/customize/static/favicon.ico 將替換 favicon。
提示
在容器啟動時,這些文件被複製到相應的位置,因此需要在變更儲存區的內容後重新啟動 Weblate。
This approach can be also used to override Weblate templates. For example
法律模組 documents can be placed into
/app/data/python/customize/templates/legal/documents.
或者,您也可以包括自己的模組(請參閱 客製 Weblate),並將其作為單獨的捲新增到 Docker 容器中,例如:
weblate:
volumes:
- weblate-data:/app/data
- ./weblate_customization/weblate_customization:/app/data/python/weblate_customization
environment:
WEBLATE_ADD_APPS: weblate_customization
自訂代碼¶
備註
The internal Weblate API may vary significantly between releases and is not meant to be stable. Please review your custom code interacting with Weblate internals on each upgrade.
You can place additional Python code into /app/data/python/customize
(see Docker 容器 volumes). It is already installed as a Django application
inside Weblate (this is used for customizing templates and static files as
described above).
This can be used to place any code (for example 撰寫自訂檢查) or to add custom maintenance tasks to the Celery task scheduler.
/app/data/python/customize/tasks.py.¶"""Custom scheduled task."""
import subprocess # noqa: S404
from celery.schedules import crontab
from weblate.utils.celery import app
@app.task
def custom_task() -> None:
"""Execute custom task code."""
subprocess.run(["sleep", "1"], check=True) # noqa: S607
@app.on_after_finalize.connect
def setup_periodic_tasks(sender, **kwargs) -> None:
"""Configure when periodic task is triggered."""
sender.add_periodic_task(
crontab(hour=1, minute=0), custom_task.s(), name="custom-task"
)
整合第三方容器¶
The Weblate Docker setup can be extended with additional containers to provide complementary services such as machine translation, spell checking, or other tools that enhance the translation workflow. These services can be integrated into your Docker Compose configuration and work alongside Weblate.
When adding third-party containers, consider the following:
Network connectivity: Ensure containers can communicate with each other by placing them on the same Docker network
Data persistence: Use volumes for services that need to persist data
Security: Configure appropriate access controls and avoid exposing unnecessary ports
LibreTranslate Docker 容器整合¶
LibreTranslate is a free and open-source machine translation service that can be self-hosted. Integrating it with Weblate provides offline machine translation capabilities without relying on external services.
You can incorporate the LibreTranslate service into your Weblate deployment by including it in a docker-compose.override.yml file. Since it runs within the Docker network, it's only accessible to Weblate and not exposed to the public internet.
Basic setup using docker-compose.override.yml:
services:
libretranslate:
image: libretranslate/libretranslate:latest
command: --disable-web-ui
restart: unless-stopped
environment:
LT_UPDATE_MODELS: true
volumes:
- libretranslate_models:/home/libretranslate/.local:rw
healthcheck:
test: ['CMD-SHELL', './venv/bin/python scripts/healthcheck.py']
interval: 10s
timeout: 4s
retries: 4
start_period: 5s
volumes:
libretranslate_models:
For GPU-accelerated translation (if you have NVIDIA GPU available):
services:
libretranslate:
image: libretranslate/libretranslate:latest-cuda
command: --disable-web-ui
restart: unless-stopped
environment:
LT_UPDATE_MODELS: true
PUID: root
volumes:
- libretranslate_models:/home/libretranslate/.local:rw
healthcheck:
test: ['CMD-SHELL', './venv/bin/python scripts/healthcheck.py']
interval: 10s
timeout: 4s
retries: 4
start_period: 5s
deploy:
resources:
reservations:
devices:
- driver: nvidia
count: 1
capabilities: [gpu]
volumes:
libretranslate_models:
After starting the services with docker compose down && docker compose up -d,
configure LibreTranslate in Weblate:
存取 Weblate 管理員介面
Navigate to Machine translation → Automatic suggestions
Add a new LibreTranslate service with:
- 服務:
LibreTranslate
- API URL:
http://libretranslate:5000- API 金鑰:
Leave empty
LibreTranslate 現在於 Weblate 中可被配置及用於機器翻譯。
備註
The LibreTranslate service runs without the web UI (
--disable-web-ui) and is only accessible via the API within the Docker network.Models are automatically updated when the container starts. (
LT_UPDATE_MODELS: true)Data is persisted using Docker volumes for optimal performance and data safety.
Health checks ensure that the Docker engine properly observes the state of the service.
For GPU acceleration, use the CUDA image variant and ensure your system has NVIDIA Docker support. This container runs as a privileged user to be able to use the GPU.
No external ports are exposed, making the setup secure by default.
Anubis Docker 容器整合¶
Anubis is a web AI firewall utility to block AI scrapers and other disruptive traffic on the server. It is typically needed for publicly open Weblate installations to avoid excessive load caused by scraping.
Anubis can be deployed using Docker Compose:
anubis:
image: ghcr.io/techarohq/anubis:latest
environment:
BIND: ":8923"
DIFFICULTY: "4"
METRICS_BIND: ":9090"
SERVE_ROBOTS_TXT: "false"
OG_PASSTHROUGH: "false"
# The single space in TARGET enables subrequest authentication
TARGET: " "
# The redirect domain has to match WEBLATE_SITE_DOMAIN
REDIRECT_DOMAINS: weblate.example.com
# Generate a random private key using: openssl rand -hex 32
ED25519_PRIVATE_KEY_HEX: "..."
# Customize your Anubis policy
POLICY_FNAME: /data/botPolicies.yaml
healthcheck:
test: ["CMD", "anubis", "--healthcheck"]
interval: 5s
timeout: 30s
retries: 5
start_period: 500ms
volumes:
- anubis-data:/data
volumes:
anubis-data:
備註
The anubis-data volume in the above configuration is expected to contain
botPolicies.yaml with a bot policy configured to your needs.
At minimum, you need to adjust status codes as described in https://anubis.techaro.lol/docs/admin/configuration/subrequest-auth.
It is also recommended to configure persistent storage backend as described in https://anubis.techaro.lol/docs/admin/policies/#storage-backends.
You can then turn on the Anubis usage in Weblate using:
environment:
WEBLATE_ANUBIS_URL: http://anubis:8923
配置 PostgreSQL 伺服器¶
The PostgreSQL container uses default PostgreSQL configuration and it won't effectively utilize your CPU cores or memory. It is recommended to customize the configuration to improve the performance.
The configuration can be adjusted as described in Database Configuration at https://hub.docker.com/_/postgres. The configuration matching your environment can be generated using https://pgtune.leopard.in.ua/.
容器內部¶
The container is using supervisor to start individual services. In case of 平行擴充, it only starts single service in a container.
確認服務狀態使用:
docker compose exec --user weblate weblate supervisorctl status
There are individual services for each Celery queue (see 使用 Celery 的背景工作 for details). You can stop processing some tasks by stopping the appropriate worker:
docker compose exec --user weblate weblate supervisorctl stop celery-translate