deploy.sh Automated Hetzner Deploy Script

Vite + Supabase + PM2 + Nginx Deploy Script

This script sets up a Hetzner server to host a Vite app from GitHub using PM2, Nginx, Certbot SSL, and Supabase environment variables.

Instructions

  1. Edit the DOMAIN, REPO, EMAIL, and Supabase variables at the top.
  2. Upload the script to your server (e.g., /root/deploy.sh).
  3. Make it executable: chmod +x deploy.sh.
  4. Run it: ./deploy.sh.

Deploy Script

#!/usr/bin/env bash
set -euo pipefail

######################
#  EDIT THESE FIRST  #
######################
DOMAIN="espressocafebar.eu"
REPO="https://github.com/youruser/your-vite-repo.git"
EMAIL="your-email@example.com"

# --- Supabase / ENV settings ---
SUPABASE_URL="https://dagnscrjrktrrspyamwu.supabase.co"
SUPABASE_ANON_KEY="eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFz..."
WEBHOOK_AUTH_TOKEN="hWrqAUlCk52lXEDD9OyjS4cuU7XWU9"

######################

# 1) System update & prerequisites
apt update && apt upgrade -y
apt install -y curl git nginx certbot python3-certbot-nginx

# Install Node.js 20.x
curl -fsSL https://deb.nodesource.com/setup_20.x | bash -
apt install -y nodejs

# 2) Clone & build prep
TARGET="/var/www/$DOMAIN"
rm -rf "$TARGET"
mkdir -p "$TARGET"
git clone "$REPO" "$TARGET"
cd "$TARGET"

# 2a) Create .env for Vite/Supabase
cat > .env </dev/null || true
pm2 serve "$TARGET/dist" 3000 --name "$DOMAIN" --spa
pm2 save
pm2 startup systemd --silent

# 4) Nginx config
CONF="/etc/nginx/sites-available/$DOMAIN"
cat > "$CONF" <

Намирате ли за полезно?

  • Palm Fitness information

    The project is currently deployed at demo.automationaid.eu. It is uploaded to Sava Barbarov's GitHub...
  • Forbidden Knowledge

    Supabase MCP The Supabase MCP, as demonstrated in the YouTube video, offers more than just basic fun...
  • n8n System Message template

    Guide to n8n AI Agents - System Messages   Writing Tips Be Direct & Unambiguous: Use clea...
  • n8n backend update

    Предварителни С&...
  • Supabase KB

    Welcome to our comprehensive knowledge base, designed to provide you with valuable insights, tips, a...