Skip to main content

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:

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
If you’re just testing locally, you can get away with less, but for production, these are the minimums we’d recommend.

Quick Start

1. Get the code

2. Set up your environment

Copy the example config and edit it:
Here’s what you need to configure in your .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

That’s it! Your server should be running on http://localhost:8080 (or whatever you configured).

Production Deployment Options

For production deployments, we offer several options depending on your infrastructure and requirements: 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:
Use these images directly in your Docker Compose / Kubernetes manifests for faster deployments.
View Docker Deployment Guide β†’

πŸš€ 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
View Kubernetes Deployment Guide β†’

βš™οΈ 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
View Systemd Deployment Guide β†’

πŸ“Š 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
Choose the deployment method that best fits your infrastructure and team expertise.

Configuration

Environment variables

Here are the main settings you can configure:

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
Each deployment guide includes detailed security configurations specific to that method:

Monitoring and Logging

Essential Monitoring

For production deployments, implement these monitoring components:
  • Health checks - Use the /health endpoint for service monitoring
  • Application logs - Configure log rotation and aggregation
  • Metrics collection - Set up Prometheus and Grafana
  • Alerting - Configure alerts for critical issues
Each deployment guide includes specific monitoring setup:

Health Check Endpoint

The application provides a health check endpoint:
Expected response:

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
Each deployment guide includes specific backup procedures:

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
Each deployment guide includes specific performance tuning:

Basic Database Optimization

Support

If you encounter issues while self-hosting:
  1. Check the logs for error messages
  2. Review this documentation for common solutions
  3. Search existing issues on GitHub
  4. 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

  1. Navigate to the Kubernetes directory:
  1. Update configuration:
    • Edit secret.yaml with your actual passwords and keys
    • Update configmap.yaml for non-sensitive configuration
    • Modify ingress.yaml with your domain name
  2. Build and deploy:

Architecture Overview

The Kubernetes setup includes:
  • Namespace: posthoot-server for 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

  1. Image Pull Errors
  2. Database Connection Issues
  3. 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
For detailed Kubernetes configuration and advanced setup options, see the Kubernetes README.

Next Steps

After successfully setting up your self-hosted instance:
  1. Configure your frontend to point to your API
  2. Set up monitoring and alerting
  3. Configure backups and test restore procedures
  4. Review security settings and update regularly
  5. Join the community for updates and support