+80
deploy.sh
+80
deploy.sh
···
1
+
#!/bin/bash
2
+
set -e
3
+
4
+
echo "๐ Deploying Blonk to Fly.io..."
5
+
6
+
# Set PATH to include fly
7
+
export PATH="/root/.fly/bin:$PATH"
8
+
9
+
# Check if authenticated
10
+
if ! 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
14
+
fi
15
+
16
+
echo "๐ Current Fly.io status:"
17
+
fly auth whoami
18
+
19
+
# Create app if it doesn't exist
20
+
if ! 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!"
24
+
else
25
+
echo "โ
App 'blonk' already exists"
26
+
fi
27
+
28
+
# Create PostgreSQL database if it doesn't exist
29
+
if ! 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
37
+
else
38
+
echo "โ
Database 'blonk-db' already exists"
39
+
fi
40
+
41
+
# Set up secrets
42
+
echo "๐ Setting up secrets..."
43
+
if [ -f "./setup-fly-secrets.sh" ]; then
44
+
echo "Running automated secrets setup..."
45
+
./setup-fly-secrets.sh
46
+
else
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
59
+
fi
60
+
61
+
# Show current secrets (without values)
62
+
echo "๐ Current secrets:"
63
+
fly secrets list
64
+
65
+
# Build and deploy
66
+
echo "๐จ Building and deploying..."
67
+
fly deploy
68
+
69
+
echo ""
70
+
echo "โ
Deployment complete!"
71
+
echo "๐ Visit your app at: https://blonk.fly.dev"
72
+
echo "๐ Monitor with: fly logs"
73
+
echo "๐๏ธ Check database: fly postgres connect blonk-db"
74
+
echo ""
75
+
echo "๐ง Useful commands:"
76
+
echo " fly status - Check app status"
77
+
echo " fly logs - View application logs"
78
+
echo " fly ssh console - SSH into the app"
79
+
echo " fly scale count 1 - Scale to 1 instance"
80
+
echo " fly secrets list - View secrets"