|
| 1 | +# NCA Toolkit Storage Configuration Guide |
| 2 | + |
| 3 | +## Overview |
| 4 | +The NCA Toolkit supports dual storage configuration: |
| 5 | +- **MinIO** for local development |
| 6 | +- **Supabase Storage** for production |
| 7 | + |
| 8 | +Both use S3-compatible APIs, making it easy to switch between environments. |
| 9 | + |
| 10 | +--- |
| 11 | + |
| 12 | +## MinIO Setup (Local Development) |
| 13 | + |
| 14 | +### 1. Start Services |
| 15 | +```bash |
| 16 | +cd c:\development\github\compiled-growth\nca |
| 17 | +docker compose -f docker-compose.local.yml up -d |
| 18 | +``` |
| 19 | + |
| 20 | +### 2. Verify MinIO |
| 21 | +- **Console:** http://localhost:9001 |
| 22 | +- **API:** http://localhost:9000 |
| 23 | +- **Credentials:** minioadmin / minioadmin123 |
| 24 | + |
| 25 | +### 3. Bucket Configuration |
| 26 | +**Bucket Name:** `nca-videos` |
| 27 | +**Access Policy:** Public download (read-only) |
| 28 | + |
| 29 | +**Status:** ✅ Created and configured |
| 30 | + |
| 31 | +### 4. Test Access |
| 32 | +```bash |
| 33 | +# List buckets |
| 34 | +docker exec nca-minio mc ls local/ |
| 35 | + |
| 36 | +# Check bucket policy |
| 37 | +docker exec nca-minio mc anonymous get local/nca-videos |
| 38 | +``` |
| 39 | + |
| 40 | +### 5. Environment Configuration |
| 41 | +Use `.env.local.minio` for local development: |
| 42 | +```bash |
| 43 | +S3_ENDPOINT=http://localhost:9000 |
| 44 | +S3_ACCESS_KEY=minioadmin |
| 45 | +S3_SECRET_KEY=minioadmin123 |
| 46 | +S3_BUCKET=nca-videos |
| 47 | +``` |
| 48 | + |
| 49 | +--- |
| 50 | + |
| 51 | +## Supabase Storage Setup (Production) |
| 52 | + |
| 53 | +### 1. Access Supabase Dashboard |
| 54 | +Navigate to your Supabase project dashboard |
| 55 | + |
| 56 | +### 2. Create Storage Bucket |
| 57 | + |
| 58 | +**Option A: Via Dashboard** |
| 59 | +1. Go to **Storage** section |
| 60 | +2. Click **New bucket** |
| 61 | +3. Name: `nca-videos` |
| 62 | +4. Set to **Public** bucket |
| 63 | +5. Click **Create bucket** |
| 64 | + |
| 65 | +**Option B: Via SQL** |
| 66 | +```sql |
| 67 | +-- Create the bucket |
| 68 | +INSERT INTO storage.buckets (id, name, public) |
| 69 | +VALUES ('nca-videos', 'nca-videos', true); |
| 70 | + |
| 71 | +-- Set public access policy |
| 72 | +CREATE POLICY "Public Access" |
| 73 | +ON storage.objects FOR SELECT |
| 74 | +USING (bucket_id = 'nca-videos'); |
| 75 | + |
| 76 | +-- Allow authenticated uploads |
| 77 | +CREATE POLICY "Authenticated Uploads" |
| 78 | +ON storage.objects FOR INSERT |
| 79 | +WITH CHECK (bucket_id = 'nca-videos' AND auth.role() = 'authenticated'); |
| 80 | +``` |
| 81 | + |
| 82 | +### 3. Get S3 Credentials |
| 83 | +1. Go to **Project Settings** > **API** |
| 84 | +2. Scroll to **S3 Access Keys** |
| 85 | +3. Click **Generate new key** |
| 86 | +4. Save the Access Key ID and Secret Access Key |
| 87 | + |
| 88 | +### 4. Configure Environment |
| 89 | +Update `.env.supabase.example` with your credentials: |
| 90 | +```bash |
| 91 | +S3_ENDPOINT=https://YOUR_PROJECT_REF.supabase.co/storage/v1/s3 |
| 92 | +S3_ACCESS_KEY=YOUR_ACCESS_KEY_ID |
| 93 | +S3_SECRET_KEY=YOUR_SECRET_ACCESS_KEY |
| 94 | +S3_BUCKET=nca-videos |
| 95 | +USE_SSL=true |
| 96 | +``` |
| 97 | + |
| 98 | +### 5. Test Connection |
| 99 | +```bash |
| 100 | +# Using AWS CLI |
| 101 | +aws s3 ls s3://nca-videos \ |
| 102 | + --endpoint-url https://YOUR_PROJECT_REF.supabase.co/storage/v1/s3 \ |
| 103 | + --region us-east-1 |
| 104 | +``` |
| 105 | + |
| 106 | +--- |
| 107 | + |
| 108 | +## Switching Between Environments |
| 109 | + |
| 110 | +### Local Development |
| 111 | +```bash |
| 112 | +cp .env.local.minio .env |
| 113 | +docker compose -f docker-compose.local.yml up -d |
| 114 | +``` |
| 115 | + |
| 116 | +### Production |
| 117 | +```bash |
| 118 | +cp .env.supabase .env |
| 119 | +# Deploy to your production environment |
| 120 | +``` |
| 121 | + |
| 122 | +--- |
| 123 | + |
| 124 | +## Bucket Permissions |
| 125 | + |
| 126 | +### MinIO (Local) |
| 127 | +- **Read:** Public (anyone can download) |
| 128 | +- **Write:** Authenticated via API key |
| 129 | + |
| 130 | +### Supabase (Production) |
| 131 | +- **Read:** Public (anyone can download) |
| 132 | +- **Write:** Authenticated users only |
| 133 | +- **Delete:** Service role only |
| 134 | + |
| 135 | +--- |
| 136 | + |
| 137 | +## Testing Both Storage Solutions |
| 138 | + |
| 139 | +### Test MinIO |
| 140 | +```bash |
| 141 | +# Upload test file |
| 142 | +curl -X POST http://localhost:8080/api/v1/test-upload \ |
| 143 | + -H "X-API-Key: local-dev-api-key-12345" \ |
| 144 | + -F "file=@test-video.mp4" |
| 145 | + |
| 146 | +# Verify in MinIO Console |
| 147 | +open http://localhost:9001/buckets/nca-videos/browse |
| 148 | +``` |
| 149 | + |
| 150 | +### Test Supabase |
| 151 | +```bash |
| 152 | +# Upload test file (production) |
| 153 | +curl -X POST https://your-api.com/api/v1/test-upload \ |
| 154 | + -H "X-API-Key: your-production-key" \ |
| 155 | + -F "file=@test-video.mp4" |
| 156 | + |
| 157 | +# Verify in Supabase Dashboard |
| 158 | +# Go to Storage > nca-videos |
| 159 | +``` |
| 160 | + |
| 161 | +--- |
| 162 | + |
| 163 | +## Troubleshooting |
| 164 | + |
| 165 | +### MinIO Issues |
| 166 | +- **Port 9000 in use:** Stop other MinIO instances |
| 167 | +- **Bucket not found:** Recreate via console or mc command |
| 168 | +- **Permission denied:** Check bucket policy is set to public |
| 169 | + |
| 170 | +### Supabase Issues |
| 171 | +- **S3 credentials not working:** Regenerate keys in dashboard |
| 172 | +- **Bucket not accessible:** Verify bucket is set to public |
| 173 | +- **Upload fails:** Check RLS policies allow authenticated uploads |
| 174 | + |
| 175 | +--- |
| 176 | + |
| 177 | +## Integration with n8n |
| 178 | + |
| 179 | +Both storage solutions can be accessed from n8n workflows: |
| 180 | + |
| 181 | +### MinIO (from n8n container) |
| 182 | +```javascript |
| 183 | +// Use host.docker.internal or MinIO container name |
| 184 | +const endpoint = 'http://host.docker.internal:9000'; |
| 185 | +const bucket = 'nca-videos'; |
| 186 | +``` |
| 187 | + |
| 188 | +### Supabase (from n8n) |
| 189 | +```javascript |
| 190 | +// Use Supabase Storage node or HTTP Request |
| 191 | +const endpoint = 'https://YOUR_PROJECT_REF.supabase.co/storage/v1'; |
| 192 | +const bucket = 'nca-videos'; |
| 193 | +``` |
| 194 | + |
| 195 | +--- |
| 196 | + |
| 197 | +## Next Steps |
| 198 | + |
| 199 | +1. ✅ MinIO bucket created and configured |
| 200 | +2. ⏳ Create Supabase storage bucket |
| 201 | +3. ⏳ Test both storage solutions |
| 202 | +4. ⏳ Configure n8n workflows to use storage |
| 203 | +5. ⏳ Fix Supabase container restart issues |
0 commit comments