germany: server/ конфиги в репе, deploy_lang.sh → rsync + build на ВМ

This commit is contained in:
“Naeel”
2026-05-22 21:09:09 +04:00
parent d9ecab051d
commit cbb5b4917a
3 changed files with 95 additions and 11 deletions
+21 -11
View File
@@ -1,16 +1,26 @@
#!/bin/bash
set -e
VM="root@95.179.252.111"
SSH="ssh -i ~/.ssh/vultr_openssh -o StrictHostKeyChecking=no"
# Собираем dist/index.html (CSS + JS встроены)
~/lang/.venv/bin/python3 ~/lang/build.sh
echo "=== rsync repo -> VM ==="
rsync -az -e "$SSH" --exclude='.git' --exclude='.venv' --exclude='__pycache__' ~/lang/ ${VM}:/opt/lyngvo/
# Вклеиваем Groq API ключ в dist/index.html
KEY=$(cat ~/lang/token.txt)
cp ~/lang/dist/index.html /tmp/lyngvo_index.html
sed -i "s|const GROQ_API_KEY = '';|const GROQ_API_KEY = '${KEY}';|" /tmp/lyngvo_index.html
echo "=== build + deploy ==="
$SSH $VM "bash -c '
cd /opt/lyngvo
python3 build.sh
KEY=\$(cat token.txt)
sed -i \"s|const GROQ_API_KEY = .*;|const GROQ_API_KEY = '\\\''\$KEY'\\\'';|\" dist/index.html
cp dist/index.html /var/www/lyngvo/index.html
if [ -f server/lang.kube5s.ru.conf ]; then
cp server/lang.kube5s.ru.conf /etc/nginx/conf.d/
nginx -t && systemctl reload nginx
fi
if [ -f server/proxy.py ]; then
cp server/proxy.py /opt/groq-proxy/proxy.py
systemctl reload groq-proxy 2>/dev/null || true
fi
'"
# Деплой на германскую ВМ (nginx + Groq прокси)
scp -i ~/.ssh/vultr_openssh -o StrictHostKeyChecking=no /tmp/lyngvo_index.html root@95.179.252.111:/var/www/lyngvo/index.html
rm -f /tmp/lyngvo_index.html
echo "\n=== Деплой завершён. Проверяй https://lang.kube5s.ru ==="
echo "=== https://lang.kube5s.ru ==="