blonk is a radar for your web, where you follow vibes for cool blips on the radar
1#!/bin/bash
2set -e
3
4echo "🚀 Deploying Blonk to Fly.io..."
5
6# Set PATH to include fly
7export PATH="/root/.fly/bin:$PATH"
8
9# Check if authenticated
10if ! fly auth whoami > /dev/null 2>&1; then
11 echo "❌ Not authenticated with Fly.io"
12 echo "Please run: fly auth login"
13 exit 1
14fi
15
16echo "📋 Current Fly.io status:"
17fly auth whoami
18
19# Create app if it doesn't exist
20if ! fly apps list | grep -q "^blonk"; then
21 echo "📦 Creating new Fly app..."
22 fly apps create blonk --org personal
23 echo "✅ App 'blonk' created!"
24else
25 echo "✅ App 'blonk' already exists"
26fi
27
28# Create PostgreSQL database if it doesn't exist
29if ! fly postgres list | grep -q "blonk-db"; then
30 echo "🗄️ Creating PostgreSQL database..."
31 fly postgres create --name blonk-db --region dfw --vm-size shared-cpu-1x --volume-size 1
32 echo "✅ Database 'blonk-db' created!"
33
34 # Wait a moment for database to be ready
35 echo "⏳ Waiting for database to be ready..."
36 sleep 10
37else
38 echo "✅ Database 'blonk-db' already exists"
39fi
40
41# Set up secrets
42echo "🔑 Setting up secrets..."
43if [ -f "./setup-fly-secrets.sh" ]; then
44 echo "Running automated secrets setup..."
45 ./setup-fly-secrets.sh
46else
47 echo "Manual secrets setup required:"
48 echo "fly secrets set SECRET_KEY_BASE=\$(mix phx.gen.secret)"
49 echo "fly secrets set RELEASE_COOKIE=\$(mix phx.gen.secret)"
50 echo "fly secrets set DATABASE_URL=\$(fly postgres connect-string blonk-db)"
51 echo "fly secrets set PHX_HOST=blonk.fly.dev"
52 echo "fly secrets set MIX_ENV=prod"
53 echo "fly secrets set PORT=8080"
54 echo ""
55 echo "ATProto credentials (set manually):"
56 echo "fly secrets set ATPROTO_IDENTIFIER=your_bluesky_handle"
57 echo "fly secrets set ATPROTO_PASSWORD=your_bluesky_app_password"
58 exit 1
59fi
60
61# Show current secrets (without values)
62echo "📋 Current secrets:"
63fly secrets list
64
65# Build and deploy
66echo "🔨 Building and deploying..."
67fly deploy
68
69echo ""
70echo "✅ Deployment complete!"
71echo "🌐 Visit your app at: https://blonk.fly.dev"
72echo "📊 Monitor with: fly logs"
73echo "🗄️ Check database: fly postgres connect blonk-db"
74echo ""
75echo "🔧 Useful commands:"
76echo " fly status - Check app status"
77echo " fly logs - View application logs"
78echo " fly ssh console - SSH into the app"
79echo " fly scale count 1 - Scale to 1 instance"
80echo " fly secrets list - View secrets"