node entfernt

This commit is contained in:
2025-04-27 06:49:59 +02:00
parent d42c43db50
commit 1c59b0b616
6094 changed files with 1462 additions and 746934 deletions

86
deploy.py Executable file
View File

@@ -0,0 +1,86 @@
#!/usr/bin/env python3
import os
import subprocess
import sys
import shutil
from pathlib import Path
def main():
"""Deploy the website on a server"""
print("Deploying the website on the server...")
# Get the directory where deploy.py is located (project root)
project_root = Path(__file__).resolve().parent
website_dir = project_root / "website"
# Check if virtual environment exists, create if not
venv_dir = project_root / "venv"
if not venv_dir.exists():
print("Creating virtual environment...")
subprocess.run([sys.executable, "-m", "venv", str(venv_dir)], check=True)
# Determine Python and pip paths based on OS
if os.name == 'nt': # Windows
python = venv_dir / "Scripts" / "python"
pip = venv_dir / "Scripts" / "pip"
else: # Unix-like
python = venv_dir / "bin" / "python"
pip = venv_dir / "bin" / "pip"
# Install dependencies
print("Installing dependencies...")
subprocess.run([str(pip), "install", "-r", str(website_dir / "requirements.txt")], check=True)
subprocess.run([str(pip), "install", "gunicorn"], check=True)
# Build CSS
print("Building CSS with Tailwind...")
subprocess.run([str(python), str(website_dir / "build_css.py")], check=True)
# Create a systemd service file
service_file = """[Unit]
Description=MindMap Wissensnetzwerk
After=network.target
[Service]
User=www-data
WorkingDirectory={website_dir}
Environment="PATH={venv_bin}"
ExecStart={gunicorn} --workers 3 --bind 0.0.0.0:5000 --log-level info 'run:app'
Restart=always
[Install]
WantedBy=multi-user.target
""".format(
website_dir=website_dir,
venv_bin=venv_dir / "bin",
gunicorn=venv_dir / "bin" / "gunicorn"
)
service_path = project_root / "mindmap.service"
with open(service_path, 'w') as f:
f.write(service_file)
print(f"""
Deployment files created!
To install the service on a Linux server:
1. Copy the systemd service file:
sudo cp {service_path} /etc/systemd/system/
2. Reload systemd:
sudo systemctl daemon-reload
3. Enable and start the service:
sudo systemctl enable mindmap.service
sudo systemctl start mindmap.service
4. Check service status:
sudo systemctl status mindmap.service
Alternatively, you can run the application with gunicorn manually:
cd {website_dir}
{venv_dir}/bin/gunicorn --workers 3 --bind 0.0.0.0:5000 'run:app'
""")
if __name__ == "__main__":
main()