#Need 2Go memory 
#Need 5go space
apt-get install --no-install-recommends -y libicu-dev pkg-config gcc g++ python3-pip python3-dev
useradd libretranslate -r -s /bin/false -m -d /usr/lib/libretranslate
 
su - -s /bin/bash -c "pip install libretranslate" libretranslate
rm -fr /usr/lib/libretranslate/.cache
 
cat << EOF > /etc/systemd/system/libretranslate.service
[Unit]
Description=libretranslate
 
[Service]
Type=exec
User=libretranslate
WorkingDirectory=/usr/lib/libretranslate
ExecStart=/usr/lib/libretranslate/.local/bin/libretranslate --load-only fr,en --host 0.0.0.0 --port 8080 --frontend-language-source en --frontend-language-target fr --req-limit 10
Restart=on-failure
RestartSec=30s
 
# Optional hardening to improve security
ReadWritePaths=/usr/lib/libretranslate
 
[Install]
WantedBy=multi-user.target
EOF
 
systemctl start libretranslate
systemctl enable libretranslate