Introduce a Woodpecker CI/CD pipeline in `.woodpecker.yml` for automated deployment on pushes to the main branch. Add new components for visualizing campaign performance, including `DailyPerformanceChart`, `InboxPlacementChart`, and `InboxVsSpamChart`, to enhance the Campaign Detail page. Update `WarmupPlanChart` to include additional metrics and improve tooltip information. Enhance utility functions for chart data formatting and daily statistics mapping.
48 lines
1.2 KiB
Bash
Executable file
48 lines
1.2 KiB
Bash
Executable file
#!/usr/bin/env bash
|
|
# Production deploy — run on the server in the git checkout (e.g. /srv/docker-configs/warmbox).
|
|
# Used by Woodpecker CI and manual deploys.
|
|
set -euo pipefail
|
|
|
|
DEPLOY_DIR="${DEPLOY_DIR:-$(cd "$(dirname "$0")/.." && pwd)}"
|
|
BRANCH="${DEPLOY_BRANCH:-main}"
|
|
|
|
cd "$DEPLOY_DIR"
|
|
|
|
echo "==> Deploying Warmbox from ${DEPLOY_DIR} (branch ${BRANCH})"
|
|
|
|
if ! git rev-parse --is-inside-work-tree >/dev/null 2>&1; then
|
|
echo "ERROR: ${DEPLOY_DIR} is not a git repository"
|
|
exit 1
|
|
fi
|
|
|
|
git fetch origin "$BRANCH"
|
|
git reset --hard "origin/${BRANCH}"
|
|
|
|
if [[ ! -f .env ]]; then
|
|
echo "ERROR: .env missing in ${DEPLOY_DIR}. Create it from .env.example before deploying."
|
|
exit 1
|
|
fi
|
|
|
|
echo "==> Stopping containers..."
|
|
docker compose down
|
|
|
|
echo "==> Building and starting..."
|
|
docker compose up -d --build
|
|
|
|
echo "==> Waiting for container health..."
|
|
for i in $(seq 1 30); do
|
|
if docker compose exec -T warmbox node -e \
|
|
"fetch('http://127.0.0.1:3000/health').then(r=>process.exit(r.ok?0:1)).catch(()=>process.exit(1))" \
|
|
>/dev/null 2>&1; then
|
|
echo "==> Health check passed"
|
|
docker compose ps
|
|
echo "==> Deploy complete"
|
|
exit 0
|
|
fi
|
|
sleep 2
|
|
done
|
|
|
|
echo "==> Health check failed"
|
|
docker compose ps
|
|
docker compose logs --tail=80 warmbox
|
|
exit 1
|