-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdeploy.sh
More file actions
69 lines (59 loc) · 2.16 KB
/
Copy pathdeploy.sh
File metadata and controls
69 lines (59 loc) · 2.16 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
#!/bin/bash
# Deploy script for Lead Finder Pro on VPS
set -e
PROJECT="leadfinderpro"
GITHUB_URL="https://github.com/CreativeCodingSolutions/lead-finder-pro.git"
APP_DIR="/home/deployer/www/${PROJECT}"
DYNAMIC_FILE="/docker/traefik/dynamic/dynamic.yml"
APP_PORT="10000"
echo "=== Deploying ${PROJECT} ==="
# 1. Clone or pull
if [ -d "$APP_DIR/.git" ]; then
echo "→ Pulling latest..."
cd "$APP_DIR"
git pull origin main 2>&1 || git pull origin master 2>&1
else
echo "→ Cloning..."
git clone "$GITHUB_URL" "$APP_DIR" 2>&1
cd "$APP_DIR"
fi
# 2. Build and start with Docker Compose
echo "→ Building Docker container..."
docker compose down 2>/dev/null || true
docker compose build --no-cache
docker compose up -d
# 3. Wait for container to be ready
echo "→ Waiting for container..."
sleep 5
# 4. Run Laravel setup
echo "→ Laravel setup..."
docker compose exec -T app php artisan key:generate --force 2>/dev/null || true
docker compose exec -T app php artisan config:cache 2>/dev/null || true
docker compose exec -T app php artisan route:cache 2>/dev/null || true
docker compose exec -T app php artisan view:cache 2>/dev/null || true
docker compose exec -T app php artisan migrate --force 2>/dev/null || true
# 5. Permissions
docker compose exec -T app chmod -R 775 storage bootstrap/cache 2>/dev/null || true
# 6. Update Traefik dynamic config
echo "→ Updating Traefik config..."
if grep -q "${PROJECT}.creativecoding.cloud" "$DYNAMIC_FILE" 2>/dev/null; then
echo "→ Already in Traefik"
else
python3 << PYEOF
import yaml
with open("${DYNAMIC_FILE}", "r") as f:
config = yaml.safe_load(f)
config["http"]["services"]["${PROJECT}"] = {"loadBalancer": {"servers": [{"url": "http://localhost:${APP_PORT}"}]}}
config["http"]["routers"]["${PROJECT}"] = {
"rule": "Host(`${PROJECT}.creativecoding.cloud`)",
"entryPoints": ["websecure"],
"service": "${PROJECT}",
"tls": {"certResolver": "letsencrypt"}
}
with open("${DYNAMIC_FILE}", "w") as f:
yaml.dump(config, f, default_flow_style=False, allow_unicode=True)
PYEOF
docker restart traefik 2>&1 || true
fi
echo "=== ${PROJECT} deployed! ==="
echo "→ https://${PROJECT}.creativecoding.cloud"