auto-claude: subtask-3-6 - Add deployment and production information

This commit is contained in:
Maciej Pienczyn 2026-01-10 09:40:38 +01:00
parent 47b4ca039b
commit 40ff7e950e

186
README.md
View File

@ -455,6 +455,192 @@ docker exec -i nordabiz-postgres psql -U nordabiz_app -d nordabiz < database/sch
For more detailed database setup and management, see `database/README.md`. For more detailed database setup and management, see `database/README.md`.
## Deployment & Production
The application is live in production at **https://nordabiznes.pl** since November 23, 2025.
### Production Environment
| Component | Details |
|-----------|---------|
| **Server** | NORDABIZ-01 (VM 249, IP: 10.22.68.249) |
| **Database** | PostgreSQL 15 on 10.22.68.249:5432 |
| **Reverse Proxy** | Nginx Proxy Manager on R11-REVPROXY-01 (VM 119, IP: 10.22.68.250) |
| **Domain** | nordabiznes.pl (DNS managed via OVH) |
| **SSL/TLS** | Let's Encrypt with automatic renewal |
| **WSGI Server** | Gunicorn |
| **Service Manager** | systemd (`nordabiznes.service`) |
| **Application Path** | `/var/www/nordabiznes` |
| **Application User** | `www-data` |
### Git Repositories
The project maintains two Git remotes for redundancy and deployment:
| Remote | Repository | Purpose |
|--------|------------|---------|
| **origin** (GitHub) | `git@github.com:pienczyn/nordabiz.git` | Cloud backup, public access, CI/CD ready |
| **inpi** (Gitea) | `git@10.22.68.180:maciejpi/nordabiz.git` | Internal backup, deployment source |
**Gitea Access:** https://10.22.68.180:3000/ (requires HTTPS)
### Deployment Workflow
```
┌─────────────┐ git push ┌─────────────┐ git pull ┌─────────────┐
│ Development │ ────────────► │ Gitea │ ◄──────────── │ Production │
│ (Local) │ │ (INPI) │ │ Server │
└─────────────┘ └─────────────┘ └─────────────┘
└──── git push ────► GitHub (cloud backup)
```
#### Deployment Steps
**1. Push Changes from Development:**
```bash
# Push to both remotes (from local development)
git push origin master && git push inpi master
```
**2. Deploy to Production:**
```bash
# SSH to production server
ssh maciejpi@10.22.68.249
# Navigate to application directory
cd /var/www/nordabiznes
# Pull latest changes (as www-data user)
sudo -u www-data git pull
# Restart the application service
sudo systemctl restart nordabiznes
# Verify deployment
curl -I https://nordabiznes.pl/health
# Expected: HTTP/2 200
```
#### Pre-Deployment Checklist
Before deploying to production, always:
1. **Test locally** - Verify changes work in development environment
2. **Syntax check** - Run `python -m py_compile app.py` to check for syntax errors
3. **Database migrations** - Apply any schema changes to production database
4. **Environment variables** - Ensure new `.env` variables are configured on production
5. **Dependencies** - Update `requirements.txt` if new packages were added
**For comprehensive deployment procedures, see [`deployment_checklist.md`](deployment_checklist.md).**
### Production Configuration
**Critical NPM Proxy Configuration:**
```
Nginx Proxy Manager (10.22.68.250) → Backend (10.22.68.249:5000) ✓
```
**⚠️ IMPORTANT:** The NPM proxy must forward to port **5000** (Gunicorn), NOT port 80 (nginx). Forwarding to port 80 causes redirect loops.
**Environment Variables:**
Production uses similar `.env` configuration as development, but with production-specific values:
- `FLASK_ENV=production`
- `DATABASE_URL=postgresql://nordabiz_app:***@localhost:5432/nordabiz`
- `APP_URL=https://nordabiznes.pl`
- Production API keys (Google Gemini, PageSpeed, Places, etc.)
### Production Monitoring & Maintenance
**Service Management:**
```bash
# Check service status
sudo systemctl status nordabiznes
# View application logs
sudo journalctl -u nordabiznes -f
# Restart service
sudo systemctl restart nordabiznes
# Stop service
sudo systemctl stop nordabiznes
# Start service
sudo systemctl start nordabiznes
```
**Database Backup:**
Production server uses Proxmox Backup Server for automated VM snapshots and disaster recovery.
**Health Check:**
The application provides a health endpoint for monitoring:
- **URL:** https://nordabiznes.pl/health
- **Expected Response:** `{"status": "healthy"}`
### Production Access
**SSH Access:**
```bash
# Always SSH as maciejpi user (NOT root!)
ssh maciejpi@10.22.68.249
```
**Test Accounts:**
For testing functionality in production:
| Account | Email | Role |
|---------|-------|------|
| Test User | `test@nordabiznes.pl` | Regular user (company directory, search, chat) |
| Test Admin | `testadmin@nordabiznes.pl` | Administrator (admin panels, moderation) |
**⚠️ IMPORTANT:** Always use test accounts for production verification. Never test with real user accounts.
### Troubleshooting Production Issues
**Application Not Responding:**
```bash
# Check if service is running
sudo systemctl status nordabiznes
# Check application logs for errors
sudo journalctl -u nordabiznes -n 100
# Restart service
sudo systemctl restart nordabiznes
```
**Database Connection Issues:**
```bash
# Check PostgreSQL is running
sudo systemctl status postgresql
# Test database connectivity
psql -U nordabiz_app -d nordabiz -h localhost -c "SELECT 1;"
```
**Redirect Loop / 502 Errors:**
Verify NPM proxy configuration forwards to port 5000:
```bash
curl -I https://nordabiznes.pl/health
```
If issues persist, check NPM configuration on R11-REVPROXY-01 (Proxy Host ID: 27).
**For detailed incident reports and troubleshooting guides, see `docs/INCIDENT_REPORT_20260102.md`.**
## Roadmap & Future Enhancements ## Roadmap & Future Enhancements
While the platform is fully functional and in production, the following features are planned for future releases: While the platform is fully functional and in production, the following features are planned for future releases: