Monorepo for Aesthetic.Computer aesthetic.computer
at main 80 lines 2.9 kB view raw
1#!/usr/bin/env fish 2# Provision a new DO droplet for lith 3# Run locally — creates droplet, installs deps, clones repo 4 5set RED '\033[0;31m' 6set GREEN '\033[0;32m' 7set YELLOW '\033[1;33m' 8set NC '\033[0m' 9 10set DROPLET_NAME "ac-lith" 11set REGION "sfo3" 12set SIZE "s-2vcpu-4gb" 13set IMAGE "ubuntu-24-04-x64" 14 15# Get SSH key IDs 16echo -e "$GREEN-> Fetching SSH keys...$NC" 17set SSH_KEYS (doctl compute ssh-key list --format ID --no-header | string join ',') 18 19if test -z "$SSH_KEYS" 20 echo -e "$RED x No SSH keys found in DO account$NC" 21 exit 1 22end 23 24echo -e "$GREEN-> Creating droplet $DROPLET_NAME ($SIZE in $REGION)...$NC" 25set DROPLET_ID (doctl compute droplet create $DROPLET_NAME \ 26 --region $REGION \ 27 --size $SIZE \ 28 --image $IMAGE \ 29 --ssh-keys $SSH_KEYS \ 30 --tag-names ac,lith,web \ 31 --wait \ 32 --format ID \ 33 --no-header) 34 35set DROPLET_IP (doctl compute droplet get $DROPLET_ID --format PublicIPv4 --no-header) 36 37echo -e "$GREEN-> Droplet created: $DROPLET_NAME @ $DROPLET_IP$NC" 38echo -e "$YELLOW Save this IP for Cloudflare DNS updates!$NC" 39echo "" 40echo "LITH_IP=$DROPLET_IP" > /tmp/lith-droplet.env 41echo "LITH_ID=$DROPLET_ID" >> /tmp/lith-droplet.env 42 43# Wait for SSH 44echo -e "$GREEN-> Waiting for SSH...$NC" 45sleep 10 46while not ssh -o StrictHostKeyChecking=no -o ConnectTimeout=5 root@$DROPLET_IP "echo ok" &>/dev/null 47 sleep 5 48end 49 50# Install stack 51echo -e "$GREEN-> Installing Caddy + Node.js + system deps...$NC" 52ssh root@$DROPLET_IP " 53 # Caddy 54 apt-get update -qq 55 apt-get install -y -qq debian-keyring debian-archive-keyring apt-transport-https curl 56 curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/gpg.key' | gpg --dearmor -o /usr/share/keyrings/caddy-stable-archive-keyring.gpg 57 curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/debian.deb.txt' | tee /etc/apt/sources.list.d/caddy-stable.list 58 apt-get update -qq 59 apt-get install -y -qq caddy 60 61 # Node.js 22 LTS 62 curl -fsSL https://deb.nodesource.com/setup_22.x | bash - 63 apt-get install -y -qq nodejs 64 65 # Sharp + Puppeteer deps 66 apt-get install -y -qq libvips-dev chromium-browser git 67 68 # Clone repo 69 git clone https://github.com/aesthetic-computer/aesthetic-computer.git /opt/ac 70 cd /opt/ac/lith && npm install 71 cd /opt/ac/system && npm install 72" 73 74echo -e "$GREEN-> Droplet provisioned.$NC" 75echo -e "$YELLOW-> Next steps:$NC" 76echo " 1. Upload .env: scp vault/netlify-production.env root@$DROPLET_IP:/opt/ac/system/.env" 77echo " 2. Upload Caddyfile: scp lith/Caddyfile root@$DROPLET_IP:/etc/caddy/Caddyfile" 78echo " 3. Install service: scp lith/lith.service root@$DROPLET_IP:/etc/systemd/system/" 79echo " 4. Enable service: ssh root@$DROPLET_IP 'systemctl daemon-reload && systemctl enable --now lith && systemctl reload caddy'" 80echo " 5. Update DNS: Point 36 records to $DROPLET_IP (see vault/cloudflare-dns-records.md)"