Spaces:
Running on CPU Upgrade

File size: 2,987 Bytes
427634d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
#!/usr/bin/env bash
#
# Lighting MVP one-time setup script.
#
# Generates a .env file with the minimum required environment variables.
# Read HANDOVER.md before running this; it explains what the values mean
# and which optional settings you may want to add.
#
# Usage:
#   scripts/setup.sh           # writes .env if missing
#   scripts/setup.sh --force   # overwrite existing .env (regenerates password)
#   scripts/setup.sh --print   # print to stdout, don't write
#
set -euo pipefail

force=false
print_only=false
for arg in "$@"; do
    case "$arg" in
        --force) force=true ;;
        --print) print_only=true ;;
        -h|--help)
            sed -n '3,15p' "$0"
            exit 0
            ;;
        *)
            echo "Unknown argument: $arg" >&2
            echo "Use --help for usage." >&2
            exit 2
            ;;
    esac
done

REPO_ROOT="$(cd "$(dirname "$0")/.." && pwd)"
ENV_FILE="$REPO_ROOT/.env"

if [[ -f "$ENV_FILE" && "$force" == false && "$print_only" == false ]]; then
    echo "$ENV_FILE already exists. Pass --force to overwrite, or --print to dump a fresh template to stdout." >&2
    exit 1
fi

# Generate a strong random password. Falls back to /dev/urandom if openssl is
# missing so the script works on minimal containers.
if command -v openssl >/dev/null 2>&1; then
    ACCESS_PASSWORD="$(openssl rand -base64 24 | tr -d '/+=' | cut -c1-24)"
else
    ACCESS_PASSWORD="$(tr -dc 'A-Za-z0-9' < /dev/urandom | head -c 24)"
fi

env_contents=$(cat <<EOF
# Lighting MVP environment configuration.
# Generated by scripts/setup.sh on $(date -u +"%Y-%m-%dT%H:%M:%SZ").
# Re-run with --force to regenerate the password.
#
# REQUIRED
# --------
# Shared password protecting the UI and all API endpoints. Anyone with
# this password can use the tool, so treat it like a service password:
# share over a secure channel, rotate if leaked.
LIGHTING_MVP_ACCESS_GATE_PASSWORD=$ACCESS_PASSWORD

# OPTIONAL
# --------
# Postgres connection string. Leave unset to use a local SQLite DB
# (lighting_mvp.db). Set to a Neon / RDS / hosted Postgres URL for any
# shared or persistent deployment.
# LIGHTING_MVP_DATABASE_URL=postgresql://user:pass@host:5432/dbname

# Where transient pipeline files are staged. Default is /tmp (ephemeral).
# Mount a persistent volume and point this at it for prod.
# LIGHTING_MVP_STORAGE_ROOT=/data

# Which LLM provider to use. Can also be changed live from the gear icon.
# LIGHTING_MVP_AGENT_PROVIDER=anthropic
EOF
)

if [[ "$print_only" == true ]]; then
    echo "$env_contents"
    exit 0
fi

echo "$env_contents" > "$ENV_FILE"
chmod 600 "$ENV_FILE"

echo "Wrote $ENV_FILE (mode 0600)."
echo
echo "Next steps:"
echo "  1. docker build -t lighting-mvp ."
echo "  2. docker run --rm -p 7860:7860 --env-file .env lighting-mvp"
echo "  3. Open http://localhost:7860 and log in with the password in .env"
echo "  4. Click the gear icon (⚙) to complete the Claude or Codex login flow."
echo
echo "Full walkthrough: HANDOVER.md"