Files
cryptowallet/start.sh
2026-05-11 18:36:44 +03:00

42 lines
1.2 KiB
Bash

#!/bin/bash
set -euo pipefail
cd "$(dirname "$0")"
command -v docker >/dev/null 2>&1 || { echo "[ERROR] Docker not installed"; exit 1; }
docker compose version >/dev/null 2>&1 || { echo "[ERROR] docker compose plugin missing"; exit 1; }
if [ ! -f .env ]; then
if [ -f .env.example ]; then
cp .env.example .env
echo "[INFO] .env создан из примера — заполни Vault креды и запусти снова"
exit 1
else
echo "[ERROR] нет ни .env, ни .env.example"
exit 1
fi
fi
echo "[INFO] Building and starting containers..."
docker compose up -d --build
echo "[INFO] Waiting for API to become healthy..."
for i in $(seq 1 30); do
if curl -sf http://localhost:3001/api/health >/dev/null 2>&1; then
echo "[OK] API is healthy"
break
fi
if [ "$i" = "30" ]; then
echo "[ERROR] API not healthy after 60s. Logs:"
docker compose logs --tail=50 api
exit 1
fi
sleep 2
done
echo ""
echo "API: http://localhost:3001"
echo "Health: http://localhost:3001/api/health"
echo "Docs: http://localhost:3001/api/docs"
echo "Logs: docker compose logs -f api"