Self-Hosting Guide
Want to run Posthoot on your own servers? This guide will walk you through setting up your own instance. It’s actually pretty straightforward - we’ve made it as simple as possible.What you’ll need
Before we start, make sure you have these installed:- Go 1.21+ - Download here
- PostgreSQL 14+ - Download here
- Redis 6+ - Download here
- Git - Download here
Server specs
For a basic setup, you’ll want:- CPU: 2+ cores (more is better)
- RAM: 4GB minimum, 8GB recommended
- Storage: 20GB for database and logs
- Network: Stable internet connection
Quick Start
1. Get the code
2. Set up your environment
Copy the example config and edit it:.env file:
3. Set up the database
Create your PostgreSQL database:4. Install Redis
Install and start Redis (pick your OS):5. Get the dependencies
6. Start the server
http://localhost:8080 (or whatever you configured).
Production Deployment Options
For production deployments, we offer several options depending on your infrastructure and requirements:🐳 Docker Deployment (Recommended)
The easiest way to deploy with containerization. Perfect for most users.- Quick setup with Docker Compose
- Isolated environments for each component
- Easy scaling and management
- Consistent deployments across environments
Prebuilt container images You can pull ready-to-run images from GitHub Container Registry:View Docker Deployment Guide →Use these images directly in your Docker Compose / Kubernetes manifests for faster deployments.
🚀 Kubernetes Deployment
Enterprise-grade deployment for high availability and scalability.- Multi-replica deployments with load balancing
- Automatic scaling based on demand
- Advanced monitoring and health checks
- Production-grade security and networking
⚙️ Systemd Deployment
Native Linux service deployment for traditional server setups.- System service integration with automatic startup
- Resource management and security features
- Traditional server administration
- Direct system integration
📊 PM2 Deployment
Node.js-style process management for Go applications.- Process clustering and load balancing
- Zero-downtime deployments
- Built-in monitoring and logging
- Familiar for Node.js developers
Configuration
Environment variables
Here are the main settings you can configure:| Variable | What it does | Default | Required? |
|---|---|---|---|
SERVER_HOST | Where to bind the server | localhost | No |
SERVER_PORT | Port to run on | 8080 | No |
PUBLIC_URL | Your public URL | http://localhost:8080 | No |
POSTGRES_HOST | Database host | localhost | Yes |
POSTGRES_PORT | Database port | 5432 | No |
POSTGRES_USER | Database username | - | Yes |
POSTGRES_PASSWORD | Database password | - | Yes |
POSTGRES_DB | Database name | posthoot | No |
JWT_SECRET | Secret for signing tokens | - | Yes |
REDIS_HOST | Redis host | localhost | No |
REDIS_PORT | Redis port | 6379 | No |
REDIS_PASSWORD | Redis password | - | No |
SUPERADMIN_EMAIL | Admin email | - | Yes (first run) |
SUPERADMIN_PASSWORD | Admin password | - | Yes (first run) |
Storage Options
Local Storage
S3 Storage
SMTP Configuration
Gmail
SendGrid
Security Considerations
Basic Security Setup
For production deployments, consider these essential security measures:- Firewall configuration - Restrict access to necessary ports only
- Reverse proxy setup - Use Nginx or Apache for SSL termination
- SSL certificates - Install Let’s Encrypt or commercial certificates
- Database security - Create read-only users for backups
- Regular updates - Keep system and dependencies updated
Monitoring and Logging
Essential Monitoring
For production deployments, implement these monitoring components:- Health checks - Use the
/healthendpoint for service monitoring - Application logs - Configure log rotation and aggregation
- Metrics collection - Set up Prometheus and Grafana
- Alerting - Configure alerts for critical issues
Health Check Endpoint
The application provides a health check endpoint:Backup Strategy
Essential Backup Components
For production deployments, implement these backup strategies:- Database backups - Regular PostgreSQL dumps with compression
- File storage backups - Backup application data and uploads
- Configuration backups - Backup environment files and settings
- Automated scheduling - Use cron jobs for regular backups
Basic Database Backup
Troubleshooting
Common Issues
For detailed troubleshooting guides specific to each deployment method:Basic Debugging Commands
Performance Tuning
Optimization Areas
For production deployments, consider these performance optimizations:- Database tuning - Index optimization and query performance
- Redis configuration - Memory management and persistence
- Application settings - Worker concurrency and connection pooling
- System resources - CPU, memory, and network optimization
Basic Database Optimization
Support
If you encounter issues while self-hosting:- Check the logs for error messages
- Review this documentation for common solutions
- Search existing issues on GitHub
- Create a new issue with detailed information including:
- Your environment (OS, Go version, etc.)
- Configuration (sanitized)
- Error logs
- Steps to reproduce
Kubernetes Deployment
For production environments, we recommend using Kubernetes for better scalability, reliability, and management. We’ve created a comprehensive Kubernetes setup that includes all necessary components.Prerequisites
- Kubernetes cluster (v1.20+)
- kubectl configured to access your cluster
- Docker registry access
- NGINX Ingress Controller installed
- cert-manager installed (for SSL certificates)
Quick Deployment
- Navigate to the Kubernetes directory:
-
Update configuration:
- Edit
secret.yamlwith your actual passwords and keys - Update
configmap.yamlfor non-sensitive configuration - Modify
ingress.yamlwith your domain name
- Edit
- Build and deploy:
Architecture Overview
The Kubernetes setup includes:- Namespace:
posthoot-serverfor isolation - Database: PostgreSQL with persistent storage (10Gi)
- Cache: Redis with persistent storage (5Gi)
- Application: Posthoot server (2 replicas with HPA)
- Monitoring: Asynqmon for background job monitoring
- Networking: Ingress with SSL termination
- Security: Network policies and proper RBAC
Key Features
High Availability
- Multiple server replicas with load balancing
- Persistent storage for database and cache
- Health checks and automatic recovery
- Horizontal Pod Autoscaler (2-10 replicas)
Security
- Network policies restricting pod communication
- Secrets management for sensitive data
- SSL termination with automatic certificate renewal
- Isolated namespace
Monitoring
- Health check endpoints (
/health) - Asynqmon dashboard for background jobs
- Resource monitoring and alerting
- Comprehensive logging
Scaling
- Automatic scaling based on CPU/memory usage
- Resource limits and requests
- Connection pooling optimization
- Background job processing
Configuration
Environment Variables
All environment variables are managed through ConfigMaps and Secrets:Resource Allocation
- PostgreSQL: 256Mi-512Mi RAM, 250m-500m CPU
- Redis: 128Mi-256Mi RAM, 100m-200m CPU
- Server: 512Mi-1Gi RAM, 500m-1000m CPU
- Asynqmon: 128Mi-256Mi RAM, 100m-200m CPU
Management Commands
Check Status
Scaling
Updates
Backup
Troubleshooting
Common Issues
-
Image Pull Errors
-
Database Connection Issues
-
Ingress Issues
Debugging
Production Considerations
Monitoring Setup
- Install Prometheus and Grafana for metrics
- Set up alerting for critical issues
- Configure log aggregation (ELK stack)
Backup Strategy
- Regular database backups with retention policy
- Persistent volume snapshots
- Disaster recovery testing
Security Hardening
- Network policies for pod isolation
- RBAC with least privilege access
- Regular security updates
- Secrets rotation
Next Steps
After successfully setting up your self-hosted instance:- Configure your frontend to point to your API
- Set up monitoring and alerting
- Configure backups and test restore procedures
- Review security settings and update regularly
- Join the community for updates and support