使用 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 Redis 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 of RAM

  • 2 CPU 核心

  • 1 GB 的儲存空間

備註

根據 Weblate 中管理的翻譯大小,安裝 Weblate 的實際要求差異很大。

Memory usage

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 usage

Many concurrent users increase the amount of needed CPU cores.

Storage usage

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 Architecture overview) 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 的資料庫設定).

安裝

提示

The following examples assume you have a working Docker environment, with docker-compose-plugin installed. Please check the Docker documentation for instructions.

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 平行擴展.

  1. 克隆 weblate-docker 儲存庫:

    git clone https://github.com/WeblateOrg/docker-compose.git weblate-docker
    cd weblate-docker
    
  2. 建立一個 docker-compose.override.yml 檔案並調整為您所需的設定。參閱 Docker 環境變數 瞭解更多相關設定參數。

    version: '3'
    services:
      weblate:
        ports:
          - 80:8080
        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
    

    備註

    如果未設定 WEBLATE_ADMIN_PASSWORD,則使用首次啟動時顯示的隨機密碼創建管理員使用者。

    提供的例子使 Weblate 偵聽連接埠 80,在 docker-compose.override.yml 文件中編輯連接埠映射來更改。

  3. 啟動 Weblate 容器:

    docker compose up
    

享受您的 Weblate 部署,可以在 weblate 容器的連接埠 80 上進行存取。

Choosing Docker image registry

Weblate containers are published to following registries:

備註

All examples currently fetch images from Docker Hub, please adjust the configuration accordingly to use a different registry.

Choosing Docker image tag

Please choose a tag that matches your environment and expectations:

標籤名稱

描述

用例

latest

Weblate 穩定版本,符合最新版本的發佈

在正式環境中滾動式更新

<MAJOR>

Weblate 穩定版本

Rolling updates within a major version in a production environment

<MAJOR>.<MINOR>

Weblate 穩定版本

Rolling updates within a minor version in a production environment

<VERSION>.<PATCH>

Weblate 穩定版本

明確定義其佈署版本於正式環境中

edge

基於 Weblate 穩定版本作開發修正於 Docker 容器(例如更新相依套件)

滾動式更新於暫存環境中

edge-<DATE>-<SHA>

基於 Weblate 穩定版本作開發修正於 Docker 容器(例如更新相依套件)

明確定義其佈署版本於暫存環境中

bleeding

依 Git 上的 Weblate 開發版本

滾動式更新來測試即將發佈的 Weblate 功能

bleeding-<DATE>-<SHA>

依 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 證書

如果您要使用自己的 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 )可能會使用端口 80443。要將 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 證書

如果要在公共安裝中使用`Let’s Encrypt <https://letsencrypt.org/>`_ 自動產生的SSL 證書,則需要在其他Docker 容器中新增反向HTTPS 代理,這將使用`https-portal <https ://hub.docker.com/r/steveltn/https-portal/>`_。這是在 docker-compose-https.yml 文件中使用的。然後使用您的設定建立一個 docker-compose-https.override.yml 文件:

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'

Whenever invoking docker compose you need to pass both files to it, and then do:

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 會很痛苦,並且在大多數情況下不會帶來很多好處。

在 4.17-1 版的變更: Since Weblate 4.17-1, the Docker container uses Django 4.2 what requires PostgreSQL 12 or newer, please upgrade it prior to upgrading Weblate. See Upgrading PostgreSQL container.

您可以通過堅持使用現有的 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 資料庫應在首次啟動時自動遷移,並且不需要其他手動操作。

備註

Upgrades across major versions are not supported by Weblate. For example, if you are on 3.x series and want to upgrade to 4.x, first upgrade to the latest 4.0.x-y image (at time of writing this it is the 4.0.4-5), which will do the migration and then continue upgrading to newer versions.

You might also want to update the docker-compose repository, though it’s not needed in most case. See Upgrading PostgreSQL container for upgrading the PostgreSQL server.

