Files
opencare/deploy/setup_vps.sh
laurentbarontini efd775706b Initial production-ready release of OpenCare v1
- Flask/SQLAlchemy app with profile, dashboard, recommendations
- AI crawl pipeline (GPT-4o) with admin review workflow
- 14 curated health sources (RSS + index crawling)
- Production config: env vars, Gunicorn, systemd, nginx
- deploy/ scripts for VPS setup and updates

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-05 21:38:03 +02:00

64 lines
1.8 KiB
Bash

#!/bin/bash
# Script d'installation OpenCare sur VPS Ubuntu/Debian
# Usage : sudo bash setup_vps.sh
set -e
APP_DIR=/opt/opencare
APP_USER=www-data
REPO=https://gitea.open-squared.tech/admin/opencare.git
echo "=== Installation OpenCare ==="
# 1. Dépendances système
apt-get update -qq
apt-get install -y python3 python3-pip python3-venv nginx git
# 2. Cloner / mettre à jour le repo
if [ -d "$APP_DIR/.git" ]; then
echo "--- Mise à jour du code ---"
cd "$APP_DIR" && git pull
else
echo "--- Clonage du repo ---"
git clone "$REPO" "$APP_DIR"
fi
cd "$APP_DIR"
# 3. Environnement virtuel Python
if [ ! -d "$APP_DIR/venv" ]; then
python3 -m venv venv
fi
venv/bin/pip install -q --upgrade pip
venv/bin/pip install -q -r requirements.txt
# 4. Fichier .env (créer si absent)
if [ ! -f "$APP_DIR/.env" ]; then
cp .env.example .env
SECRET=$(python3 -c "import secrets; print(secrets.token_hex(32))")
sed -i "s/change-me-with-a-strong-random-key/$SECRET/" .env
echo "ATTENTION : .env créé avec une clé secrète aléatoire."
echo "Editez /opt/opencare/.env pour configurer DATABASE_URL et autres."
fi
# 5. Dossier instance (SQLite)
mkdir -p "$APP_DIR/instance"
chown -R "$APP_USER:$APP_USER" "$APP_DIR"
# 6. Service systemd
cp deploy/opencare.service /etc/systemd/system/opencare.service
systemctl daemon-reload
systemctl enable opencare
systemctl restart opencare
# 7. Nginx
cp deploy/nginx.conf /etc/nginx/sites-available/opencare
ln -sf /etc/nginx/sites-available/opencare /etc/nginx/sites-enabled/opencare
rm -f /etc/nginx/sites-enabled/default
nginx -t && systemctl reload nginx
echo ""
echo "=== Déploiement terminé ==="
echo "L'application tourne sur http://$(hostname -I | awk '{print $1}')"
echo "Consultez les logs : journalctl -u opencare -f"