Set up libretranslate for kosmos.social
This commit is contained in:
parent
3933e4c310
commit
ed0e030106
|
@ -25,6 +25,7 @@
|
|||
"s3_region": "garage",
|
||||
"s3_bucket": "kosmos-social",
|
||||
"s3_alias_host": "s3.kosmos.social",
|
||||
"libre_translate_endpoint": "http://127.0.0.1:5000",
|
||||
"alternate_domains": [
|
||||
"mastodon.w7nooprauv6yrnhzh2ajpcnj3doinked2aaztlwfyt6u6pva2qdxqhid.onion"
|
||||
]
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
"kosmos_garage::default",
|
||||
"kosmos_garage::firewall_rpc",
|
||||
"kosmos_postgresql::hostsfile",
|
||||
"kosmos-mastodon::libretranslate",
|
||||
"kosmos-mastodon",
|
||||
"kosmos-mastodon::default",
|
||||
"kosmos-mastodon::backup",
|
||||
|
@ -45,6 +46,8 @@
|
|||
"hostname::default",
|
||||
"firewall::default",
|
||||
"chef-sugar::default",
|
||||
"git::default",
|
||||
"git::package",
|
||||
"kosmos-nodejs::default",
|
||||
"nodejs::nodejs_from_package",
|
||||
"nodejs::repo",
|
||||
|
@ -64,9 +67,7 @@
|
|||
"nodejs::npm",
|
||||
"nodejs::install",
|
||||
"backup::default",
|
||||
"logrotate::default",
|
||||
"git::default",
|
||||
"git::package"
|
||||
"logrotate::default"
|
||||
],
|
||||
"platform": "ubuntu",
|
||||
"platform_version": "20.04",
|
||||
|
|
|
@ -2,6 +2,7 @@ name "mastodon"
|
|||
|
||||
run_list %w(
|
||||
role[postgresql_client]
|
||||
kosmos-mastodon::libretranslate
|
||||
kosmos-mastodon
|
||||
kosmos-mastodon::backup
|
||||
)
|
||||
|
|
|
@ -8,6 +8,7 @@ node.default["kosmos-mastodon"]["server_name"] = "kosmos.social"
|
|||
node.default["kosmos-mastodon"]["alternate_domains"] = []
|
||||
node.default["kosmos-mastodon"]["redis_url"] = "redis://localhost:6379/0"
|
||||
node.default["kosmos-mastodon"]["sidekiq_threads"] = 25
|
||||
node.default["kosmos-mastodon"]["allowed_private_addresses"] = "127.0.0.1"
|
||||
|
||||
node.default["kosmos-mastodon"]["onion_address"] = nil
|
||||
|
||||
|
@ -19,4 +20,7 @@ node.default["kosmos-mastodon"]["s3_region"] = nil
|
|||
node.default["kosmos-mastodon"]["s3_bucket"] = nil
|
||||
node.default["kosmos-mastodon"]["s3_alias_host"] = nil
|
||||
|
||||
node.default["kosmos-mastodon"]["default_locale"] = "en"
|
||||
node.default["kosmos-mastodon"]["libre_translate_endpoint"] = nil
|
||||
|
||||
node.override["redisio"]["version"] = "6.2.6"
|
||||
|
|
|
@ -175,7 +175,10 @@ application mastodon_path do
|
|||
vapid_private_key: mastodon_credentials['vapid_private_key'],
|
||||
vapid_public_key: mastodon_credentials['vapid_public_key'],
|
||||
db_pass: postgresql_data_bag_item['mastodon_user_password'],
|
||||
db_host: "pg.kosmos.local"
|
||||
db_host: "pg.kosmos.local",
|
||||
default_locale: node["kosmos-mastodon"]["default_locale"],
|
||||
allowed_private_addresses: node["kosmos-mastodon"]["allowed_private_addresses"],
|
||||
libre_translate_endpoint: node["kosmos-mastodon"]["libre_translate_endpoint"]
|
||||
notifies :restart, "application[#{mastodon_path}]", :delayed
|
||||
end
|
||||
|
||||
|
|
|
@ -0,0 +1,64 @@
|
|||
#
|
||||
# Cookbook Name:: kosmos-mastodon
|
||||
# Recipe:: libretranslate
|
||||
#
|
||||
|
||||
build_essential
|
||||
include_recipe "git"
|
||||
|
||||
version = "1.3.8"
|
||||
|
||||
%w{ python3 python3-pip python3-setuptools python3-dev }.each do |pkg|
|
||||
apt_package pkg
|
||||
end
|
||||
|
||||
user "libretranslate" do
|
||||
shell '/bin/bash'
|
||||
home "/opt/libretranslate"
|
||||
manage_home true
|
||||
end
|
||||
|
||||
bash "install_libretranslate" do
|
||||
code "sudo -u libretranslate pip3 install --user --prefer-binary libretranslate==#{version}"
|
||||
action :run
|
||||
not_if { `sudo -u libretranslate pip3 list |grep libretranslate`.split(' ')[1] == version rescue false }
|
||||
notifies :restart, "service[libretranslate]", :delayed
|
||||
end
|
||||
|
||||
languages = `sudo -u libretranslate /opt/libretranslate/.local/bin/argospm search`
|
||||
languages.each_line do |line|
|
||||
lang = line.split(':').first
|
||||
|
||||
bash "install_lt_#{lang}" do
|
||||
code "sudo -u libretranslate /opt/libretranslate/.local/bin/argospm install #{lang}"
|
||||
action :nothing
|
||||
end
|
||||
end
|
||||
|
||||
systemd_unit "libretranslate.service" do
|
||||
content({
|
||||
Unit: {
|
||||
Description: "LibreTranslate",
|
||||
Documentation: ["https://github.com/LibreTranslate/LibreTranslate"],
|
||||
After: "network.target"
|
||||
},
|
||||
Service: {
|
||||
Type: "simple",
|
||||
User: "libretranslate",
|
||||
Group: "libretranslate",
|
||||
WorkingDirectory: "/opt/libretranslate/",
|
||||
ExecStart: "/opt/libretranslate/.local/bin/libretranslate --host 127.0.0.1 --port 5000 --disable-files-translation",
|
||||
Restart: "always"
|
||||
},
|
||||
Install: {
|
||||
WantedBy: "multi-user.target"
|
||||
}
|
||||
})
|
||||
verify false
|
||||
triggers_reload true
|
||||
action [:create, :enable]
|
||||
end
|
||||
|
||||
service "libretranslate" do
|
||||
action [:enable, :start]
|
||||
end
|
|
@ -35,6 +35,9 @@ SMTP_FROM_ADDRESS=<%= @smtp_from_address %>
|
|||
# Serve static files (to nginx proxy)
|
||||
RAILS_SERVE_STATIC_FILES=true
|
||||
|
||||
# Private addresses/subnets to allow outgoing HTTP requests to
|
||||
ALLOWED_PRIVATE_ADDRESSES=<%= @allowed_private_addresses %>
|
||||
|
||||
<% if @s3_endpoint %>
|
||||
# S3 (optional)
|
||||
S3_ENABLED=true
|
||||
|
@ -46,6 +49,14 @@ AWS_ACCESS_KEY_ID=<%= @aws_access_key_id %>
|
|||
AWS_SECRET_ACCESS_KEY=<%= @aws_secret_access_key %>
|
||||
<% end %>
|
||||
|
||||
# locale
|
||||
DEFAULT_LOCALE=<%= @default_locale %>
|
||||
|
||||
<% if @libre_translate_endpoint %>
|
||||
# translate
|
||||
LIBRE_TRANSLATE_ENDPOINT=<%= @libre_translate_endpoint %>
|
||||
<% end %>
|
||||
|
||||
# Optional alias for S3 if you want to use Cloudfront or Cloudflare in front
|
||||
# S3_CLOUDFRONT_HOST=
|
||||
|
||||
|
|
Loading…
Reference in New Issue