#!/bin/bash # Run this once on the VPS to set up the service # ssh -p 4422 vps-hetzner "bash -s" < vps-setup.sh set -e APP_DIR="/opt/nav-carte" PORT=3333 # Create app directory mkdir -p "$APP_DIR" # Create systemd service cat > /etc/systemd/system/nav-carte.service << EOF [Unit] Description=NAV Carte des institutions (Nuxt 3) After=network.target [Service] Type=simple User=root WorkingDirectory=$APP_DIR ExecStart=/usr/bin/node $APP_DIR/server/index.mjs Restart=on-failure RestartSec=5 Environment=PORT=$PORT Environment=HOST=0.0.0.0 EnvironmentFile=$APP_DIR/.env [Install] WantedBy=multi-user.target EOF systemctl daemon-reload systemctl enable nav-carte echo "Service created. Run 'systemctl start nav-carte' after deploy." echo "" echo "Add this to /etc/caddy/Caddyfile:" echo "" echo "nav.trans-former.fr {" echo " reverse_proxy localhost:$PORT" echo "}" echo "" echo "Then: systemctl reload caddy"