feat: copier update v0.9.0 → v0.10.0

Pulls in template changes: export_serving.py for atomic DuckDB swap,
supervisor export step, SQLMesh glob macro, server provisioning script,
imprint template, and formatting improvements.

Template scaffold SQL models excluded (padelnomics has real models).
Web app routes/analytics unchanged (padelnomics-specific customizations).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Deeman
2026-02-22 17:50:36 +01:00
parent 59306d5a90
commit ea86940b78
10 changed files with 236 additions and 16 deletions

51
infra/setup_server.sh Normal file
View File

@@ -0,0 +1,51 @@
#!/bin/bash
# One-time server setup: create app directory and GitLab deploy key.
# Run as root on a fresh server before deploying.
#
# Usage:
# bash infra/setup_server.sh
set -euo pipefail
APP_DIR="/opt/padelnomics"
KEY_PATH="$HOME/.ssh/padelnomics_deploy"
# Create app directory
mkdir -p "$APP_DIR"
echo "Created $APP_DIR"
# Generate deploy key if not already present
if [ ! -f "$KEY_PATH" ]; then
mkdir -p "$HOME/.ssh"
ssh-keygen -t ed25519 -f "$KEY_PATH" -N "" -C "padelnomics-server"
chmod 700 "$HOME/.ssh"
chmod 600 "$KEY_PATH"
chmod 644 "$KEY_PATH.pub"
# Configure SSH to use this key for gitlab.com
if ! grep -q "# padelnomics" "$HOME/.ssh/config" 2>/dev/null; then
cat >> "$HOME/.ssh/config" <<EOF
# padelnomics
Host gitlab.com
IdentityFile $KEY_PATH
EOF
chmod 600 "$HOME/.ssh/config"
fi
echo "Generated deploy key: $KEY_PATH"
else
echo "Deploy key already exists, skipping"
fi
echo ""
echo "=== Next steps ==="
echo "1. Add this deploy key to GitLab (Settings → Repository → Deploy Keys, read-only):"
echo ""
cat "$KEY_PATH.pub"
echo ""
echo "2. Clone the repo:"
echo " git clone git@gitlab.com:YOUR_USER/padelnomics.git $APP_DIR"
echo ""
echo "3. Deploy:"
echo " cd $APP_DIR && bash deploy.sh"

View File

@@ -13,6 +13,7 @@ RestartSec=10
EnvironmentFile=/opt/padelnomics/.env
Environment=LANDING_DIR=/data/padelnomics/landing
Environment=DUCKDB_PATH=/data/padelnomics/lakehouse.duckdb
Environment=SERVING_DUCKDB_PATH=/data/padelnomics/analytics.duckdb
LimitNOFILE=65536

View File

@@ -4,9 +4,10 @@
# https://github.com/tigerbeetle/tigerbeetle/blob/main/src/scripts/cfo_supervisor.sh
#
# Environment variables (set in systemd EnvironmentFile or .env):
# LANDING_DIR — local path for extracted landing data
# DUCKDB_PATH — path to DuckDB lakehouse file
# ALERT_WEBHOOK_URL — optional ntfy.sh / Slack / Telegram webhook for failures
# LANDING_DIR — local path for extracted landing data
# DUCKDB_PATH — path to DuckDB lakehouse (pipeline DB, SQLMesh exclusive)
# SERVING_DUCKDB_PATH — path to serving-only DuckDB (web app reads from here)
# ALERT_WEBHOOK_URL — optional ntfy.sh / Slack / Telegram webhook for failures
set -eu
@@ -37,6 +38,12 @@ do
DUCKDB_PATH="${DUCKDB_PATH:-/data/padelnomics/lakehouse.duckdb}" \
uv run --package sqlmesh_padelnomics sqlmesh run --select-model "serving.*"
# Export serving tables to analytics.duckdb (atomic swap).
# The web app detects the inode change on next query — no restart needed.
DUCKDB_PATH="${DUCKDB_PATH:-/data/padelnomics/lakehouse.duckdb}" \
SERVING_DUCKDB_PATH="${SERVING_DUCKDB_PATH:-/data/padelnomics/analytics.duckdb}" \
uv run python -m padelnomics.export_serving
) || {
if [ -n "${ALERT_WEBHOOK_URL:-}" ]; then
curl -s -d "Padelnomics pipeline failed at $(date)" \