# AI Infrastructure Stack for $5/Month: Full Guide

> Learn how to run n8n, Postiz, Hermes Agent, and Paperclip on one Hetzner server with Docker, Caddy, and PostgreSQL. Full setup steps, sizing, and costs.

By Jonathan Ben Haim. Updated 2026-11-29. Source: https://jonathanai.io/blog/ai-infrastructure-stack-single-server

I once added up what I was paying for a small set of AI and marketing tools each month. The number landed well above what I expected, and most of it was for software that does the same basic jobs. This guide shows how I run a full AI-powered operation on one small server for about $5 to $10 per month in server costs.

**In short:** You can run n8n, Postiz, [Hermes Agent](/blog/how-to-install-hermes-agent), and Paperclip on one Hetzner CX32 VPS for €8.21 per month, using Docker, Caddy, PostgreSQL, and Redis. Your main additional cost is AI API usage, which the guide lists at $10-50 per month for Claude. The full setup includes DNS, SSL, backups, and monitoring.

## Key takeaways

- The Hetzner CX32 VPS costs €8.21 per month and handles n8n, Postiz, Hermes Agent, and Paperclip.
- The guide uses Docker, Caddy for reverse proxy and SSL, one shared PostgreSQL instance, and one shared Redis instance.
- Postiz supports 30+ platforms and unlimited posts when self-hosted.
- The estimated total cost is ~€20-60 per month, including the VPS, domain, and [Claude API usage](/blog/claude-api-pricing).
- A daily backup script keeps 7 days of backups.
- Estimated savings versus equivalent SaaS subscriptions are ~$50-100 per month.

## What does the monthly AI software stack cost?

A typical AI-forward founder can pay $105-550 per month for social scheduling, automation, an AI assistant, task tracking, and API costs. The same kinds of tools can run on a single $5-10 per month VPS with a self-hosted open-source stack.

The average setup looks like this:

- Buffer or Hootsuite (social scheduling): $20-100
- Zapier or Make.com (automation): $20-100
- AI assistant subscription: $20-200
- Project management / task tracking: $15-50
- Various API costs: $30-100

Total: $105-550/month

The open-source version of the stack looks like this:

- n8n (automation/workflow): Self-hosted, unlimited executions
- Postiz ([social media scheduling](/blog/install-postiz-self-hosted-docker)): Self-hosted, 30+ platforms, unlimited posts
- Hermes Agent (AI personal assistant): Self-hosted, 24/7, connects to Telegram
- Paperclip ([AI agent orchestration](/blog/paperclip-ai-install-guide)): Self-hosted, manage your AI workforce

Total infrastructure cost: €5-10/month (the VPS)
Plus AI API costs: Variable, but controllable

This guide shows you how to run all of it on a single server, understand the real tradeoffs, and build an AI-powered operation that would have cost a small business $500/month two years ago.

## What does the stack look like?

The stack runs on one [Hetzner VPS](/blog/install-n8n-on-hetzner). Docker manages the containers. Caddy sits in front of the services and handles SSL. PostgreSQL and Redis are shared by the apps that need them.

```
Hetzner CX32 VPS (€8.21/month)
└── Docker (container orchestration)
    ├── n8n (port 5678) - workflow automation
    │     Reverse proxied to n8n.yourdomain.com
    ├── Postiz (ports 3000, 4200) - social media
    │     Reverse proxied to postiz.yourdomain.com  
    ├── Hermes Agent - personal AI (via Telegram, no port needed)
    └── Paperclip (port 3000 internal) - agent management
          Reverse proxied to paperclip.yourdomain.com
└── Caddy (ports 80, 443) - reverse proxy + SSL for all services
└── PostgreSQL - shared database for n8n and Postiz
└── Redis - shared cache for Postiz and n8n
```

### Why share services?

PostgreSQL and Redis can serve multiple applications. Instead of running 4 separate database instances, one PostgreSQL cluster handles n8n and Postiz. This saves RAM and simplifies backup.

## Which server size do you need?

Start with the CX32 for most setups. It is enough for the full stack when you use hosted AI APIs instead of local models. Larger servers are only needed if you run local AI models.

