diff --git a/README.md b/README.md index aaa7587..8e3de6f 100644 --- a/README.md +++ b/README.md @@ -34,35 +34,39 @@ npm install # 2. Set up environment cp .env.example .env -# Edit .env with your values (see docs/SETUP-INFRASTRUCTURE.md) +# Edit .env with your values -# 3. Create required directories +# 3. Create public directory mkdir -p frontend/public -# 4. Start with Docker Compose +# 4. Start services docker-compose up -d --build -# 6. Initialize database (first time only) +# 5. Initialize database (first time only) docker-compose exec backend npx prisma db push -# 7. Deploy Solana program (optional, for token features) -cd anchor-program -anchor deploy +# 6. Configure Caddy (see docs/CADDY-CONFIG.md) +# Services expose ports 3000 (frontend) and 3001 (backend) on localhost ``` +See `docs/CADDY-CONFIG.md` for reverse proxy setup. + ## Project Structure ``` coop-credits/ -├── anchor-program/ # Solana Anchor program for $COOP token -├── backend/ # Express API server -├── frontend/ # Next.js dashboard -├── shared/ # Shared types and utilities -├── docker/ # Docker configurations -├── deployment/ # Deployment scripts -└── docker-compose.yml # Full stack orchestration +├── anchor-program/ # Solana Anchor program for $COOP token +├── backend/ # Express API server +├── frontend/ # Next.js dashboard +├── shared/ # Shared types and utilities +├── docs/ # Documentation +│ └── CADDY-CONFIG.md # Reverse proxy setup +├── docker-compose.yml # Docker orchestration (no nginx) +└── .env.example # Environment template ``` +**Note:** No internal reverse proxy. Use Caddy/Nginx/Traefik externally. + ## User Flow 1. **Login** → User visits coop.hobokenchicken.com, authenticates with Plex diff --git a/docker-compose.yml b/docker-compose.yml index 16d1d59..8cefd53 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -60,7 +60,7 @@ services: - OVERSEER_API_KEY=${OVERSEER_API_KEY} - ENCRYPTION_KEY=${ENCRYPTION_KEY} ports: - - "3001:3001" + - "127.0.0.1:3001:3001" # Localhost only, Caddy proxies to this depends_on: postgres: condition: service_healthy @@ -75,38 +75,23 @@ services: context: . dockerfile: frontend/Dockerfile args: - - NEXT_PUBLIC_API_URL=http://localhost:3001 + - NEXT_PUBLIC_API_URL=${API_URL:-http://localhost:3001} - NEXT_PUBLIC_SOLANA_NETWORK=devnet - NEXT_PUBLIC_SOLANA_RPC_URL=https://api.devnet.solana.com container_name: coop-frontend environment: - - NEXT_PUBLIC_API_URL=http://localhost:3001 + - NODE_ENV=production + - NEXT_PUBLIC_API_URL=${API_URL:-http://localhost:3001} - NEXT_PUBLIC_SOLANA_NETWORK=devnet - NEXT_PUBLIC_SOLANA_RPC_URL=https://api.devnet.solana.com ports: - - "3000:3000" + - "127.0.0.1:3000:3000" # Localhost only, Caddy proxies to this depends_on: - backend networks: - coop-network restart: unless-stopped - nginx: - image: nginx:alpine - container_name: coop-nginx - ports: - - "80:80" - volumes: - - ./docker/nginx/nginx.conf:/etc/nginx/nginx.conf:ro - depends_on: - frontend: - condition: service_started - backend: - condition: service_healthy - networks: - - coop-network - restart: unless-stopped - volumes: postgres_data: redis_data: diff --git a/docs/CADDY-CONFIG.md b/docs/CADDY-CONFIG.md new file mode 100644 index 0000000..2e78d0b --- /dev/null +++ b/docs/CADDY-CONFIG.md @@ -0,0 +1,50 @@ +# Caddy Configuration + +Caddy handles SSL termination and routes to the application services. + +## Caddyfile Example + +```caddy +coop.hobokenchicken.com { + # Frontend (Next.js) + handle_path /* { + reverse_proxy localhost:3000 + } + + # API routes + handle_path /api/* { + reverse_proxy localhost:3001 + } + + # Webhooks + handle_path /webhooks/* { + reverse_proxy localhost:3001 + } + + # WebSocket support + handle_path /socket.io/* { + reverse_proxy localhost:3001 + } +} +``` + +## Docker Compose (no nginx) + +Services bind to localhost only (`127.0.0.1`): + +- **Frontend**: `127.0.0.1:3000` +- **Backend**: `127.0.0.1:3001` +- **Postgres**: `5432` (internal only) +- **Redis**: `6379` (internal only) + +## Start Stack + +```bash +# Start services +docker-compose up -d + +# Verify +curl http://localhost:3001/health +``` + +Caddy automatically provisions SSL and routes traffic.