Docker Deployment
This guide covers deploying Posthoot using Docker and Docker Compose. This is the recommended approach for most users as it provides a good balance of simplicity and production readiness.Prerequisites
Before you begin, ensure you have:- Docker installed and running
- Docker Compose installed
- Git for cloning the repository
- Basic knowledge of Docker concepts
Quick Start
1. Clone the Repository
2. Configure Environment
Copy the example environment file:.env with your configuration:
3. Create Docker Compose File
Createdocker-compose.yml:
4. Build and Start
Configuration
Environment Variables
Key environment variables for Docker deployment:| Variable | Description | Default | Required |
|---|---|---|---|
SERVER_HOST | Server bind address | 0.0.0.0 | No |
SERVER_PORT | Server port | 9001 | No |
POSTGRES_HOST | Database host | postgres | Yes |
POSTGRES_USER | Database username | - | Yes |
POSTGRES_PASSWORD | Database password | - | Yes |
POSTGRES_DB | Database name | posthoot | No |
REDIS_HOST | Redis host | redis | No |
REDIS_PASSWORD | Redis password | - | No |
JWT_SECRET | JWT signing secret | - | Yes |
Volume Mounts
The setup includes several volume mounts:- PostgreSQL data:
postgres_data:/var/lib/postgresql/data - Redis data:
redis_data:/data - Application storage:
./storage:/app/storage
Network Configuration
All services communicate through theposthoot-network bridge network, providing:
- Isolated communication between services
- Automatic DNS resolution
- No external network exposure
Management
Basic Commands
Monitoring
Backup and Restore
Database Backup
Volume Backup
Production Deployment
Using External Database
For production, consider using managed database services:Using External Redis
Reverse Proxy Setup
Add Nginx for SSL termination:nginx.conf:
Security
Environment File Security
Network Security
Container Security
Troubleshooting
Common Issues
1. Database Connection Issues
2. Redis Connection Issues
3. Port Conflicts
4. Permission Issues
Debugging
Performance Tuning
Resource Limits
Database Optimization
Redis Optimization
Monitoring
Health Checks
All services include health checks:Logging
Metrics
Consider adding monitoring:Support
For Docker-specific issues:- Check Docker and Docker Compose logs
- Verify environment variables are set correctly
- Ensure ports are not conflicting
- Check volume permissions and mounts
Next Steps
After successful deployment:- Configure monitoring and alerting
- Set up backups and test recovery
- Implement security best practices
- Plan scaling strategies
- Document procedures for your team