|
1 | | -# Deploy Eryxon Flow |
| 1 | +# Deployment Guide |
| 2 | + |
| 3 | +## Quick Start (Automated) |
| 4 | + |
| 5 | +The fastest way to deploy Eryxon MES: |
| 6 | + |
| 7 | +```bash |
| 8 | +chmod +x scripts/setup.sh |
| 9 | +./scripts/setup.sh |
| 10 | +``` |
| 11 | + |
| 12 | +This interactive script handles all setup steps. For manual setup, continue reading. |
2 | 13 |
|
3 | 14 | ## Prerequisites |
4 | 15 |
|
5 | | -- Supabase account |
6 | | -- Cloudflare account (free tier) |
| 16 | +- Node.js 20+ |
| 17 | +- [Supabase CLI](https://supabase.com/docs/guides/cli) |
| 18 | +- A [Supabase](https://supabase.com) project |
7 | 19 |
|
8 | | -## Step 1: Create Supabase Project |
| 20 | +## Step 1: Supabase Setup |
9 | 21 |
|
| 22 | +### Create Project |
| 23 | +1. Go to [supabase.com](https://supabase.com) and create a new project |
| 24 | +2. Note your **Project URL**, **anon key**, and **service role key** from Settings > API |
| 25 | + |
| 26 | +### Apply Database Schema |
10 | 27 | ```bash |
11 | | -# 1. Go to supabase.com → Create project |
12 | | -# 2. Get credentials from Settings → API: |
13 | | -# - Project URL |
14 | | -# - anon key |
15 | | -# - Project Ref |
| 28 | +cp .env.example .env |
| 29 | +# Fill in VITE_SUPABASE_URL and VITE_SUPABASE_PUBLISHABLE_KEY |
16 | 30 |
|
17 | | -# 3. Apply schema |
18 | | -supabase link --project-ref YOUR_REF |
| 31 | +supabase link --project-ref <your-project-ref> |
19 | 32 | supabase db push |
| 33 | +``` |
20 | 34 |
|
21 | | -# 4. Create storage |
22 | | -supabase storage create parts-images |
23 | | -supabase storage create issues |
| 35 | +### Set Up Storage & Cron Jobs |
| 36 | +```bash |
| 37 | +# Apply via SQL Editor in Supabase Dashboard, or: |
| 38 | +supabase db execute < supabase/seed.sql |
| 39 | +``` |
24 | 40 |
|
25 | | -# 5. Deploy functions |
| 41 | +This creates storage buckets (`parts-images`, `issues`, `parts-cad`) and schedules cron jobs. |
| 42 | + |
| 43 | +### Deploy Edge Functions |
| 44 | +```bash |
26 | 45 | supabase functions deploy |
27 | 46 | ``` |
28 | 47 |
|
29 | | -## Step 2: Deploy to Cloudflare Pages |
| 48 | +### Set Edge Function Secrets |
| 49 | +```bash |
| 50 | +supabase secrets set \ |
| 51 | + SUPABASE_URL=<your-project-url> \ |
| 52 | + SUPABASE_SERVICE_ROLE_KEY=<your-service-role-key> |
| 53 | +``` |
| 54 | + |
| 55 | +Optional secrets: |
| 56 | +| Secret | Purpose | |
| 57 | +|--------|---------| |
| 58 | +| RESEND_API_KEY | Email invitations via Resend | |
| 59 | +| APP_URL | Base URL for invitation links | |
| 60 | +| EMAIL_FROM | Sender email for invitations | |
| 61 | +| CRON_SECRET | Auth for monthly-reset-cron | |
| 62 | +| SELF_HOSTED_MODE | Set to "true" for self-hosted mode | |
30 | 63 |
|
| 64 | +## Step 2: Deploy Frontend |
| 65 | + |
| 66 | +### Option A: Local Development |
31 | 67 | ```bash |
32 | | -# 1. Go to dash.cloudflare.com |
33 | | -# 2. Pages → Create → Connect Git |
34 | | -# 3. Select repo |
35 | | -# 4. Build: npm run build |
36 | | -# 5. Output: dist |
| 68 | +npm ci |
| 69 | +npm run dev |
37 | 70 | ``` |
38 | 71 |
|
39 | | -**Environment Variables** (set in Cloudflare): |
| 72 | +### Option B: Cloudflare Pages |
| 73 | +1. Connect your Git repository to Cloudflare Pages |
| 74 | +2. Build command: `npm run build` |
| 75 | +3. Output directory: `dist` |
| 76 | +4. Add environment variables in Cloudflare Pages settings |
| 77 | + |
| 78 | +### Option C: Docker |
| 79 | +```bash |
| 80 | +docker build \ |
| 81 | + --build-arg VITE_SUPABASE_URL=<url> \ |
| 82 | + --build-arg VITE_SUPABASE_PUBLISHABLE_KEY=<key> \ |
| 83 | + -t eryxon-flow . |
| 84 | + |
| 85 | +docker run -p 80:80 eryxon-flow |
40 | 86 | ``` |
41 | | -VITE_SUPABASE_URL = https://YOUR_REF.supabase.co |
42 | | -VITE_SUPABASE_PUBLISHABLE_KEY = your-anon-key |
43 | | -VITE_SUPABASE_PROJECT_ID = YOUR_REF |
| 87 | + |
| 88 | +### Option D: Docker Compose (Production with SSL) |
| 89 | +```bash |
| 90 | +# Edit Caddyfile - replace domain with yours |
| 91 | +# Edit docker-compose.prod.yml if needed |
| 92 | +docker compose -f docker-compose.prod.yml up -d |
44 | 93 | ``` |
45 | 94 |
|
46 | | -## Step 3: Custom Domain |
| 95 | +## Step 3: First Login |
| 96 | + |
| 97 | +1. Navigate to your deployment URL |
| 98 | +2. Click "Sign Up" to create the first admin account |
| 99 | +3. The first user automatically becomes admin with their own tenant |
| 100 | + |
| 101 | +## Optional: Cloudflare Turnstile (CAPTCHA) |
| 102 | + |
| 103 | +Turnstile is optional. Without it, auth works but without bot protection. |
| 104 | + |
| 105 | +To enable: |
| 106 | +1. Create a Turnstile widget at [Cloudflare Dashboard](https://dash.cloudflare.com/?to=/:account/turnstile) |
| 107 | +2. Set `VITE_TURNSTILE_SITE_KEY` in your environment |
| 108 | +3. Configure the Turnstile secret key in Supabase Dashboard > Auth > Captcha |
| 109 | + |
| 110 | +## Verification |
| 111 | + |
| 112 | +Run the verification script to check your setup: |
| 113 | +```bash |
| 114 | +chmod +x scripts/verify-setup.sh |
| 115 | +./scripts/verify-setup.sh |
| 116 | +``` |
47 | 117 |
|
48 | | -In Cloudflare Pages: |
49 | | -- Custom domains → Add domain |
50 | | -- Enter: app.eryxon.eu |
51 | | -- DNS: CNAME app → eryxon-flow.pages.dev |
| 118 | +## Full Documentation |
52 | 119 |
|
53 | | -Done. |
| 120 | +See [docs/SELF_HOSTING_GUIDE.md](docs/SELF_HOSTING_GUIDE.md) for the complete self-hosting guide including Docker, Cloudflare Pages, and troubleshooting. |
0 commit comments