47 lines
1.2 KiB
Bash
47 lines
1.2 KiB
Bash
#!/bin/bash
|
|
set -e
|
|
|
|
echo "=== Hadith Scholar API — Build & Deploy ==="
|
|
|
|
# ── 1. Build ──
|
|
echo ""
|
|
echo "📦 Building Docker image..."
|
|
docker build -t axxs/hadith-api:latest .
|
|
|
|
# ── 2. Push ──
|
|
echo ""
|
|
echo "⬆️ Pushing to Docker Hub..."
|
|
docker push axxs/hadith-api:latest
|
|
|
|
# ── 3. Deploy ──
|
|
echo ""
|
|
echo "🚀 Deploying to Kubernetes..."
|
|
|
|
# Create namespace (idempotent)
|
|
# kubectl create namespace api --dry-run=client -o yaml | kubectl apply -f -
|
|
|
|
# example: namespace "default"
|
|
# ⚠️ EDIT THE SECRET VALUES FIRST!
|
|
# Open k8s/deployment.yaml and replace REPLACE_ME in the Secret
|
|
|
|
kubectl apply -f k8s/deployment.yaml
|
|
|
|
# ── 4. Wait for rollout ──
|
|
echo ""
|
|
echo "⏳ Waiting for rollout..."
|
|
kubectl rollout status deployment/hadith-api -n api --timeout=120s
|
|
|
|
# ── 5. Verify ──
|
|
echo ""
|
|
echo "✅ Checking pods..."
|
|
kubectl get pods -n api -l app=hadith-api
|
|
|
|
echo ""
|
|
echo "🌐 API should be available at:"
|
|
echo " https://hadith-api.betelgeusebytes.io"
|
|
echo " https://hadith-api.betelgeusebytes.io/docs (Swagger)"
|
|
echo " https://hadith-api.betelgeusebytes.io/redoc (ReDoc)"
|
|
echo ""
|
|
echo "📋 Quick test:"
|
|
echo " curl https://hadith-api.betelgeusebytes.io/health"
|