PostHog
PostHog is an open-source product analytics suite that provides event tracking, session recordings, feature flags, A/B testing, and user surveys in a single platform. It is designed as a self-hosted alternative to tools like Mixpanel, Amplitude, LaunchDarkly, and Hotjar combined. This stack deploys the PostHog web application, PostgreSQL 16 for metadata and user data, Redis 7 for caching and real-time features, and ClickHouse for high-performance event analytics at scale. PostHog captures events via a lightweight JavaScript SDK, provides funnel analysis, retention charts, path analysis, cohort creation, and data exports. Feature flags support percentage rollouts, multivariate flags, and targeting by user properties. Session recordings include console logs, network requests, and DOM snapshots. After deployment, access the web UI on port 8000 to create your organization and set up event tracking on your website or application.
Enthaltene Services
posthog
posthog/posthog:latest
Umgebungsvariablen:
postgres
postgres:16-alpine
Umgebungsvariablen:
redis
redis:7-alpine
clickhouse
clickhouse/clickhouse-server:latest
Umgebungsvariablen:
Generiertes YAML
# Generated by ComposeHub (composehub.dev)
name: posthog
services:
posthog:
image: posthog/posthog:latest
restart: always
ports:
- 8000:8000
volumes:
- posthog_data:/var/lib/posthog
environment:
SECRET_KEY: ${SECRET_KEY:-changeme-generate-a-long-random-string}
DATABASE_URL: postgres://${POSTGRES_USER:-posthog}:${POSTGRES_PASSWORD:-changeme}@postgres:5432/${POSTGRES_DB:-posthog}
REDIS_URL: redis://redis:6379/
CLICKHOUSE_HOST: clickhouse
CLICKHOUSE_DATABASE: ${CLICKHOUSE_DB:-posthog}
CLICKHOUSE_SECURE: "false"
CLICKHOUSE_VERIFY: "false"
SITE_URL: ${SITE_URL:-http://localhost:8000}
IS_BEHIND_PROXY: ${IS_BEHIND_PROXY:-false}
DISABLE_SECURE_SSL_REDIRECT: ${DISABLE_SSL_REDIRECT:-true}
networks:
- posthog
depends_on:
postgres:
condition: service_healthy
redis:
condition: service_healthy
clickhouse:
condition: service_healthy
healthcheck:
test:
- CMD-SHELL
- curl -f http://localhost:8000/_health/ || exit 1
interval: 30s
timeout: 10s
retries: 5
start_period: 90s
deploy:
resources:
limits:
cpus: "2.00"
memory: 2048M
reservations:
cpus: "0.50"
memory: 512M
labels:
com.composehub.description: PostHog product analytics application server
postgres:
image: postgres:16-alpine
restart: always
volumes:
- posthog_db:/var/lib/postgresql/data
environment:
POSTGRES_DB: ${POSTGRES_DB:-posthog}
POSTGRES_USER: ${POSTGRES_USER:-posthog}
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-changeme}
networks:
- posthog
healthcheck:
test:
- CMD-SHELL
- pg_isready -U ${POSTGRES_USER:-posthog} -d ${POSTGRES_DB:-posthog}
interval: 5s
timeout: 5s
retries: 10
start_period: 30s
deploy:
resources:
limits:
cpus: "1.00"
memory: 512M
reservations:
cpus: "0.25"
memory: 128M
labels:
com.composehub.description: PostgreSQL 16 database for PostHog metadata
redis:
image: redis:7-alpine
restart: always
command:
- redis-server
- "--save"
- "20"
- "1"
- "--loglevel"
- warning
- "--maxmemory"
- 512mb
- "--maxmemory-policy"
- allkeys-lru
volumes:
- posthog_redis:/data
networks:
- posthog
healthcheck:
test:
- CMD-SHELL
- redis-cli ping | grep PONG
interval: 5s
timeout: 5s
retries: 10
start_period: 10s
deploy:
resources:
limits:
cpus: "0.50"
memory: 576M
reservations:
cpus: "0.10"
memory: 64M
labels:
com.composehub.description: Redis 7 for PostHog caching and real-time features
clickhouse:
image: clickhouse/clickhouse-server:latest
restart: always
volumes:
- posthog_clickhouse:/var/lib/clickhouse
- posthog_clickhouse_logs:/var/log/clickhouse-server
environment:
CLICKHOUSE_DB: ${CLICKHOUSE_DB:-posthog}
CLICKHOUSE_DEFAULT_ACCESS_MANAGEMENT: "1"
networks:
- posthog
healthcheck:
test:
- CMD-SHELL
- wget --no-verbose --tries=1 --spider http://localhost:8123/ping || exit 1
interval: 10s
timeout: 5s
retries: 10
start_period: 30s
deploy:
resources:
limits:
cpus: "2.00"
memory: 2048M
reservations:
cpus: "0.50"
memory: 512M
labels:
com.composehub.description: ClickHouse OLAP database for PostHog event analytics
networks:
posthog:
driver: bridge
volumes:
posthog_data:
driver: local
posthog_db:
driver: local
posthog_redis:
driver: local
posthog_clickhouse:
driver: local
posthog_clickhouse_logs:
driver: local
Kurzinfo
- Services
- 4
- Netzwerke
- 1
- Volumes
- 5
Wann verwenden
Dieses Template ist ideal für die Einrichtung einer posthog Umgebung. Alle Services sind mit Healthchecks, Ressourcenlimits und sinnvollen Standardwerten vorkonfiguriert. Passen Sie die Umgebungsvariablen an, bevor Sie in Produktion gehen.
Tipps
- Ändern Sie alle Standardpasswörter vor dem Deployment
- Überprüfen Sie die Ressourcenlimits für Ihre Hardware
- Fügen Sie einen Reverse Proxy für HTTPS in Produktion hinzu
- Konfigurieren Sie Backup-Strategien für Daten-Volumes