| 1 | set -e |
| 2 | cd "$(dirname "$0")/.." |
| 3 | |
| 4 | declare -A TARGETS=( |
| 5 | [nodejwt]="targets/node-jsonwebtoken:7001" |
| 6 | [pyjwt]="targets/pyjwt:7002" |
| 7 | [pyjose]="targets/python-jose:7003" |
| 8 | [panva]="targets/jose-panva:7004" |
| 9 | [gojwt]="targets/golang-jwt:7005" |
| 10 | ) |
| 11 | |
| 12 | ONLY="${1:-}" |
| 13 | |
| 14 | for name in "${!TARGETS[@]}"; do |
| 15 | if [[ -n "$ONLY" && "$ONLY" != "$name" ]]; then continue; fi |
| 16 | ctx="${TARGETS[$name]%:*}" |
| 17 | port="${TARGETS[$name]##*:}" |
| 18 | img="schism-$name" |
| 19 | echo "[build] $name <- $ctx" |
| 20 | docker build -q -t "$img" "$ctx" >/dev/null |
| 21 | echo "[run] $name :$port" |
| 22 | docker rm -f "schism-$name" >/dev/null 2>&1 || true |
| 23 | docker run -d --name "schism-$name" -p "$port:$port" --restart unless-stopped "$img" >/dev/null |
| 24 | done |
| 25 | |
| 26 | echo "[ready] sleeping 2s for boot..." |
| 27 | sleep 2 |
| 28 | for name in "${!TARGETS[@]}"; do |
| 29 | if [[ -n "$ONLY" && "$ONLY" != "$name" ]]; then continue; fi |
| 30 | port="${TARGETS[$name]##*:}" |
| 31 | if curl -s -o /dev/null -w "%{http_code}" -X POST "http://localhost:$port/verify" \ |
| 32 | -H 'Content-Type: application/json' -d '{"token":"","key":"","algs":[]}' \ |
| 33 | | grep -q 200; then |
| 34 | echo " ok $name :$port" |
| 35 | else |
| 36 | echo " ?? $name :$port (not 200 - check logs: docker logs schism-$name)" |
| 37 | fi |
| 38 | done |