-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdc
More file actions
executable file
·107 lines (103 loc) · 3.59 KB
/
dc
File metadata and controls
executable file
·107 lines (103 loc) · 3.59 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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
#!/usr/bin/env bash
# dc — Docker Compose wrapper for Maschina
# Usage: ./dc [command] [service?]
#
# Commands:
# start bring up all services (detached)
# stop stop all services
# restart restart all services (or one: ./dc restart api)
# kill force-kill all services (or one: ./dc kill daemon)
# down stop and remove containers
# reset stop, remove containers AND wipe volumes (nuclear)
# logs follow all logs (or one: ./dc logs api)
# ps / status show running containers + health check
# build build all images (or one: ./dc build api)
# rebuild rebuild and restart (or one: ./dc rebuild api)
# deploy pull latest + build + up + health check (full deploy)
set -euo pipefail
COMPOSE="docker compose -f docker/docker-compose.yml -f docker/docker-compose.services.yml --env-file .env"
cmd="${1:-help}"
svc="${2:-}"
case "$cmd" in
start|up)
$COMPOSE up -d $svc
;;
stop)
$COMPOSE stop $svc
;;
restart)
$COMPOSE restart $svc
;;
kill)
$COMPOSE kill $svc
;;
down)
$COMPOSE down $svc
;;
reset)
echo "WARNING: this wipes all volumes. Ctrl+C to cancel."
sleep 3
$COMPOSE down -v
;;
logs)
$COMPOSE logs -f $svc
;;
ps|status)
$COMPOSE ps
echo ""
echo "Health:"
curl -sf http://localhost:3000/health && echo " api ok" || echo " api FAIL"
curl -sf http://localhost:8080/health && echo " gateway ok" || echo " gateway FAIL"
curl -sf http://localhost:4000/health && echo " realtime ok" || echo " realtime FAIL"
curl -sf http://localhost:9090/-/healthy && echo " prometheus ok" || echo " prometheus FAIL"
curl -sf http://localhost:3030/api/health && echo " grafana ok" || echo " grafana FAIL"
;;
build)
$COMPOSE build $svc
;;
rebuild)
$COMPOSE up -d --build $svc
;;
deploy)
REPO_DIR="$(cd "$(dirname "$0")" && pwd)"
echo "→ Pulling latest code..."
git -C "$REPO_DIR" pull origin main
echo "→ Pulling latest images from GHCR..."
$COMPOSE pull --ignore-pull-failures || true
echo "→ Starting services..."
$COMPOSE up -d
echo "→ Waiting 30s for services to start..."
sleep 30
echo ""
echo "Health checks:"
API=$(curl -sf --max-time 5 http://localhost:3000/health 2>/dev/null && echo "ok" || echo "FAIL")
GW=$(curl -sf --max-time 5 http://localhost:8080/health 2>/dev/null && echo "ok" || echo "FAIL")
RT=$(curl -sf --max-time 5 http://localhost:4000/health 2>/dev/null && echo "ok" || echo "FAIL")
echo " api: $API"
echo " gateway: $GW"
echo " realtime: $RT"
echo ""
if [[ "$API" == "FAIL" || "$GW" == "FAIL" || "$RT" == "FAIL" ]]; then
echo "Deploy incomplete — check logs: ./dc logs [service]"
exit 1
fi
echo "Deploy complete."
;;
help|*)
echo "Usage: ./dc [command] [service]"
echo ""
echo " start bring everything up"
echo " stop stop everything"
echo " restart [service] restart all or one service"
echo " kill [service] force-kill all or one service"
echo " down stop and remove containers"
echo " reset !! wipes volumes too"
echo " logs [service] follow logs"
echo " ps / status containers + health check"
echo " build [service] build images"
echo " deploy pull + build + up + health check"
echo " rebuild [service] build + restart"
echo ""
echo "Services: api gateway daemon realtime runtime worker"
;;
esac