docs: update all documentation to reflect current project state
This commit is contained in:
+76
-159
@@ -5,9 +5,10 @@ This guide covers setting up CoopCredits with your existing Plex/Tautulli/Overse
|
||||
## Prerequisites
|
||||
|
||||
- Server running Docker and Docker Compose
|
||||
- Access to 172.20.1.0/24 network
|
||||
- Access to `172.20.1.0/24` network
|
||||
- API keys from Tautulli and Overseer
|
||||
- Domain name (coop.hobokenchicken.com) pointing to your server
|
||||
- Domain name (`coop.hobokenchicken.com`) pointing to your server
|
||||
- Ko-fi account with store items set up (optional, for credit purchases)
|
||||
|
||||
## Network Overview
|
||||
|
||||
@@ -38,72 +39,64 @@ git clone <repository> coop-credits
|
||||
cd coop-credits
|
||||
```
|
||||
|
||||
### 2. Run Infrastructure Setup
|
||||
|
||||
```bash
|
||||
./deployment/setup-infrastructure.sh
|
||||
```
|
||||
|
||||
This script will:
|
||||
- Test connectivity to your services (Plex, Tautulli, Overseer)
|
||||
- Generate a secure `.env` file
|
||||
- Output configuration instructions
|
||||
|
||||
**Note:** SSL/TLS is handled by your external reverse proxy (Caddy). The application runs HTTP on port 80 internally.
|
||||
|
||||
### 3. Configure Environment
|
||||
|
||||
Edit the generated `.env` file:
|
||||
### 2. Configure Environment
|
||||
|
||||
```bash
|
||||
cp .env.example .env
|
||||
nano .env
|
||||
```
|
||||
|
||||
Add your API keys:
|
||||
Required environment variables:
|
||||
|
||||
```env
|
||||
# Get from Tautulli: Settings > Web Interface > API
|
||||
TAUTULLI_API_KEY=your-tautulli-api-key
|
||||
# Database
|
||||
DATABASE_URL="postgresql://coop:coop_password@localhost:5432/coop_credits?schema=public"
|
||||
|
||||
# Get from Overseer: Settings > General > API Key
|
||||
OVERSEER_API_KEY=your-overseer-api-key
|
||||
# Server
|
||||
PORT=3002
|
||||
API_URL=https://coop.hobokenchicken.com
|
||||
FRONTEND_URL=https://coop.hobokenchicken.com
|
||||
|
||||
# Get from https://plex.tv/claim or Plex settings
|
||||
# JWT Secret (generate: openssl rand -hex 32)
|
||||
JWT_SECRET=your-random-secret
|
||||
|
||||
# Plex OAuth
|
||||
PLEX_CLIENT_ID=your-plex-client-id
|
||||
PLEX_CLIENT_SECRET=your-plex-client-secret
|
||||
PLEX_REDIRECT_URI=https://coop.hobokenchicken.com/auth/callback
|
||||
|
||||
# Tautulli
|
||||
TAUTULLI_URL=http://172.20.1.255:8181
|
||||
TAUTULLI_API_KEY=your-tautulli-api-key
|
||||
|
||||
# Overseer
|
||||
OVERSEER_URL=http://172.20.1.225:5055
|
||||
OVERSEER_API_KEY=your-overseer-api-key
|
||||
|
||||
# Ko-fi (optional — for credit purchases)
|
||||
KOFI_VERIFICATION_TOKEN=your-kofi-verification-token
|
||||
|
||||
# Security
|
||||
ENCRYPTION_KEY=$(openssl rand -base64 32)
|
||||
```
|
||||
|
||||
### 4. Setup Solana
|
||||
### 3. Deploy
|
||||
|
||||
```bash
|
||||
npm run setup:solana
|
||||
docker-compose up -d --build
|
||||
|
||||
# Initialize database (first time only)
|
||||
docker exec coop-backend npx prisma db push --accept-data-loss
|
||||
```
|
||||
|
||||
This will:
|
||||
- Install Solana CLI
|
||||
- Create a devnet wallet
|
||||
- Request airdrop
|
||||
- Output the private key for your `.env` file
|
||||
### 4. Configure Caddy
|
||||
|
||||
Copy the `SOLANA_MINT_AUTHORITY_KEYPAIR` into your `.env` file.
|
||||
See `docs/CADDY-CONFIG.md`. Key points:
|
||||
- Backend runs on **port 3002**
|
||||
- Use `handle` (not `handle_path`) for `/api/*`
|
||||
- Proxy `/webhooks/*` to backend
|
||||
|
||||
### 5. Deploy Solana Program
|
||||
|
||||
```bash
|
||||
cd anchor-program
|
||||
anchor build
|
||||
anchor deploy
|
||||
```
|
||||
|
||||
Update `SOLANA_PROGRAM_ID` in `.env` with the deployed program ID.
|
||||
|
||||
### 6. Deploy
|
||||
|
||||
```bash
|
||||
./deployment/deploy-production.sh
|
||||
```
|
||||
|
||||
### 8. Configure Tautulli Webhook
|
||||
### 5. Configure Tautulli Webhook
|
||||
|
||||
1. Open Tautulli: http://172.20.1.255:8181
|
||||
2. Go to **Settings > Notification Agents**
|
||||
@@ -134,7 +127,7 @@ Update `SOLANA_PROGRAM_ID` in `.env` with the deployed program ID.
|
||||
|
||||
**Triggers:** Enable **Watched**
|
||||
|
||||
### 9. Configure Overseer Webhook
|
||||
### 6. Configure Overseer Webhook
|
||||
|
||||
1. Open Overseer: http://172.20.1.225:5055
|
||||
2. Go to **Settings > Notifications**
|
||||
@@ -142,7 +135,7 @@ Update `SOLANA_PROGRAM_ID` in `.env` with the deployed program ID.
|
||||
|
||||
**Configuration:**
|
||||
- Webhook URL: `https://coop.hobokenchicken.com/webhooks/overseer`
|
||||
- Authorization Header: `Bearer your-webhook-secret-from-env`
|
||||
- Content Type: `application/json`
|
||||
|
||||
**JSON Payload:**
|
||||
```json
|
||||
@@ -156,24 +149,33 @@ Update `SOLANA_PROGRAM_ID` in `.env` with the deployed program ID.
|
||||
|
||||
**Events:** Enable **Request Approved** and **Request Declined**
|
||||
|
||||
### 7. Configure Ko-fi Webhook (Optional)
|
||||
|
||||
1. Go to ko-fi.com → **Settings > Webhooks**
|
||||
2. Set **Webhook URL** to: `https://coop.hobokenchicken.com/webhooks/kofi`
|
||||
3. Save
|
||||
|
||||
Create store items:
|
||||
- $5 item → link: `https://ko-fi.com/s/YOUR_ITEM_ID`
|
||||
- $10 item → link: `https://ko-fi.com/s/YOUR_ITEM_ID`
|
||||
|
||||
Update frontend preset links in `frontend/src/app/dashboard/components/BuyCreditsModal.tsx`
|
||||
|
||||
### 8. Set Admin User
|
||||
|
||||
```bash
|
||||
docker exec coop-postgres psql -U coop -d coop_credits -c "UPDATE users SET is_admin = true WHERE plex_username = 'YOUR_USERNAME';"
|
||||
```
|
||||
|
||||
## Verification
|
||||
|
||||
### Test Connectivity
|
||||
|
||||
```bash
|
||||
./deployment/health-check.sh
|
||||
```
|
||||
# Backend health
|
||||
curl https://coop.hobokenchicken.com/health
|
||||
|
||||
### Watch Mode
|
||||
|
||||
```bash
|
||||
./deployment/health-check.sh --watch
|
||||
```
|
||||
|
||||
### Manual Tests
|
||||
|
||||
**Test Tautulli webhook:**
|
||||
```bash
|
||||
# Test Tautulli webhook manually
|
||||
curl -X POST https://coop.hobokenchicken.com/webhooks/tautulli \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{
|
||||
@@ -190,88 +192,6 @@ curl -X POST https://coop.hobokenchicken.com/webhooks/tautulli \
|
||||
}'
|
||||
```
|
||||
|
||||
**Test API:**
|
||||
```bash
|
||||
curl https://coop.hobokenchicken.com/api/health
|
||||
```
|
||||
|
||||
## Firewall Configuration
|
||||
|
||||
If using UFW:
|
||||
|
||||
```bash
|
||||
# Allow web traffic
|
||||
sudo ufw allow 80/tcp
|
||||
sudo ufw allow 443/tcp
|
||||
|
||||
# Allow backend to reach local network
|
||||
sudo ufw allow from 172.20.2.0/16 to 172.20.1.0/24
|
||||
|
||||
# Deny direct access to internal services
|
||||
sudo ufw deny 3000/tcp
|
||||
sudo ufw deny 3001/tcp
|
||||
sudo ufw deny 5432/tcp
|
||||
sudo ufw deny 6379/tcp
|
||||
|
||||
# Enable firewall
|
||||
sudo ufw enable
|
||||
```
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
### Cannot reach local services
|
||||
|
||||
1. Check Docker network:
|
||||
```bash
|
||||
docker network inspect coop-credits_coop-external
|
||||
```
|
||||
|
||||
2. Test connectivity from container:
|
||||
```bash
|
||||
docker exec coop-backend ping 172.20.1.255
|
||||
```
|
||||
|
||||
3. Verify firewall rules:
|
||||
```bash
|
||||
sudo ufw status verbose
|
||||
```
|
||||
|
||||
### Webhooks not working
|
||||
|
||||
1. Check Nginx logs:
|
||||
```bash
|
||||
tail -f docker/nginx/logs/access.log
|
||||
```
|
||||
|
||||
2. Check backend logs:
|
||||
```bash
|
||||
docker-compose -f docker-compose.prod.yml logs -f backend
|
||||
```
|
||||
|
||||
3. Test webhook manually:
|
||||
```bash
|
||||
curl -X POST https://coop.hobokenchicken.com/webhooks/tautulli \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{"test": true}'
|
||||
```
|
||||
|
||||
### Database connection issues
|
||||
|
||||
1. Check database status:
|
||||
```bash
|
||||
docker-compose -f docker-compose.prod.yml ps postgres
|
||||
```
|
||||
|
||||
2. View database logs:
|
||||
```bash
|
||||
docker-compose -f docker-compose.prod.yml logs postgres
|
||||
```
|
||||
|
||||
3. Test connection:
|
||||
```bash
|
||||
docker-compose -f docker-compose.prod.yml exec postgres pg_isready -U coop
|
||||
```
|
||||
|
||||
## Maintenance
|
||||
|
||||
### Update Application
|
||||
@@ -279,48 +199,45 @@ sudo ufw enable
|
||||
```bash
|
||||
cd /opt/coop-credits
|
||||
git pull
|
||||
./deployment/deploy-production.sh
|
||||
docker-compose up -d --build
|
||||
```
|
||||
|
||||
### Backup Database
|
||||
|
||||
```bash
|
||||
# Automated backup
|
||||
docker-compose -f docker-compose.prod.yml exec -T postgres pg_dump -U coop coop_credits > backup_$(date +%Y%m%d).sql
|
||||
docker exec -T coop-postgres pg_dump -U coop coop_credits > backup_$(date +%Y%m%d).sql
|
||||
```
|
||||
|
||||
### View Logs
|
||||
|
||||
```bash
|
||||
# All services
|
||||
docker-compose -f docker-compose.prod.yml logs -f
|
||||
docker-compose logs -f
|
||||
|
||||
# Specific service
|
||||
docker-compose -f docker-compose.prod.yml logs -f backend
|
||||
docker-compose logs -f backend
|
||||
```
|
||||
|
||||
### Restart Services
|
||||
|
||||
```bash
|
||||
docker-compose -f docker-compose.prod.yml restart backend
|
||||
docker-compose restart backend
|
||||
docker-compose restart frontend
|
||||
```
|
||||
|
||||
## Security Checklist
|
||||
|
||||
- [ ] Changed all default passwords in `.env`
|
||||
- [ ] Changed default PostgreSQL password
|
||||
- [ ] External reverse proxy (Caddy) configured for SSL
|
||||
- [ ] Firewall rules configured
|
||||
- [ ] Tautulli webhook secret set
|
||||
- [ ] Overseer webhook secret set
|
||||
- [ ] JWT secret is random and secure
|
||||
- [ ] Database not exposed externally
|
||||
- [ ] Redis password set
|
||||
- [ ] Encryption key is random and backed up
|
||||
- [ ] Solana mint authority key backed up securely
|
||||
- [ ] Ko-fi verification token set (if using purchases)
|
||||
|
||||
## Support
|
||||
|
||||
For issues:
|
||||
1. Check health: `./deployment/health-check.sh`
|
||||
2. Review logs: `docker-compose -f docker-compose.prod.yml logs`
|
||||
3. Check documentation in `docs/INFRASTRUCTURE.md`
|
||||
1. Check logs: `docker-compose logs -f`
|
||||
2. Review environment variables
|
||||
3. Verify all services are running: `docker ps`
|
||||
|
||||
Reference in New Issue
Block a user