#!/usr/bin/env bash # deploy.sh — One-command Deep Dive deployment # Issue: #830 — Sovereign NotebookLM Daily Briefing # # Usage: # ./deploy.sh --dry-run # Build + test only # ./deploy.sh --live # Build + install daily timer set -euo pipefail SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" COMPOSE_FILE="$SCRIPT_DIR/docker-compose.yml" MODE="dry-run" RED='\033[0;31m' GREEN='\033[0;32m' YELLOW='\033[1;33m' NC='\033[0m' pass() { echo -e "${GREEN}[PASS]${NC} $*"; } fail() { echo -e "${RED}[FAIL]${NC} $*"; } info() { echo -e "${YELLOW}[INFO]${NC} $*"; } usage() { echo "Usage: $0 [--dry-run | --live]" echo " --dry-run Build image and run a dry-run test (default)" echo " --live Build image, run test, and install systemd timer" exit 1 } if [[ $# -gt 0 ]]; then case "$1" in --dry-run) MODE="dry-run" ;; --live) MODE="live" ;; -h|--help) usage ;; *) usage ;; esac fi info "==================================================" info "Deep Dive Deployment — Issue #830" info "Mode: $MODE" info "==================================================" # --- Prerequisites --- info "Checking prerequisites..." if ! command -v docker >/dev/null 2>&1; then fail "Docker is not installed" exit 1 fi pass "Docker installed" if ! docker compose version >/dev/null 2>&1 && ! docker-compose version >/dev/null 2>&1; then fail "Docker Compose is not installed" exit 1 fi pass "Docker Compose installed" if [[ ! -f "$SCRIPT_DIR/config.yaml" ]]; then fail "config.yaml not found in $SCRIPT_DIR" info "Copy config.yaml.example or create one before deploying." exit 1 fi pass "config.yaml exists" # --- Build --- info "Building Deep Dive image..." cd "$SCRIPT_DIR" docker compose -f "$COMPOSE_FILE" build deepdive pass "Image built successfully" # --- Dry-run test --- info "Running dry-run pipeline test..." docker compose -f "$COMPOSE_FILE" run --rm deepdive --dry-run --since 48 pass "Dry-run test passed" # --- Live mode: install timer --- if [[ "$MODE" == "live" ]]; then info "Installing daily execution timer..." SYSTEMD_DIR="$HOME/.config/systemd/user" mkdir -p "$SYSTEMD_DIR" # Generate a service that runs via docker compose cat > "$SYSTEMD_DIR/deepdive.service" < "$SYSTEMD_DIR/deepdive.timer" <