| Workload | Recommended Server | Cost |
|---|---|---|
| Just n8n | Hetzner CX22 (2 vCPU, 4GB RAM) | €3.49/mo |
| n8n + Postiz | Hetzner CX32 (4 vCPU, 8GB RAM) | €8.21/mo |
| Full stack (all 4 tools) | Hetzner CX32 or CX42 (8 vCPU, 16GB RAM) | €8.21-16/mo |
| Full stack + local LLM (Ollama) | Hetzner CCX33 (8 vCPU, 32GB RAM) | €35/mo |

For most builders, the CX32 at €8.21 per month handles n8n, Postiz, Hermes Agent (using Claude or OpenAI API, not local models), and Paperclip comfortably.

If you want to run [local AI models via Ollama](/blog/ollama-vs-lm-studio) to remove API costs, you need significantly more RAM, such as a CCX33 or a similar server. The break-even point against API costs depends on your usage volume.

## How do you set up the Hetzner server?

Create a CX32 server in the Hetzner Cloud console, then harden it with a non-root user, a firewall, and SSH changes. Use Ubuntu 24.04 LTS and add your public SSH key during creation.

1. Log into [console.hetzner.cloud](https://console.hetzner.cloud) and create the server with these settings:
   - Location: Choose your region (Nuremberg or Falkenstein for EU)
   - Image: Ubuntu 24.04 LTS
   - Type: CX32
   - SSH key: Add your public key
   - Firewall: Create one allowing ports 22, 80, 443
2. SSH into the server as root and run the setup commands below.
3. Switch to the deploy user.

```
ssh root@YOUR_SERVER_IP

# Update system
apt update && apt upgrade -y

# Install Docker
curl -fsSL https://get.docker.com | sh

# Install Docker Compose plugin
apt install docker-compose-plugin -y

# Create a non-root user for security
adduser deploy
usermod -aG docker deploy
usermod -aG sudo deploy

# Copy SSH key to new user
mkdir -p /home/deploy/.ssh
cp ~/.ssh/authorized_keys /home/deploy/.ssh/
chown -R deploy:deploy /home/deploy/.ssh
chmod 700 /home/deploy/.ssh
chmod 600 /home/deploy/.ssh/authorized_keys

# Basic firewall (UFW)
ufw allow ssh
ufw allow http
ufw allow https
ufw enable

# Harden SSH
sed -i 's/#PermitRootLogin yes/PermitRootLogin no/' /etc/ssh/sshd_config
sed -i 's/#PasswordAuthentication yes/PasswordAuthentication no/' /etc/ssh/sshd_config
systemctl restart sshd

# Switch to deploy user
su - deploy
```

## How do you configure DNS for the services?

Create an A record for each subdomain in your DNS provider. Point each record to your server IP address.

```
n8n.yourdomain.com        → YOUR_SERVER_IP
postiz.yourdomain.com     → YOUR_SERVER_IP
paperclip.yourdomain.com  → YOUR_SERVER_IP
```

## How do you create the directory structure?

Create one folder structure under /opt/stack, then give the deploy user ownership of it. Move into that folder before you add the config files.

```
sudo mkdir -p /opt/stack/{n8n/{data,postgres},postiz/{postgres,uploads},paperclip,shared/{redis},caddy}
sudo chown -R deploy:deploy /opt/stack
cd /opt/stack
```

## How do you write the Docker Compose file?

Create a single docker-compose.yml file in /opt/stack. It defines PostgreSQL, Redis, n8n, Postiz, Paperclip, and Caddy, and it connects them on one internal network.

```
nano /opt/stack/docker-compose.yml
```

```
version: '3.8'

# Shared services
services:
  # Shared PostgreSQL - serves both n8n and Postiz
  postgres:
    image: postgres:16-alpine
    container_name: stack-postgres
    restart: unless-stopped
    environment:
      POSTGRES_USER: admin
      POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
      POSTGRES_MULTIPLE_DATABASES: n8n,postiz
    volumes:
      - ./postgres-init:/docker-entrypoint-initdb.d
      - ./shared/postgres:/var/lib/postgresql/data
    healthcheck:
      test: ["CMD-SHELL", "pg_isready -U admin"]
      interval: 10s
      timeout: 5s
      retries: 5
    networks:
      - stack-network

  # Shared Redis - serves both n8n and Postiz
  redis:
    image: redis:7-alpine
    container_name: stack-redis
    restart: unless-stopped
    healthcheck:
      test: ["CMD", "redis-cli", "ping"]
      interval: 10s
      timeout: 5s
      retries: 5
    networks:
      - stack-network

  # n8n - workflow automation
  n8n:
    image: n8nio/n8n:latest
    container_name: stack-n8n
    restart: unless-stopped
    depends_on:
      postgres:
        condition: service_healthy
    environment:
      - N8N_HOST=n8n.yourdomain.com
      - N8N_PORT=5678
      - N8N_PROTOCOL=https
      - WEBHOOK_URL=https://n8n.yourdomain.com/
      - DB_TYPE=postgresdb
      - DB_POSTGRESDB_HOST=postgres
      - DB_POSTGRESDB_PORT=5432
      - DB_POSTGRESDB_DATABASE=n8n
      - DB_POSTGRESDB_USER=admin
      - DB_POSTGRESDB_PASSWORD=${POSTGRES_PASSWORD}
      - N8N_ENCRYPTION_KEY=${N8N_ENCRYPTION_KEY}
      - N8N_BASIC_AUTH_ACTIVE=true
      - N8N_BASIC_AUTH_USER=${N8N_USER}
      - N8N_BASIC_AUTH_PASSWORD=${N8N_PASSWORD}
      - EXECUTIONS_DATA_PRUNE=true
      - EXECUTIONS_DATA_MAX_AGE=168
    volumes:
      - ./n8n/data:/home/node/.n8n
    networks:
      - stack-network

  # Postiz - social media scheduling
  postiz:
    image: ghcr.io/gitroomhq/postiz-app:v2.11.3
    container_name: stack-postiz
    restart: unless-stopped
    depends_on:
      postgres:
        condition: service_healthy
      redis:
        condition: service_healthy
    environment:
      MAIN_URL: "https://postiz.yourdomain.com"
      FRONTEND_URL: "https://postiz.yourdomain.com"
      NEXT_PUBLIC_BACKEND_URL: "https://postiz.yourdomain.com/api"
      JWT_SECRET: "${POSTIZ_JWT_SECRET}"
      DATABASE_URL: "postgresql://admin:${POSTGRES_PASSWORD}@postgres:5432/postiz"
      REDIS_URL: "redis://redis:6379"
      BACKEND_INTERNAL_URL: "http://localhost:3000"
      IS_GENERAL: "true"
      STORAGE_PROVIDER: "local"
      UPLOAD_DIRECTORY: "/uploads"
      NEXT_PUBLIC_UPLOAD_STATIC_DIRECTORY: "/uploads"
      DISABLE_REGISTRATION: "false"
    volumes:
      - ./postiz/uploads:/uploads
    networks:
      - stack-network

  # Paperclip - AI agent orchestration
  paperclip:
    image: paperclipai/paperclip:latest
    container_name: stack-paperclip
    restart: unless-stopped
    environment:
      DATABASE_URL: "postgresql://admin:${POSTGRES_PASSWORD}@postgres:5432/paperclip"
      JWT_SECRET: "${PAPERCLIP_JWT_SECRET}"
      NODE_ENV: production
    volumes:
      - ./paperclip:/app/data
    networks:
      - stack-network

  # Caddy - reverse proxy + SSL for all services
  caddy:
    image: caddy:2-alpine
    container_name: stack-caddy
    restart: unless-stopped
    ports:
      - "80:80"
      - "443:443"
    volumes:
      - ./Caddyfile:/etc/caddy/Caddyfile
      - caddy_data:/data
      - caddy_config:/config
    networks:
      - stack-network

networks:
  stack-network:
    driver: bridge

volumes:
  caddy_data:
  caddy_config:
```

## How do you set up the environment file?

Create a .env file in /opt/stack with a strong value for each password and secret. Generate each value separately so no two secrets match.

```
nano /opt/stack/.env
```

```
# Database
POSTGRES_PASSWORD=generate-strong-password-1

# n8n
N8N_ENCRYPTION_KEY=generate-32-char-string
N8N_USER=your-username
N8N_PASSWORD=generate-strong-password-2

# Postiz
POSTIZ_JWT_SECRET=generate-strong-password-3

# Paperclip
PAPERCLIP_JWT_SECRET=generate-strong-password-4
```

Generate secure values with this
