Monorepo for Aesthetic.Computer
aesthetic.computer
1#!/usr/bin/env fish
2# Deploy user pages to at.aesthetic.computer PDS
3# This updates the Caddy config to serve custom user pages on wildcard subdomains
4# Usage: fish deploy-user-pages.fish
5
6# Get the directory where this script lives
7set SCRIPT_DIR (dirname (status --current-filename))
8
9set LANDING_PAGE_LOCAL "$SCRIPT_DIR/landing-page.html"
10set USER_PAGE_LOCAL "$SCRIPT_DIR/user-page.html"
11set PDS_SERVER "root@165.227.120.137"
12set WEB_ROOT "/pds/caddy/data/www"
13set CADDY_WEB_ROOT "/data/www"
14set SSH_KEY "$HOME/.ssh/aesthetic_pds"
15
16echo "🚀 Deploying user pages to at.aesthetic.computer"
17echo ""
18
19# Check if files exist
20if not test -f $LANDING_PAGE_LOCAL
21 echo "❌ Error: landing-page.html not found"
22 exit 1
23end
24
25if not test -f $USER_PAGE_LOCAL
26 echo "❌ Error: user-page.html not found"
27 exit 1
28end
29
30echo "📤 Uploading pages to /tmp on PDS server..."
31
32# Upload to /tmp directory (temporary staging)
33scp -i $SSH_KEY $LANDING_PAGE_LOCAL "$PDS_SERVER:/tmp/index.html"
34scp -i $SSH_KEY $USER_PAGE_LOCAL "$PDS_SERVER:/tmp/user.html"
35
36if test $status -ne 0
37 echo "❌ Failed to upload pages"
38 exit 1
39end
40
41echo "✅ Pages uploaded to /tmp"
42
43echo "📦 Copying files into Caddy container..."
44ssh -i $SSH_KEY $PDS_SERVER 'docker cp /tmp/index.html caddy:/data/www/index.html && docker cp /tmp/user.html caddy:/data/www/user.html'
45
46if test $status -ne 0
47 echo "❌ Failed to copy files into container"
48 exit 1
49end
50
51echo "✅ Files copied into container at /data/www"
52echo ""
53echo "🔧 Configuring Caddy to serve custom user pages..."
54
55# SSH into server and update Caddyfile
56ssh -i $SSH_KEY $PDS_SERVER '
57 # Backup existing Caddyfile
58 cp /pds/caddy/etc/caddy/Caddyfile /pds/caddy/etc/caddy/Caddyfile.backup
59
60 # Create new Caddyfile with custom pages
61 cat > /pds/caddy/etc/caddy/Caddyfile << "EOF"
62{
63 email me@jas.life
64 on_demand_tls {
65 ask http://localhost:3000/tls-check
66 }
67}
68
69# Main domain with custom landing page
70at.aesthetic.computer {
71 tls {
72 on_demand
73 }
74
75 # Serve custom landing page for root
76 handle / {
77 root * /data/www
78 file_server
79 }
80
81 # Proxy all other requests to PDS
82 handle {
83 reverse_proxy http://localhost:3000
84 }
85}
86
87# Wildcard for user handles - serve custom user page at root
88*.at.aesthetic.computer {
89 tls {
90 on_demand
91 }
92
93 root * /data/www
94
95 # Proxy media requests to aesthetic.computer to avoid CORS
96 handle /media/* {
97 reverse_proxy https://aesthetic.computer
98 }
99
100 # Proxy /xrpc/* to PDS for API access
101 handle /xrpc/* {
102 reverse_proxy http://localhost:3000
103 }
104
105 # Proxy .well-known for ATProto
106 handle /.well-known/* {
107 reverse_proxy http://localhost:3000
108 }
109
110 # Serve custom user page for root path
111 @root path /
112 handle @root {
113 rewrite * /user.html
114 file_server
115 }
116
117 # Serve all other static files
118 handle {
119 file_server
120 }
121}
122EOF
123
124 # Reload Caddy
125 docker exec caddy caddy reload --config /etc/caddy/Caddyfile
126'
127
128if test $status -eq 0
129 echo ""
130 echo "✅ Deployment complete!"
131 echo ""
132 echo "🌐 Landing page: https://at.aesthetic.computer"
133 echo "👤 User pages: https://[handle].at.aesthetic.computer"
134 echo "🔍 Health check: https://at.aesthetic.computer/xrpc/_health"
135 echo ""
136 echo "Example user pages:"
137 echo " https://fifi.at.aesthetic.computer"
138 echo " https://jeffrey.at.aesthetic.computer"
139 echo ""
140 echo "Note: User pages are served at subdomain root"
141 echo " All /xrpc/* routes still go to the PDS backend for API access"
142else
143 echo ""
144 echo "❌ Deployment failed"
145 exit 1
146end