Upgrading PostgreSQL container

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.

  1. Stop Weblate container:

    docker compose stop weblate cache
    
  2. 備份資料庫:

    docker compose exec database pg_dumpall --clean --if-exists --username weblate > backup.sql
    
  3. Stop the database container:

    docker compose stop database
    
  4. 移除 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-docker in this documentation.

  5. Adjust docker-compose.yml to use new PostgreSQL version.

  6. 啟動資料庫容器:

    docker compose up -d database
    
  7. 從備份中恢復資料庫:

    cat backup.sql | docker compose exec -T database psql --username weblate --dbname weblate
    

    提示

    Please check that the database name matches POSTGRES_DB.

  8. (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.

  9. 啟動所有剩下的容器:

    docker compose up -d
    

系統管理員登入

設定容器之後,您可以使用 WEBLATE_ADMIN_PASSWORD 中提供的密碼以 管理員 使用者身份登入,或者如果未設定該密碼,則在首次啟動時產生隨機密碼。

要重置 管理員 密碼,請在 WEBLATE_ADMIN_PASSWORD 設定為新密碼的情況下重啟容器。

過程數量和內存消耗

基於CPU的數量,自動確定UWSGI和CELERY的工人流程數。這適用於大多數雲虛擬機,因為它們通常具有很少的CPU和良好的內存量。

在您有很多 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

平行擴展

Added in version 4.6.

您可以執行多個 Weblate 容器以水平擴展服務。 /app/data`volume 必須由所有容器共享,建議使用群集檔案系統,如 Glusterfs。 :file:/app/cache` volume 應該為每個容器分開組態。

每個WebLate容器都有定義的角色:envvar:`weblate_service`環境變量。請仔細追蹤文件,因為某些服務應該在群集中僅執行一次,並且服務的訂單也是如此。

您可以在“docker-compose`` repo中”找到示例設定為“docker-compose-split.yml <https://github.com/weblateorg/docker-compose/blob/main/docker-compose-split.yml>`__。

Docker 環境變數

許多 Weblate 的 :ref:`config`可以透過環境變數設定到 Docker 容器中。

If you need to define a setting not exposed through Docker environment variables, see Configuration beyond environment variables.

Passing secrets

Added in version 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_DEBUG

使用 DEBUG 組態 Django 調試模式。

示例:

environment:
  WEBLATE_DEBUG: 1

也參考

停用除錯模式

WEBLATE_LOGLEVEL

Configures the logging verbosity. Set this to DEBUG to get more detailed logs.

Defaults to INFO when WEBLATE_DEBUG is turned off, DEBUG is used when debug mode is turned on.

For more silent logging use ERROR or WARNING.

WEBLATE_LOGLEVEL_DATABASE

Configures the logging of the database queries verbosity.

WEBLATE_SITE_TITLE

更改所有頁面頁眉上顯示的站點標題。

WEBLATE_SITE_DOMAIN

Configures the site domain. This parameter is required.

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_PASSWORDWEBLATE_ADMIN_NAMEWEBLATE_ADMIN_EMAIL

警告

將密碼儲存在組態文件中可能會帶來安全風險。考慮僅將此變量用於初始設定(或讓 Weblate 在初始啟動時產生隨機密碼)或用於密碼恢復。

WEBLATE_SERVER_EMAIL

The email address that error messages are sent from.

WEBLATE_DEFAULT_FROM_EMAIL

組態外發電子郵件的地址。

WEBLATE_ADMINS_CONTACT

Configures 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_ALLOW_BACKENDS

組態可用於通過 REGISTRATION_ALLOW_BACKENDS 建立新帳戶的身份驗證方法。

示例:

environment:
  WEBLATE_REGISTRATION_OPEN: 0
  WEBLATE_REGISTRATION_ALLOW_BACKENDS: azuread-oauth2,azuread-tenant-oauth2
WEBLATE_REGISTRATION_REBIND

Added in version 4.16.

Configures REGISTRATION_REBIND.

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_INTERLEDGER_PAYMENT_POINTERS

Added in version 4.12.1.

Lets Weblate set the meta[name=monetization] field in the head of the document. If multiple are specified, chooses one randomly.

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

Added in version 5.0.1.

Configures IP_PROXY_OFFSET.

WEBLATE_USE_X_FORWARDED_PORT

Added in version 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

代表 HTTP 標頭/值的組合的元組,用於表達請求,這樣的元組是安全的。當 Weblate 在進行終止SSL 的反向代理之後執行時,這是需要的,終止 SSL 不通過標準 HTTPS 標頭。

示例:

environment:
  WEBLATE_SECURE_PROXY_SSL_HEADER: HTTP_X_FORWARDED_PROTO,https
WEBLATE_REQUIRE_LOGIN

啟用 REQUIRE_LOGIN 而在整個 Weblate 上強制認證。

示例:

environment:
  WEBLATE_REQUIRE_LOGIN: 1
WEBLATE_LOGIN_REQUIRED_URLS_EXCEPTIONS
WEBLATE_ADD_LOGIN_REQUIRED_URLS_EXCEPTIONS
WEBLATE_REMOVE_LOGIN_REQUIRED_URLS_EXCEPTIONS

使用 LOGIN_REQUIRED_URLS_EXCEPTIONS 來為整個 Webate 安裝所需的身份驗證新增 URL 例外。

可以替換整個設定,或者使用 ADDREMOVE 變量修改預設值。

To enforce authentication for the contact form, do:

environment:
  WEBLATE_REMOVE_LOGIN_REQUIRED_URLS_EXCEPTIONS: /contact/$
WEBLATE_GOOGLE_ANALYTICS_ID

通過 GOOGLE_ANALYTICS_ID 來組態用於 Google Analytics 的 ID。

WEBLATE_DEFAULT_PULL_MESSAGE

設定拉取請求預設的標題與訊息透過 API 改變 DEFAULT_PULL_MESSAGE

WEBLATE_SIMPLIFY_LANGUAGES

組態語言簡化策略,請參見 SIMPLIFY_LANGUAGES

WEBLATE_DEFAULT_ACCESS_CONTROL

為新項目組態預設的 存取控制,請參見 DEFAULT_ACCESS_CONTROL

WEBLATE_DEFAULT_RESTRICTED_COMPONENT

為新組件的 受限制的存取 組態預設值,請參見 DEFAULT_RESTRICTED_COMPONENT

WEBLATE_DEFAULT_TRANSLATION_PROPAGATION

為新組件的 允許翻譯再用 組態預設值,請參見 DEFAULT_TRANSLATION_PROPAGATION

WEBLATE_DEFAULT_COMMITER_EMAIL

組態 DEFAULT_COMMITER_EMAIL

WEBLATE_DEFAULT_COMMITER_NAME

組態 DEFAULT_COMMITER_NAME

WEBLATE_DEFAULT_SHARED_TM

組態 DEFAULT_SHARED_TM.

WEBLATE_AKISMET_API_KEY

組態 Akismet API 金鑰,請參見 AKISMET_API_KEY

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

允許客製 Content-Security-Policy HTTP 標頭。

也參考

:ref:“CSP”,:設定:“CSP_Script_src`”,

WEBLATE_LICENSE_FILTER

組態 LICENSE_FILTER.

WEBLATE_LICENSE_REQUIRED

組態 LICENSE_REQUIRED

WEBLATE_WEBSITE_REQUIRED

組態 WEBSITE_REQUIRED

WEBLATE_HIDE_VERSION

組態 HIDE_VERSION

WEBLATE_BASIC_LANGUAGES

組態 BASIC_LANGUAGES.

WEBLATE_DEFAULT_AUTO_WATCH

組態 DEFAULT_AUTO_WATCH.

WEBLATE_RATELIMIT_ATTEMPTS
WEBLATE_RATELIMIT_LOCKOUT
WEBLATE_RATELIMIT_WINDOW

Added in version 4.6.

Configures rate limiter.

提示

您可以設定任何速率限制器範圍的組態。為此設定的任何設定新增``Web21```:ref:速率限制

WEBLATE_API_RATELIMIT_ANON
WEBLATE_API_RATELIMIT_USER

Added in version 4.11.

Configures API rate limiting. Defaults to 100/day for anonymous and 5000/hour for authenticated users.

也參考

API 頻次限制

WEBLATE_ENABLE_HOOKS

Added in version 4.13.

Configures ENABLE_HOOKS.

WEBLATE_ENABLE_AVATARS

Added in version 4.6.1.

組態 ENABLE_AVATARS.

WEBLATE_AVATAR_URL_PREFIX

Added in version 4.15.

Configures AVATAR_URL_PREFIX.

WEBLATE_LIMIT_TRANSLATION_LENGTH_BY_SOURCE_LENGTH

Added in version 4.9.

Configures LIMIT_TRANSLATION_LENGTH_BY_SOURCE_LENGTH.

WEBLATE_SSH_EXTRA_ARGS

Added in version 4.9.

Configures SSH_EXTRA_ARGS.

WEBLATE_BORG_EXTRA_ARGS

Added in version 4.9.

Configures BORG_EXTRA_ARGS as a comma separated list of args.

示例:

environment:
  WEBLATE_BORG_EXTRA_ARGS: --exclude,vcs/
WEBLATE_ENABLE_SHARING

Added in version 4.14.1.

Configures ENABLE_SHARING.

WEBLATE_SUPPORT_STATUS_CHECK

Added in version 5.5.

Configures SUPPORT_STATUS_CHECK.

WEBLATE_EXTRA_HTML_HEAD

Added in version 4.15.

Configures EXTRA_HTML_HEAD.

WEBLATE_PRIVATE_COMMIT_EMAIL_TEMPLATE

Added in version 4.15.

Configures PRIVATE_COMMIT_EMAIL_TEMPLATE.

WEBLATE_PRIVATE_COMMIT_EMAIL_OPT_IN

Added in version 4.15.

Configures PRIVATE_COMMIT_EMAIL_OPT_IN.

WEBLATE_UNUSED_ALERT_DAYS

Added in version 4.17.

Configures UNUSED_ALERT_DAYS.

WEBLATE_CORS_ALLOWED_ORIGINS

Added in version 4.16.

Allow CORS requests from given origins.

示例:

environment:
  WEBLATE_CORS_ALLOWED_ORIGINS: https://example.com,https://weblate.org
CLIENT_MAX_BODY_SIZE

Added in version 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 pull requests, but applies to all 版本控制整合 with appropriately changed variable names.

An example configuration for GitHub 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 pull requests 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 pull requests 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 Server pull requests by changing BITBUCKETSERVER_CREDENTIALS.

WEBLATE_AZURE_DEVOPS_USERNAME
WEBLATE_AZURE_DEVOPS_ORGANIZATION
WEBLATE_AZURE_DEVOPS_TOKEN
WEBLATE_AZURE_DEVOPS_HOST
WEBLATE_AZURE_DEVOPS_CREDENTIALS

Configures Azure DevOps pull requests by changing AZURE_DEVOPS_CREDENTIALS.

Automatic suggestion settings

在 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.

身份驗證設定

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_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
WEBLATE_SOCIAL_AUTH_GITHUB_TEAM_ID

允許 GitHub 驗證

GitHub Enterprise Edition

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

Enables GitHub EE authentication.

Bitbucket

WEBLATE_SOCIAL_AUTH_BITBUCKET_OAUTH2_KEY
WEBLATE_SOCIAL_AUTH_BITBUCKET_OAUTH2_SECRET
WEBLATE_SOCIAL_AUTH_BITBUCKET_KEY
WEBLATE_SOCIAL_AUTH_BITBUCKET_SECRET

允許 Butbucket 驗證

Facebook

WEBLATE_SOCIAL_AUTH_FACEBOOK_KEY
WEBLATE_SOCIAL_AUTH_FACEBOOK_SECRET

允許 Facebook 驗證 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 驗證 2

Gitea

WEBLATE_SOCIAL_AUTH_GITEA_API_URL
WEBLATE_SOCIAL_AUTH_GITEA_KEY
WEBLATE_SOCIAL_AUTH_GITEA_SECRET

Enables Gitea authentication.

Azure Active Directory

WEBLATE_SOCIAL_AUTH_AZUREAD_OAUTH2_KEY
WEBLATE_SOCIAL_AUTH_AZUREAD_OAUTH2_SECRET

允許 Azure 活動目錄身份驗證,請參見 微軟 Azure Active Directory

帶有租戶支援的Azure 活動目錄

WEBLATE_SOCIAL_AUTH_AZUREAD_TENANT_OAUTH2_KEY
WEBLATE_SOCIAL_AUTH_AZUREAD_TENANT_OAUTH2_SECRET
WEBLATE_SOCIAL_AUTH_AZUREAD_TENANT_OAUTH2_TENANT_ID

允許帶有租戶支援的Azure 活動目錄身份驗證,請參見 微軟 Azure Active Directory

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 身份驗證,請參見 documentation

Linux 銷售商

您可以通過將後面的變量設定為任何值,使用 Linux 銷售商身份驗證服務來允許身份驗證。

WEBLATE_SOCIAL_AUTH_FEDORA
WEBLATE_SOCIAL_AUTH_OPENSUSE
WEBLATE_SOCIAL_AUTH_OPENINFRA
WEBLATE_SOCIAL_AUTH_UBUNTU

Slack

WEBLATE_SOCIAL_AUTH_SLACK_KEY
SOCIAL_AUTH_SLACK_SECRET

允許 Slack 身份驗證,請參見 Slack

OpenID 連結

Added in version 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

Configures generic OpenID Connect integration.

SAML

在第一次啟動容器時自動產生自簽名的 SAML 金鑰。在您想要使用自己的金鑰的情況下,將憑證和私鑰放置在 /app/data/ssl/saml.crt 和 :file:`/app/data/ssl/saml.key `中。

WEBLATE_SAML_IDP_ENTITY_ID
WEBLATE_SAML_IDP_URL
WEBLATE_SAML_IDP_X509CERT
WEBLATE_SAML_IDP_IMAGE
WEBLATE_SAML_IDP_TITLE

SAML 身份提供者設定,請參見 SAML 身份驗證

WEBLATE_SAML_ID_ATTR_NAME
WEBLATE_SAML_ID_ATTR_USERNAME
WEBLATE_SAML_ID_ATTR_EMAIL
WEBLATE_SAML_ID_ATTR_USER_PERMANENT_ID

Added in version 4.18.

SAML attributes mapping.

Other authentication settings

WEBLATE_NO_EMAIL_AUTH

Disables e-mail authentication when set to any value. See 關閉密碼身份驗證.

WEBLATE_MIN_PASSWORD_SCORE

Minimal password score as evaluated by the zxcvbn password strength estimator. Defaults to 3, set to 0 to disable strength checking.

PostgreSQL 資料庫設定

資料庫由 docker-compose.yml 建立,所以這些設定影響 Weblate 和 PostgreSQL 容器。

POSTGRES_PASSWORD

PostgreSQL 密碼。

也參考

Passing secrets

POSTGRES_USER

PostgreSQL 使用者名。

POSTGRES_DB

PostgreSQL 資料庫名稱。

POSTGRES_HOST

PostgreSQL 伺服器主機名成或 IP 地址。預設為 database

POSTGRES_PORT

PostgreSQL 伺服器連接埠。預設為無(使用預設值)。

POSTGRES_SSL_MODE

組態 PostgreSQL 如何處理 SSL 連接到伺服器,可能的選項請參見 SSL Mode Descriptions

POSTGRES_ALTER_ROLE

在遷移過程中組態要改變的角色名稱,請參見 組態 Weblate 來使用 PostgreSQL

POSTGRES_CONN_MAX_AGE

Added in version 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

Added in version 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

Added in version 5.1.

Set to false to disables environment based configuration of the database connection. Use 資料 volume 的覆蓋設定 to configure the database connection manually.

MySQL or MariaDB server

Neither MySQL nor MariaDB can not be configured via environment variables. See MySQL 與 MariaDB for info on using those with Weblate. Use WEBLATE_DATABASES to configure the database connection manually.

資料庫備份設定

WEBLATE_DATABASE_BACKUP

使用 DATABASE_BACKUP 組態每日資料庫轉儲。預設為 plain

快取伺服器設定

Weblate 強烈推薦使用 Redis,在 Docker 中執行 Weblate 時您必須提供 Redis 事例。

也參考

允許快取

REDIS_HOST

Redis 伺服器主機名稱或 IP 地址。預設為 cache

REDIS_PORT

Redis 伺服器連接埠。預設為 6379

REDIS_DB

Redis 資料庫編號,預設為 1

REDIS_PASSWORD

Redis 伺服器密碼,預設不使用。

也參考

Passing secrets

REDIS_TLS

允許使用 SSL 進行 Redis 連接。

REDIS_VERIFY_SSL

可以用於禁止 Redis 連接的 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。

也參考

EMAIL_PORT

WEBLATE_EMAIL_HOST_USER

E-mail authentication user.

也參考

EMAIL_HOST_USER

WEBLATE_EMAIL_HOST_PASSWORD

E-mail authentication password.

WEBLATE_EMAIL_USE_SSL

與 SMTP 伺服器通信時是否使用隱式 TLS(安全)連接。在大多數電子郵件文件中,這種 TLS 連接類型稱為 SSL。通常在連接埠 465 上使用。如果遇到問題,請參閱顯式 TLS 設定 WEBLATE_EMAIL_USE_TLS

在 4.11 版的變更: 支援 SSL/TLS 將依 :envvar:`WEBLATE_EMAIL_PORT`自動啟用。

WEBLATE_EMAIL_USE_TLS

與 SMTP 伺服器通訊時是否使用 TLS(安全)連接。這用於顯式 TLS 連接,通常在端口 587 或 25 上。如果您遇到掛起的連接,請參見隱式 TLS 設定 WEBLATE_EMAIL_USE_SSL

在 4.11 版的變更: 支援 SSL/TLS 將依 :envvar:`WEBLATE_EMAIL_PORT`自動啟用。

WEBLATE_EMAIL_BACKEND

將 Django 後端組態為用於發送電子郵件。

WEBLATE_AUTO_UPDATE

Configures if and how Weblate should update repositories.

也參考

AUTO_UPDATE

備註

這是布林值的設定(使用 "true""false")。

Site integration

WEBLATE_GET_HELP_URL

組態 GET_HELP_URL.

WEBLATE_STATUS_URL

組態 STATUS_URL.

組態: setting:LEGAL_URL.

WEBLATE_PRIVACY_URL

Configures PRIVACY_URL.

Collecting error reports and monitoring performance

推薦從安裝中系統地收集錯誤,請參見 Collecting error reports and monitoring performance

要啟用對 Rollbar 的支援,請進行以下設定:

ROLLBAR_KEY

您的 Rollbar 發佈伺服器存取令牌。

ROLLBAR_ENVIRONMENT

您的 Rollbar 環境,預設為 production

要啟用對 Sentry 的支援,請進行以下設定:

SENTRY_DSN

Your Sentry DSN, see SENTRY_DSN.

SENTRY_ENVIRONMENT

Your Sentry Environment (optional), defaults to WEBLATE_SITE_DOMAIN.

SENTRY_TRACES_SAMPLE_RATE

Configure sampling rate for performance monitoring. Set to 1 to trace all events, 0 (the default) disables tracing.

示例:

environment:
  SENTRY_TRACES_SAMPLE_RATE: 0.5
SENTRY_PROFILES_SAMPLE_RATE

Configure sampling rate for profiling monitoring. Set to 1 to trace all events, 0 (the default) disables tracing.

示例:

environment:
  SENTRY_PROFILES_SAMPLE_RATE: 0.5

也參考

Sentry Profiling

SENTRY_SEND_PII

Configures SENTRY_SEND_PII.

Localization CDN

WEBLATE_LOCALIZE_CDN_URL
WEBLATE_LOCALIZE_CDN_PATH

Added in version 4.2.1.

:ref:`addon-weblate.cdn.cdnjs`的組態。

WEBLATE_LOCALIZE_CDN_PATH 是容器內的路徑。它應該儲存在持久卷上,而不能儲存在瞬態儲存器中。

一種可能性是儲存在 Weblate 資料目錄中:

environment:
  WEBLATE_LOCALIZE_CDN_URL: https://cdn.example.com/
  WEBLATE_LOCALIZE_CDN_PATH: /app/data/l10n-cdn

備註

您負責設定Weblate產生的文件的服務,它只在組態的位置儲存文件。

更改允許的 app 、檢查、附加元件或自動修復

可以通過後面的變量來調整允許的檢查、附加元件或自動修復的內建組態:

WEBLATE_ADD_APPS
WEBLATE_REMOVE_APPS
WEBLATE_ADD_CHECK
WEBLATE_REMOVE_CHECK
WEBLATE_ADD_AUTOFIX
WEBLATE_REMOVE_AUTOFIX
WEBLATE_ADD_ADDONS
WEBLATE_REMOVE_ADDONS

示例:

environment:
  WEBLATE_REMOVE_AUTOFIX: weblate.trans.autofixes.whitespace.SameBookendingWhitespace
  WEBLATE_ADD_ADDONS: customize.addons.MyAddon,customize.addons.OtherAddon

Container settings

WEBLATE_WORKERS

Added in version 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, and WEB_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 )。

