使用 Docker 安装¶
通过 dockerized Weblate 部署,您可以在几秒钟内启动并运行您的个人 Weblate 实例。Weblate 的所有依赖项已包含在内。PostgreSQL 被设置为默认数据库。
硬件要求¶
Weblate 应该可以在所有现代硬件上正常运行,以下是在单个主机( Weblate ,数据库和 Web 服务器)上运行 Weblate 所需的最低配置:
2 GB 的内存
2 个 CPU 核心
1 GB 的存储空间
内存越多越好 —— 用于所有级别的缓存(文件系统,数据库和 Weblate )。
许多并发用户会增加所需的 CPU 内核数量。对于数百个翻译组件,建议至少有 4 GB 的内存。
注解
根据 Weblate 中管理的翻译大小,安装 Weblate 的实际要求差异很大。
安装¶
以下示例假设您拥有一个工作正常的 Docker 环境,并安装了 docker-compose
。请查看 Docker 文档以获取说明。
克隆 weblate-docker 存储库:
git clone https://github.com/WeblateOrg/docker-compose.git weblate-docker cd weblate-docker
使用您的设置创建一个
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
文件中编辑端口映射以进行更改。启动 Weblate 容器:
docker-compose up
享受您的 Weblate 部署,可以在 weblate
容器的端口 80 上进行访问。
在 2.15-2 版更改: 最近更改了设置,以前有单独的 web 服务器容器,因为 2.15-2 开始,web 服务器已嵌入 Weblate 容器中。
在 3.7.1-6 版更改: 在 2019 年 7 月(从 3.7.1-6 标签开始)中,容器未以 root 用户身份运行。这已将裸露端口从 80 更改为 8080。
具有 HTTPS 支持的 Docker 容器¶
请参阅 安装 以获取常规部署说明,本节仅提及与之相比的差异。
使用自己的 SSL 证书¶
3.8-3 新版功能.
如果您要使用自己的 SSL 证书,只需将文件放入 Weblate 数据卷中(请参阅 Docker 容器卷):
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;
listen [::]:443;
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 自动生成的 SSL 证书,则需要在其他 Docker 容器中添加反向 HTTPS 代理,这将使用 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'
每当调用 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 并仅提取最新镜像然后重新启动来执行此操作:
docker-compose stop
docker-compose pull
docker-compose up
Weblate 数据库应在首次启动时自动迁移,并且不需要其他手动操作。
注解
Weblate 不支持跨 3.0 的升级。如果您使用的是 2.x 系列,并且要升级到 3.x,请首先升级到最新的 3.0.1-x(在撰写本文时为 3.0.1-7
)镜像,它将进行迁移和然后继续升级到较新版本。
您可能还想更新 docker-compose
仓库,尽管在大多数情况下并不需要。在这种情况下,请注意 PostgreSQL 版本的更改,因为升级数据库并不容易,请参见 GitHub issue 以获取更多信息。
管理员登录¶
设置容器之后,您可以使用 WEBLATE_ADMIN_PASSWORD
中提供的密码以 管理员 用户身份登录,或者如果未设置该密码,则在首次启动时生成随机密码。
要重置 管理员 密码,请在 WEBLATE_ADMIN_PASSWORD
设置为新密码的情况下重启容器。
Docker 环境变量¶
可以使用环境变量在 Docker 容器中设置许多 Weblate 的 配置 :
通用设置¶
-
WEBLATE_LOGLEVEL
¶ 配置日志记录的详细程度。
-
WEBLATE_SITE_TITLE
¶ 更改所有页面页眉上显示的站点标题。
-
WEBLATE_SITE_DOMAIN
¶ 配置网站域名.
提示
In case it is not set, the first item from
WEBLATE_ALLOWED_HOSTS
is used.
-
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_SERVER_EMAIL
¶
-
WEBLATE_DEFAULT_FROM_EMAIL
¶ 配置外发电子邮件的地址。
-
WEBLATE_ALLOWED_HOSTS
¶ 使用
ALLOWED_HOSTS
配置允许的 HTTP 主机名。Defaults to
*
which allows all hostnames.示例:
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_TIME_ZONE
¶ 在 Weblate 中配置使用的时区,请参阅
TIME_ZONE
。注解
To change the time zone of the Docker container itself, use the
TZ
environment variable.示例:
environment: WEBLATE_TIME_ZONE: Europe/Prague
-
WEBLATE_ENABLE_HTTPS
¶ Makes Weblate assume it is operated behind a reverse HTTPS proxy, it makes Weblate use HTTPS in e-mail and API links or set secure flags on cookies.
注解
This does not make the Weblate container accept HTTPS connections, you need to configure that as well, see 具有 HTTPS 支持的 Docker 容器 for examples.
示例:
environment: WEBLATE_ENABLE_HTTPS: 1
-
WEBLATE_IP_PROXY_HEADER
¶ Lets Weblate fetch the IP address from any given HTTP header. Use this when using a reverse proxy in front of the Weblate container.
Enables
IP_BEHIND_REVERSE_PROXY
and setsIP_PROXY_HEADER
.注解
The format must conform to Django’s expectations. Django transforms raw HTTP header names as follows:
converts all characters to uppercase
replaces any hyphens with underscores
prepends
HTTP_
prefix
So
X-Forwarded-For
would be mapped toHTTP_X_FORWARDED_FOR
.示例:
environment: WEBLATE_IP_PROXY_HEADER: HTTP_X_FORWARDED_FOR
-
WEBLATE_SECURE_PROXY_SSL_HEADER
¶ A tuple representing a 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
¶ Configures login required for the whole of the Weblate installation using
LOGIN_REQUIRED_URLS
.示例:
environment: WEBLATE_REQUIRE_LOGIN: 1
-
WEBLATE_LOGIN_REQUIRED_URLS_EXCEPTIONS
¶
-
WEBLATE_ADD_LOGIN_REQUIRED_URLS_EXCEPTIONS
¶
-
WEBLATE_REMOVE_LOGIN_REQUIRED_URLS_EXCEPTIONS
¶ Adds URL exceptions for login required for the whole Weblate installation using
LOGIN_REQUIRED_URLS_EXCEPTIONS
.You can either replace whole settings, or modify default value using
ADD
andREMOVE
variables.
-
WEBLATE_GOOGLE_ANALYTICS_ID
¶ Configures ID for Google Analytics by changing
GOOGLE_ANALYTICS_ID
.
-
WEBLATE_GITHUB_USERNAME
¶ Configures GitHub username for GitHub pull-requests by changing
GITHUB_USERNAME
.参见
-
WEBLATE_GITLAB_USERNAME
¶ Configures GitLab username for GitLab merge-requests by changing
GITLAB_USERNAME
-
WEBLATE_GITLAB_HOST
¶ Configures GitLab Host for GitLab merge-requests
-
WEBLATE_GITLAB_TOKEN
¶ Configures GitLab access token for GitLab merge-requests
-
WEBLATE_SIMPLIFY_LANGUAGES
¶ Configures the language simplification policy, see
SIMPLIFY_LANGUAGES
.
-
WEBLATE_DEFAULT_ACCESS_CONTROL
¶ Configures the default 访问控制 for new projects, see
DEFAULT_ACCESS_CONTROL
.
-
WEBLATE_DEFAULT_RESTRICTED_COMPONENT
¶ Configures the default value for Restricted access for new components, see
DEFAULT_RESTRICTED_COMPONENT
.
-
WEBLATE_DEFAULT_TRANSLATION_PROPAGATION
¶ Configures the default value for 允许同步翻译 for new components, see
DEFAULT_TRANSLATION_PROPAGATION
.
-
WEBLATE_DEFAULT_COMMITER_EMAIL
¶ Configures
DEFAULT_COMMITER_EMAIL
.
-
WEBLATE_DEFAULT_COMMITER_NAME
¶ Configures
DEFAULT_COMMITER_NAME
.
-
WEBLATE_AKISMET_API_KEY
¶ Configures the Akismet API key, see
AKISMET_API_KEY
.
-
WEBLATE_GPG_IDENTITY
¶ Configures GPG signing of commits, see
WEBLATE_GPG_IDENTITY
.
-
WEBLATE_URL_PREFIX
¶ Configures URL prefix where Weblate is running, see
URL_PREFIX
.
-
WEBLATE_SILENCED_SYSTEM_CHECKS
¶ Configures checks which you do not want to be displayed, see
SILENCED_SYSTEM_CHECKS
.
-
WEBLATE_CSP_SCRIPT_SRC
¶
-
WEBLATE_CSP_IMG_SRC
¶
-
WEBLATE_CSP_CONNECT_SRC
¶
-
WEBLATE_CSP_STYLE_SRC
¶
-
WEBLATE_CSP_FONT_SRC
¶ Allows to customize
Content-Security-Policy
HTTP header.
Machine translation settings¶
-
WEBLATE_MT_AWS_REGION
¶
-
WEBLATE_MT_AWS_ACCESS_KEY_ID
¶
-
WEBLATE_MT_AWS_SECRET_ACCESS_KEY
¶ Configures AWS machine translation.
environment: WEBLATE_MT_AWS_REGION: us-east-1 WEBLATE_MT_AWS_ACCESS_KEY_ID: AKIAIOSFODNN7EXAMPLE WEBLATE_MT_AWS_SECRET_ACCESS_KEY: wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY
-
WEBLATE_MT_DEEPL_KEY
¶ Enables DeepL machine translation and sets
MT_DEEPL_KEY
-
WEBLATE_MT_DEEPL_API_VERSION
¶ Configures DeepL API version to use, see
MT_DEEPL_API_VERSION
.
-
WEBLATE_MT_GOOGLE_KEY
¶ Enables Google Translate and sets
MT_GOOGLE_KEY
-
WEBLATE_MT_MICROSOFT_COGNITIVE_KEY
¶ Enables Microsoft Cognitive Services Translator and sets
MT_MICROSOFT_COGNITIVE_KEY
-
WEBLATE_MT_MICROSOFT_ENDPOINT_URL
¶ Sets
MT_MICROSOFT_ENDPOINT_URL
, please note this is supposed to contain domain name only.
-
WEBLATE_MT_MICROSOFT_REGION
¶ Sets
MT_MICROSOFT_REGION
-
WEBLATE_MT_MICROSOFT_BASE_URL
¶
-
WEBLATE_MT_MODERNMT_KEY
¶ Enables ModernMT and sets
MT_MODERNMT_KEY
.
-
WEBLATE_MT_MYMEMORY_ENABLED
¶ Enables MyMemory machine translation and sets
MT_MYMEMORY_EMAIL
toWEBLATE_ADMIN_EMAIL
.示例:
environment: WEBLATE_MT_MYMEMORY_ENABLED: 1
-
WEBLATE_MT_GLOSBE_ENABLED
¶ Enables Glosbe machine translation.
environment: WEBLATE_MT_GLOSBE_ENABLED: 1
-
WEBLATE_MT_MICROSOFT_TERMINOLOGY_ENABLED
¶ Enables Microsoft Terminology Service machine translation.
environment: WEBLATE_MT_MICROSOFT_TERMINOLOGY_ENABLED: 1
-
WEBLATE_MT_SAP_BASE_URL
¶
-
WEBLATE_MT_SAP_SANDBOX_APIKEY
¶
-
WEBLATE_MT_SAP_USERNAME
¶
-
WEBLATE_MT_SAP_PASSWORD
¶
-
WEBLATE_MT_SAP_USE_MT
¶ Configures SAP Translation Hub machine translation.
environment: WEBLATE_MT_SAP_BASE_URL: "https://example.hana.ondemand.com/translationhub/api/v1/" WEBLATE_MT_SAP_USERNAME: "user" WEBLATE_MT_SAP_PASSWORD: "password" WEBLATE_MT_SAP_USE_MT: 1
Authentication settings¶
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.
Example for direct bind:
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
Example for search and bind:
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
Example for union search and bind:
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 WEBLATE_AUTH_LDAP_USER_SEARCH_UNION: ou=users,dc=example,dc=com|ou=otherusers,dc=example,dc=com
Example with search and bind against Active Directory:
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)
参见
Bitbucket¶
-
WEBLATE_SOCIAL_AUTH_BITBUCKET_KEY
¶
-
WEBLATE_SOCIAL_AUTH_BITBUCKET_SECRET
¶ Enables Bitbucket 身份验证.
Facebook¶
-
WEBLATE_SOCIAL_AUTH_FACEBOOK_KEY
¶
-
WEBLATE_SOCIAL_AUTH_FACEBOOK_SECRET
¶ Enables 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
¶ Enables Google OAuth 2.
GitLab¶
-
WEBLATE_SOCIAL_AUTH_GITLAB_KEY
¶
-
WEBLATE_SOCIAL_AUTH_GITLAB_SECRET
¶
-
WEBLATE_SOCIAL_AUTH_GITLAB_API_URL
¶ Enables GitLab OAuth 2.
Azure Active Directory¶
-
WEBLATE_SOCIAL_AUTH_AZUREAD_OAUTH2_KEY
¶
-
WEBLATE_SOCIAL_AUTH_AZUREAD_OAUTH2_SECRET
¶ Enables Azure Active Directory authentication, see 微软 Azure Active Directory.
Azure Active Directory with Tenant support¶
-
WEBLATE_SOCIAL_AUTH_AZUREAD_TENANT_OAUTH2_KEY
¶
-
WEBLATE_SOCIAL_AUTH_AZUREAD_TENANT_OAUTH2_SECRET
¶
-
WEBLATE_SOCIAL_AUTH_AZUREAD_TENANT_OAUTH2_TENANT_ID
¶ Enables Azure Active Directory authentication with Tenant support, see 微软 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
¶ Enables Keycloak authentication, see documentation.
Linux vendors¶
You can enable authentication using Linux vendors authentication services by setting following variables to any value.
-
WEBLATE_SOCIAL_AUTH_FEDORA
¶
-
WEBLATE_SOCIAL_AUTH_OPENSUSE
¶
-
WEBLATE_SOCIAL_AUTH_UBUNTU
¶
PostgreSQL database setup¶
The database is created by docker-compose.yml
, so these settings affect
both Weblate and PostgreSQL containers.
-
POSTGRES_PASSWORD
¶ PostgreSQL password.
-
POSTGRES_USER
¶ PostgreSQL username.
-
POSTGRES_DATABASE
¶ PostgreSQL database name.
-
POSTGRES_HOST
¶ PostgreSQL server hostname or IP address. Defaults to
database
.
-
POSTGRES_PORT
¶ PostgreSQL server port. Defaults to none (uses the default value).
-
POSTGRES_SSL_MODE
¶ Configure how PostgreSQL handles SSL in connection to the server, for possible choices see SSL Mode Descriptions
Database backup settings¶
参见
-
WEBLATE_DATABASE_BACKUP
¶ Configures the daily database dump using
DATABASE_BACKUP
. Defaults toplain
.
Caching server setup¶
Using Redis is strongly recommended by Weblate and you have to provide a Redis instance when running Weblate in Docker.
-
REDIS_HOST
¶ The Redis server hostname or IP address. Defaults to
cache
.
-
REDIS_PORT
¶ The Redis server port. Defaults to
6379
.
-
REDIS_DB
¶ The Redis database number, defaults to
1
.
-
REDIS_PASSWORD
¶ The Redis server password, not used by default.
-
REDIS_TLS
¶ Enables using SSL for Redis connection.
-
REDIS_VERIFY_SSL
¶ Can be used to disable SSL certificate verification for Redis connection.
电子邮件服务器设置¶
要使外发电子邮件正常工作,您需要提供一个邮件服务器。
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
。
-
WEBLATE_EMAIL_USE_TLS
¶ 与 SMTP 服务器通讯时是否使用 TLS(安全)连接。这用于显式 TLS 连接,通常在端口 587 或 25 上。如果您遇到挂起的连接,请参见隐式 TLS 设置
WEBLATE_EMAIL_USE_SSL
。
-
WEBLATE_EMAIL_BACKEND
¶ 将 Django 后端配置为用于发送电子邮件。
错误报告¶
建议系统地从安装中收集错误,请参阅 收集错误报告。
要启用对 Rollbar 的支持,请进行以下设置:
-
ROLLBAR_KEY
¶ 您的 Rollbar 发布服务器访问令牌。
-
ROLLBAR_ENVIRONMENT
¶ 您的 Rollbar 环境,默认为
production
。
要启用对 Sentry 的支持,请进行以下设置:
-
SENTRY_DSN
¶ 您的 Sentry DSN。
-
SENTRY_ENVIRONMENT
¶ 您的 Sentry 环境(可选)。
Localization CDN¶
-
WEBLATE_LOCALIZE_CDN_URL
¶
-
WEBLATE_LOCALIZE_CDN_PATH
¶ 4.2.1 新版功能.
Configuration for JavaScript本地化CDN.
The
WEBLATE_LOCALIZE_CDN_PATH
is path within the container. It should be stored on the persistent volume and not in the transient storage.One of possibilities is storing that inside the Weblate data dir:
environment: WEBLATE_LOCALIZE_CDN_URL: https://cdn.example.com/ WEBLATE_LOCALIZE_CDN_PATH: /app/data/l10n-cdn
注解
You are responsible for seting up serving of the files generated by Weblate, it only does stores the files in configured location.
Changing enabled apps, checks, addons or autofixes¶
3.8-5 新版功能.
The built-in configuration of enabled checks, addons or autofixes can be adjusted by the following variables:
-
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
容器设置¶
-
CELERY_MAIN_OPTIONS
¶
-
CELERY_NOTIFY_OPTIONS
¶
-
CELERY_TRANSLATE_OPTIONS
¶
-
CELERY_MEMORY_OPTIONS
¶
-
CELERY_BACKUP_OPTIONS
¶
-
CELERY_BEAT_OPTIONS
¶ These variables allow you to adjust Celery worker options. It can be useful to adjust concurrency (
--concurrency 16
) or use different pool implementation (--pool=gevent
).By default, the number of concurrent workers matches the number of processors (except the backup worker, which is supposed to run only once).
示例:
environment: CELERY_MAIN_OPTIONS: --concurrency 16
-
UWSGI_WORKERS
¶ Configure how many uWSGI workers should be executed.
It defaults to number of processors + 1.
示例:
environment: UWSGI_WORKERS: 32
Docker 容器卷¶
Weblate 容器导出单个数据卷。其他服务容器(PostgreSQL 或 Redis)也具有其数据卷,但本文档未涵盖这些数据卷。
数据卷用于存储 Weblate 持久数据(例如克隆的仓库)或自定义 Weblate 安装。
Docker 卷在主机系统上的位置取决于您的 Docker 配置,但通常存储在 /var/lib/docker/volumes/weblate-docker_weblate-data/_data/
中。在容器中,它挂载为 /app/data
。
参见
进一步的配置定制¶
您可以在数据卷中进一步自定义 Weblate 安装,请参阅 Docker 容器卷。
定制配置文件¶
您还可以在 /app/data/settings-override.py
中覆盖配置(请参阅 Docker 容器卷)。加载所有环境设置后将执行此操作,因此将完全设置它,并可用于自定义任何内容。
替换 logo 和其他静态文件¶
3.8-5 新版功能.
Weblate 附带的静态文件可以通过放置到 /app/data/python/customize/static
中来覆盖(请参阅 Docker 容器卷)。例如,创建 /app/data/python/customize/static/favicon.ico
将替换 favicon。
提示
在容器启动时,这些文件被复制到相应的位置,因此需要在更改卷的内容后重新启动 Weblate 。
或者,您也可以包括自己的模块(请参阅 定制 Weblate),并将其作为单独的卷添加到 Docker 容器中,例如:
weblate:
volumes:
- weblate-data:/app/data
- ./weblate_customization/weblate_customization:/app/data/python/weblate_customization
environment:
WEBLATE_ADD_APPS: weblate_customization
添加自己的 Python 模块¶
3.8-5 新版功能.
您可以将自己的 Python 模块放置在 /app/data/python/
中(请参阅 Docker 容器卷),然后可以由 Weblate 加载它们,很可能是使用 定制配置文件。
参见
Hub 设置¶
为了使用 GitHub 的 pull-request 功能,您必须通过进入 Weblate 容器并执行任意 Hub 命令来初始化 Hub 配置。例如:
docker-compose exec --user weblate weblate bash
cd
HOME=/app/data/home hub clone octocat/Spoon-Knife
为凭据传递的用户名必须与 GITHUB_USERNAME
相同。
参见
Lab 设置¶
为了使用 GitLab 的 merge-request 功能,您必须通过进入 Weblate 容器并执行 lab
命令来初始化 lab
配置。例如:
docker-compose exec --user weblate weblate bash
cd
HOME=/app/data/home lab
您还可以使用环境变量在每个容器启动时配置 lab
。只需将 WEBLATE_GITLAB_USERNAME
,WEBLATE_GITLAB_HOST
和 WEBLATE_GITLAB_TOKEN
添加到您的环境配置中即可。
weblate:
environment:
WEBLATE_GITLAB_USERNAME: translations_bot
WEBLATE_GITLAB_HOST: https://gitlab.example.com
WEBLATE_GITLAB_TOKEN: personal_access_token_of_translations_bot
为 lab 配置传递的 access_token
必须与 GITLAB_USERNAME
相同。
选择您的机器 —— 本地或云提供商¶
使用 Docker Machine,您可以在本地计算机上或在任何数量的基于云的部署,例如 Amazon AWS,Greenhost 和许多其他提供商上创建 Weblate 部署。