-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdeploy.sh
More file actions
executable file
·73 lines (63 loc) · 2.61 KB
/
deploy.sh
File metadata and controls
executable file
·73 lines (63 loc) · 2.61 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#!/bin/bash
# =============================================================================
# Fractal Renderer — EC2 deploy script
# Works on t3a.micro (1GB RAM) and above
#
# Usage:
# curl -fsSL https://raw.githubusercontent.com/GeoffreyWang1117/Mandelbrot-Renderer/main/deploy.sh | bash
#
# Or clone and run:
# git clone https://github.com/GeoffreyWang1117/Mandelbrot-Renderer.git
# cd Mandelbrot-Renderer && bash deploy.sh
# =============================================================================
set -e
REPO="GeoffreyWang1117/Mandelbrot-Renderer"
GHCR_OWNER="geoffreywang1117"
echo "=== Fractal Renderer — EC2 Deployment ==="
echo ""
# 1. Install Docker if missing
if ! command -v docker &>/dev/null; then
echo "[1/4] Installing Docker..."
curl -fsSL https://get.docker.com | sh
sudo usermod -aG docker "$USER"
echo "Docker installed. You may need to log out and back in for group changes."
else
echo "[1/4] Docker already installed."
fi
# 2. Install docker compose plugin if missing
if ! docker compose version &>/dev/null 2>&1; then
echo "[2/4] Installing Docker Compose plugin..."
sudo apt-get update -qq && sudo apt-get install -y -qq docker-compose-plugin 2>/dev/null || \
sudo yum install -y docker-compose-plugin 2>/dev/null || \
echo "Please install docker-compose-plugin manually."
else
echo "[2/4] Docker Compose already installed."
fi
# 3. Get compose file
echo "[3/4] Fetching production compose file..."
if [ ! -f docker-compose.prod.yml ]; then
curl -fsSL "https://raw.githubusercontent.com/${REPO}/main/docker-compose.prod.yml" -o docker-compose.prod.yml
fi
# 4. Pull and start
echo "[4/4] Pulling images and starting services..."
docker compose -f docker-compose.prod.yml pull
docker compose -f docker-compose.prod.yml up -d
echo ""
echo "=== Deployment complete! ==="
echo ""
echo "Services:"
docker compose -f docker-compose.prod.yml ps --format "table {{.Name}}\t{{.Status}}\t{{.Ports}}"
echo ""
# Get public IP
PUBLIC_IP=$(curl -s --connect-timeout 3 http://169.254.169.254/latest/meta-data/public-ipv4 2>/dev/null || \
curl -s --connect-timeout 3 https://ifconfig.me 2>/dev/null || \
echo "YOUR_EC2_IP")
echo "Access your Fractal Renderer:"
echo " Web UI: http://${PUBLIC_IP}/"
echo " API: http://${PUBLIC_IP}/api"
echo ""
echo "Useful commands:"
echo " docker compose -f docker-compose.prod.yml logs -f # View logs"
echo " docker compose -f docker-compose.prod.yml down # Stop"
echo " docker compose -f docker-compose.prod.yml pull # Update images"
echo " docker stats # Monitor resources"