預設情況下,並發工作人員的數量基於:envvar:weblate_workers

示例:

environment:
  CELERY_MAIN_OPTIONS: --concurrency 16

也參考

:doc:“Celery Worker”選項<Celery:Reference / Celery.Bin.Worker>`,:Ref:“芹菜”

WEB_WORKERS

組態應該執行多少個 uWSGI workers。

WEBLATE_WORKERS 為設定值。

示例:

environment:
  WEB_WORKERS: 32
WEBLATE_SERVICE

定義應在容器內執行哪些服務,使用對象 平行擴展

Following services are defined:

celery-beat

Celery任務調度程序,只能執行一個實例。該容器也負責資料庫結構遷移,並且應該在其他人之前啟動。

celery-backup

凱利工人備份,只能執行一個例子。

celery-celery

Generic Celery worker.

celery-memory

Translation memory Celery worker.

celery-notify

Notifications Celery worker.

celery-translate

Automatic translation Celery worker.

web

Web 伺服器。

Docker 容器 volumes

Weblate 容器導出了兩個卷 (資料和快取)。其他服務容器(PostgreSQL 或 Redis)也具有其資料卷,但本文件未涵蓋這些資料卷。

資料卷用於儲存 Weblate 持久資料(例如克隆的倉儲)或自定義 Weblate 安裝。

Docker 卷在主機系統上的位置取決於您的 Docker 組態,但通常儲存在 /var/lib/docker/volumes/weblate-docker_weblate-data/_data/ 中。 (該路徑由您的 docker-compose 目錄的名稱、容器和卷的名稱組成)。在容器中,它掛載為 /app/data

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.

當手動建立 volumes 時,請在容器中指定的資料夾擁有者權限設定為 UID 1000。

也參考

Docker 卷文件

Read-only root filesystem

Added in version 4.18.

When running the container with a read-only root filesystem, two additional tmpfs volumes are required - /tmp and /run.

Configuration beyond environment variables

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.

也參考

客製 Weblate

資料 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:

  1. 建立自訂的 Python 套件.

  2. 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.py with the following initial code:

    from weblate.settings_docker import *
    
  3. Create a custom Dockerfile that inherits from the official Weblate Docker image, and then installs your package and points the DJANGO_SETTINGS_MODULE environment variable to your settings module:

    FROM weblate/weblate
    
    USER root
    
    COPY weblate_customization /usr/src/weblate_customization
    RUN pip install --no-cache-dir /usr/src/weblate_customization
    ENV DJANGO_SETTINGS_MODULE=weblate_customization.settings
    
    USER 1000
    
  4. Instead of using the official Weblate Docker image, build a custom image from this Dockerfile file.

    There is no clean way to do this with docker-compose.override.yml. You could add build: . to the weblate node in that file, but then your custom image will be tagged as weblate/weblate in your system, which could be problematic.

    So, instead of using the docker-compose.yml straight from the official repository, unmodified, and extending it through docker-compose.override.yml, you may want to make a copy of the official docker-compose.yml file, and edit your copy to replace image: weblate/weblate with build: ..

    See the Compose file build reference for details on building images from source when using docker-compose.

  5. 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_settings does, 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

Configuring PostgreSQL server

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/.

Container internals

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