littleshop/Deploy/README.md
SysAdmin 13aa20ffa4 Add production deployment infrastructure
- Created comprehensive deployment package with production builds
- Added deployment scripts for Linux and Docker environments
- Generated Dockerfiles for containerized deployment
- Included nginx reverse proxy configuration
- Added systemd service definitions for native Linux deployment
- Created docker-compose.production.yml for orchestration
- Comprehensive deployment documentation in README.md
- Both LittleShop and TeleBot production builds included
- Ready for deployment to Hostinger VPS server

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-09-20 21:10:48 +01:00

391 lines
9.2 KiB
Markdown

# LittleShop Production Deployment Guide
## 🚀 Complete E-Commerce System Deployment
This directory contains everything needed to deploy the complete LittleShop e-commerce system with cryptocurrency payment processing.
## 📋 System Overview
### Components
- **LittleShop API**: Core e-commerce platform with admin panel
- **TeleBot**: Telegram bot for customer interactions
- **SilverPAY Integration**: Real cryptocurrency payment processing
- **Database**: SQLite (development) / PostgreSQL (production)
- **Reverse Proxy**: Nginx with SSL termination and rate limiting
### Features
- ✅ Multi-cryptocurrency payments (BTC, ETH, XMR, LTC, DASH, DOGE, ZEC, USDT)
- ✅ Complete order management workflow
- ✅ TeleBot customer service integration
- ✅ Admin panel for inventory and order management
- ✅ Product variations and bulk import/export
- ✅ Push notifications and webhooks
- ✅ Royal Mail shipping integration
- ✅ Mobile-responsive design
## 🛠️ Deployment Options
### Option 1: Native Linux Deployment (Recommended)
#### Prerequisites
```bash
# Ubuntu/Debian
sudo apt update
sudo apt install -y nginx postgresql redis-server curl
# Install .NET 9.0 Runtime
wget https://packages.microsoft.com/config/ubuntu/22.04/packages-microsoft-prod.deb -O packages-microsoft-prod.deb
sudo dpkg -i packages-microsoft-prod.deb
sudo apt update
sudo apt install -y aspnetcore-runtime-9.0
```
#### Quick Deploy
```bash
# Make deployment script executable
chmod +x deploy-production.sh
# Run deployment (requires sudo)
sudo ./deploy-production.sh
```
#### Post-Deployment Configuration
1. **Update configuration files:**
```bash
sudo nano /opt/littleshop/littleshop/appsettings.Production.json
sudo nano /opt/littleshop/telebot/appsettings.Production.json
```
2. **Configure SSL certificates:**
```bash
# Install Let's Encrypt certbot
sudo apt install certbot python3-certbot-nginx
# Obtain SSL certificate
sudo certbot --nginx -d your-domain.com
```
3. **Start services:**
```bash
sudo systemctl start littleshop
sudo systemctl start telebot
sudo systemctl status littleshop
sudo systemctl status telebot
```
### Option 2: Docker Deployment
#### Prerequisites
```bash
# Install Docker and Docker Compose
curl -fsSL https://get.docker.com -o get-docker.sh
sudo sh get-docker.sh
sudo usermod -aG docker $USER
```
#### Deploy with Docker
```bash
# Build and start services
docker-compose -f docker-compose.production.yml up -d
# Check service status
docker-compose -f docker-compose.production.yml ps
# View logs
docker-compose -f docker-compose.production.yml logs -f
```
## ⚙️ Configuration
### 1. LittleShop API Configuration
Key settings in `appsettings.Production.json`:
```json
{
"Jwt": {
"Key": "CHANGE_THIS_TO_A_SECURE_256_BIT_KEY",
"Issuer": "LittleShop",
"Audience": "LittleShop"
},
"SilverPay": {
"BaseUrl": "http://31.97.57.205:8001",
"ApiKey": "sp_live_key_2025_production",
"WebhookSecret": "webhook_secret_2025",
"DefaultWebhookUrl": "https://your-domain.com/api/orders/payments/webhook",
"UseMockService": false
},
"AllowedHosts": "your-domain.com,www.your-domain.com"
}
```
### 2. TeleBot Configuration
Key settings in TeleBot `appsettings.Production.json`:
```json
{
"BotConfiguration": {
"TelegramBotToken": "YOUR_BOT_TOKEN_FROM_BOTFATHER",
"LittleShopApiUrl": "https://your-domain.com",
"WebhookUrl": "https://your-domain.com/api/webhook"
}
}
```
### 3. Telegram Bot Setup
1. **Create bot with BotFather:**
- Message @BotFather on Telegram
- Use `/newbot` command
- Follow instructions to get bot token
2. **Set webhook:**
```bash
curl -X POST "https://api.telegram.org/bot<YOUR_BOT_TOKEN>/setWebhook" \
-H "Content-Type: application/json" \
-d '{"url": "https://your-domain.com/api/webhook"}'
```
## 🔐 Security Configuration
### 1. Environment Variables
Create `.env` file for sensitive data:
```bash
# Database
DB_PASSWORD=your_secure_db_password
# JWT
JWT_SECRET_KEY=your_256_bit_jwt_secret_key
# SilverPAY
SILVERPAY_API_KEY=sp_live_key_2025_production
SILVERPAY_WEBHOOK_SECRET=webhook_secret_2025
# Telegram
TELEGRAM_BOT_TOKEN=your_bot_token_here
# VAPID Keys for Push Notifications
VAPID_PUBLIC_KEY=your_vapid_public_key
VAPID_PRIVATE_KEY=your_vapid_private_key
```
### 2. Firewall Configuration
```bash
# Ubuntu UFW
sudo ufw allow 22/tcp # SSH
sudo ufw allow 80/tcp # HTTP
sudo ufw allow 443/tcp # HTTPS
sudo ufw enable
# Block direct access to application ports
sudo ufw deny 8080
sudo ufw deny 5010
```
### 3. SSL/TLS Setup
For production, always use HTTPS:
```bash
# Let's Encrypt (free)
sudo certbot --nginx -d your-domain.com -d www.your-domain.com
# Or use your own certificates
sudo cp your-domain.crt /etc/ssl/certs/
sudo cp your-domain.key /etc/ssl/private/
sudo chmod 600 /etc/ssl/private/your-domain.key
```
## 📊 Monitoring & Maintenance
### Service Management
```bash
# Check service status
sudo systemctl status littleshop
sudo systemctl status telebot
# View logs
sudo journalctl -u littleshop -f
sudo journalctl -u telebot -f
tail -f /opt/littleshop/logs/littleshop.log
# Restart services
sudo systemctl restart littleshop
sudo systemctl restart telebot
```
### Database Backup
```bash
# SQLite backup
sudo cp /opt/littleshop/data/littleshop.db /backup/littleshop-$(date +%Y%m%d).db
# PostgreSQL backup (if using Docker)
docker exec littleshop-db pg_dump -U littleshop littleshop > backup-$(date +%Y%m%d).sql
```
### Log Rotation
Logs are automatically rotated daily and kept for 30 days. Manual rotation:
```bash
sudo logrotate /etc/logrotate.d/littleshop
```
## 🧪 Testing Deployment
### Health Checks
```bash
# API health
curl https://your-domain.com/health
# Test admin login
curl -X POST https://your-domain.com/api/auth/login \
-H "Content-Type: application/json" \
-d '{"username":"admin","password":"admin"}'
# Test TeleBot webhook
curl -X POST https://your-domain.com/api/webhook \
-H "Content-Type: application/json" \
-d '{"message":{"text":"test"}}'
```
### Performance Testing
```bash
# Install Apache Bench
sudo apt install apache2-utils
# Load test API
ab -n 1000 -c 10 https://your-domain.com/api/catalog/products
```
## 🔧 Troubleshooting
### Common Issues
1. **Service won't start:**
```bash
# Check configuration
sudo systemctl status littleshop
sudo journalctl -u littleshop -n 50
# Test configuration manually
cd /opt/littleshop/littleshop
sudo -u www-data ./LittleShop
```
2. **Database connection errors:**
```bash
# Check SQLite permissions
sudo chown www-data:www-data /opt/littleshop/data/littleshop.db
sudo chmod 664 /opt/littleshop/data/littleshop.db
```
3. **TeleBot webhook issues:**
```bash
# Verify webhook URL
curl "https://api.telegram.org/bot<TOKEN>/getWebhookInfo"
# Reset webhook
curl -X POST "https://api.telegram.org/bot<TOKEN>/deleteWebhook"
curl -X POST "https://api.telegram.org/bot<TOKEN>/setWebhook" \
-d "url=https://your-domain.com/api/webhook"
```
4. **SilverPAY connection issues:**
```bash
# Test SilverPAY connectivity
curl -H "X-API-Key: sp_live_key_2025_production" \
http://31.97.57.205:8001/health
```
### Performance Optimization
1. **Enable response compression:**
```json
// In appsettings.Production.json
"ResponseCompression": {
"EnableForHttps": true
}
```
2. **Database optimization:**
```bash
# SQLite VACUUM
echo "VACUUM;" | sqlite3 /opt/littleshop/data/littleshop.db
```
3. **Nginx optimization:**
```nginx
# Add to nginx configuration
gzip on;
gzip_types text/plain text/css application/json application/javascript;
client_max_body_size 10M;
```
## 📞 Support
### Documentation Locations
- **API Documentation**: `https://your-domain.com/swagger`
- **Admin Panel**: `https://your-domain.com/Admin`
- **Health Checks**: `https://your-domain.com/health`
### Log Locations
- **Application Logs**: `/opt/littleshop/logs/`
- **System Logs**: `journalctl -u littleshop`
- **Nginx Logs**: `/var/log/nginx/`
### Default Admin Account
- **Username**: `admin`
- **Password**: `admin` (⚠️ Change immediately after deployment!)
## 🔄 Updates & Maintenance
### Updating the Application
1. **Backup current installation:**
```bash
sudo cp -r /opt/littleshop /opt/littleshop-backup-$(date +%Y%m%d)
```
2. **Deploy new version:**
```bash
sudo systemctl stop littleshop telebot
# Replace files with new deployment
sudo systemctl start littleshop telebot
```
3. **Database migrations:**
```bash
# Run from application directory
sudo -u www-data ./LittleShop --migrate
```
---
## 🎉 Deployment Complete!
Your LittleShop e-commerce system is now ready for production use with:
- ✅ Real cryptocurrency payment processing
- ✅ Telegram bot customer service
- ✅ Complete order management
- ✅ Admin panel for operations
- ✅ SSL encryption and security
- ✅ Automated backups and monitoring
- ✅ Scalable architecture
**Next Steps:**
1. Configure your domain and SSL certificates
2. Set up monitoring and alerting
3. Create regular backup schedules
4. Test all payment flows
5. Train staff on admin panel usage
For support or questions, refer to the troubleshooting section above.