4.4 KiB
4.4 KiB
Phosphat Report - Production Deployment Guide
This guide will help you deploy the Phosphat Report application on your Dockploy VPS using Docker Compose.
Prerequisites
- Docker and Docker Compose installed on your VPS
- Domain name configured (optional but recommended)
- SSL certificate (handled by Traefik if using reverse proxy)
Quick Start
-
Clone the repository to your VPS:
git clone <your-repo-url> cd phosphat-report -
Configure environment variables:
cp .env.production .env nano .env # Edit with your production values -
Deploy the application:
chmod +x deploy.sh ./deploy.sh deploy
Environment Configuration
Edit the .env file with your production values:
Required Settings
# Change these values for security
SESSION_SECRET="your-super-secure-session-secret-min-32-chars"
SUPER_ADMIN_PASSWORD="YourSecurePassword123!"
SUPER_ADMIN_EMAIL="admin@yourcompany.com"
# Your domain (for Traefik labels)
DOMAIN=your-domain.com
Optional Settings
# Custom port (default: 3000)
APP_PORT=3000
# Storage paths
DATA_PATH=./data
BACKUP_PATH=./backups
# Email configuration (for password reset)
MAIL_HOST=smtp.gmail.com
MAIL_USERNAME=your-email@gmail.com
MAIL_PASSWORD=your-app-password
Deployment Commands
The deploy.sh script provides several useful commands:
# Deploy application
./deploy.sh deploy
# Stop services
./deploy.sh stop
# Restart services
./deploy.sh restart
# View logs
./deploy.sh logs
# Create database backup
./deploy.sh backup
# Check status
./deploy.sh status
Manual Deployment
If you prefer manual deployment:
# Create directories
mkdir -p data backups logs
# Build and start services
docker-compose up -d --build
# Check status
docker-compose ps
docker-compose logs app
Dockploy Integration
For Dockploy deployment:
- Create a new application in Dockploy
- Set the repository URL
- Configure environment variables in Dockploy UI
- Set build command:
docker-compose build - Set start command:
docker-compose up -d
Dockploy Environment Variables
Add these in the Dockploy environment variables section:
NODE_ENV=production
SESSION_SECRET=your-super-secure-session-secret
SUPER_ADMIN=superadmin
SUPER_ADMIN_EMAIL=admin@yourcompany.com
SUPER_ADMIN_PASSWORD=YourSecurePassword123!
DOMAIN=your-domain.com
Database Management
Backup
# Manual backup
docker-compose exec app cp /app/data/production.db /app/data/backup_$(date +%Y%m%d_%H%M%S).db
# Automated backup (runs daily at 2 AM)
# Configured in docker-compose.yml backup service
Restore
# Stop application
docker-compose stop app
# Restore database
cp backups/backup_YYYYMMDD_HHMMSS.db data/production.db
# Start application
docker-compose start app
Monitoring
Health Check
curl http://localhost:3000/health
Logs
# Application logs
docker-compose logs -f app
# All services logs
docker-compose logs -f
Resource Usage
docker stats phosphat-report-app
Reverse Proxy (Traefik)
The application includes Traefik labels for automatic SSL and routing. If you're using Traefik:
- Ensure Traefik is running on your server
- Set the
DOMAINenvironment variable - The application will be automatically available at
https://your-domain.com
Security Considerations
- Change default passwords in
.env - Use strong session secret (minimum 32 characters)
- Enable firewall on your VPS
- Regular backups are configured automatically
- Keep Docker images updated
Troubleshooting
Application won't start
# Check logs
docker-compose logs app
# Check database permissions
ls -la data/
# Rebuild without cache
docker-compose build --no-cache
Database issues
# Reset database (WARNING: This will delete all data)
docker-compose down
rm -f data/production.db
docker-compose up -d
Performance issues
# Check resource usage
docker stats
# Increase memory limits in docker-compose.yml
# Optimize database queries
Updates
To update the application:
# Pull latest code
git pull origin main
# Rebuild and restart
docker-compose up -d --build
# Check logs
docker-compose logs -f app
Support
For issues and support:
- Check the logs:
docker-compose logs app - Verify environment variables
- Check database connectivity
- Review health endpoint:
/health