mirror of
https://github.com/nickyeoman/docker-compose-cookbooks.git
synced 2026-09-03 18:36:22 +00:00
fix high-priority stacks: add missing sample.env+README for hedgedoc, memos, posthog, shlink
This commit is contained in:
@@ -0,0 +1,88 @@
|
||||
# PostHog
|
||||
|
||||
## Overview
|
||||
|
||||
PostHog is a self-hosted product analytics platform offering event tracking, session recording, feature flags, and experimentation. This Docker Compose stack deploys PostHog with PostgreSQL, Redis, ClickHouse, and Kafka.
|
||||
|
||||
**Note:** PostHog is resource-intensive. Minimum 4GB RAM, 8GB+ recommended.
|
||||
|
||||
## Project Details
|
||||
|
||||
- **Project Repository:** [PostHog](https://posthog.com)
|
||||
- **Container Image:** [Docker Hub](https://hub.docker.com/r/posthog/posthog)
|
||||
- **Compose Example:** [Official Hobby Compose](https://github.com/PostHog/posthog/blob/master/docker-compose.hobby.yml)
|
||||
- **Documentation:** [Self-Host Docs](https://posthog.com/docs/self-host)
|
||||
- **Reverse Proxy Port:** `8000`
|
||||
|
||||
## Getting Started
|
||||
|
||||
1. Copy `sample.env` to `.env` and edit all values (especially `POSTHOG_SECRET_KEY`)
|
||||
2. Start the stack: `docker compose up -d` (first startup will run migrations — this can take several minutes)
|
||||
3. Open http://localhost:8000 in your browser
|
||||
4. Create your admin account on first visit
|
||||
|
||||
## Environment Variable Notes
|
||||
|
||||
### Compose
|
||||
- `VOL_PATH` – base path for persistent data (default: `/data`)
|
||||
- `POSTHOG_IMAGE` – image tag (default: `posthog/posthog:latest`)
|
||||
- `POSTHOG_RESTART` – restart policy (default: `unless-stopped`)
|
||||
|
||||
### Core
|
||||
- `POSTHOG_SITE_URL` – public URL of your PostHog instance (required)
|
||||
- `POSTHOG_SECRET_KEY` – Django secret key for session encryption (required, set to a long random string)
|
||||
|
||||
### Database
|
||||
- `POSTHOG_DB_NAME` – PostgreSQL database name (default: `posthog`)
|
||||
- `POSTHOG_DB_USER` – PostgreSQL user (default: `posthog`)
|
||||
- `POSTHOG_DB_PASSWORD` – PostgreSQL password (required)
|
||||
|
||||
### ClickHouse
|
||||
- `POSTHOG_CLICKHOUSE_DB` – ClickHouse database name (default: `posthog`)
|
||||
- `POSTHOG_CLICKHOUSE_USER` – ClickHouse user (default: `clickhouse`)
|
||||
- `POSTHOG_CLICKHOUSE_PASSWORD` – ClickHouse password (required)
|
||||
|
||||
### Email (optional)
|
||||
- `POSTHOG_EMAIL_HOST` – SMTP server host
|
||||
- `POSTHOG_EMAIL_USER` – SMTP username
|
||||
- `POSTHOG_EMAIL_PASSWORD` – SMTP password
|
||||
- `POSTHOG_EMAIL_PORT` – SMTP port (default: `587`)
|
||||
- `POSTHOG_EMAIL_TLS` – enable TLS (default: `true`)
|
||||
|
||||
## Volume Notes
|
||||
|
||||
- `${VOL_PATH:-/data}/posthog/postgres` – PostgreSQL data
|
||||
- `${VOL_PATH:-/data}/posthog/redis` – Redis data
|
||||
- `${VOL_PATH:-/data}/posthog/clickhouse` – ClickHouse analytics data
|
||||
- `${VOL_PATH:-/data}/posthog/kafka` – Kafka message queue data
|
||||
- `${VOL_PATH:-/data}/posthog/data` – PostHog app data (uploads, exports)
|
||||
- `${VOL_PATH:-/data}/posthog/logs` – application logs
|
||||
|
||||
## Network Notes
|
||||
|
||||
- Requires the external `proxy` network for reverse proxy access.
|
||||
- All backend services communicate over the internal network.
|
||||
|
||||
## Docker Run
|
||||
|
||||
PostHog requires multiple interdependent services. Use the Docker Compose stack rather than individual `docker run` commands.
|
||||
|
||||
## Additional Notes / Gotchas
|
||||
|
||||
- **Resource heavy.** PostHog needs at least 4GB RAM and 10GB disk. ClickHouse and Kafka are memory-intensive.
|
||||
- **First startup is slow.** Migrations run on initial deploy and can take 5–10 minutes. Check logs with `docker compose logs -f posthog`.
|
||||
- **SECRET_KEY must be set.** Generate one with `openssl rand -hex 32` and set it in `.env`.
|
||||
- **Kafka** runs without authentication on the internal network only.
|
||||
- This is a simplified dev deployment. For production, see the [official hobby compose](https://github.com/PostHog/posthog/blob/master/docker-compose.hobby.yml) which includes additional services (plugins, ingestion pipelines, object storage, etc.).
|
||||
- Port 8000 is the internal web port. Proxy it through Nginx Proxy Manager on the `proxy` network.
|
||||
|
||||
## Dockhand Stack, Deploy from Git
|
||||
|
||||
Cookbooks Repository
|
||||
stackname: posthog
|
||||
Compose file path: posthog_dev/compose.yaml
|
||||
Additional env file (optional): posthog_dev/sample.env
|
||||
|
||||
Then "Load" posthog_dev/sample.env into the Environmental variables in dockhand
|
||||
|
||||
Create the Stack
|
||||
@@ -0,0 +1,135 @@
|
||||
services:
|
||||
postgres:
|
||||
image: ${POSTHOG_POSTGRES_IMAGE:-postgres:15-alpine}
|
||||
restart: ${POSTHOG_RESTART:-unless-stopped}
|
||||
volumes:
|
||||
- ${VOL_PATH:-/data}/posthog/postgres:/var/lib/postgresql/data
|
||||
environment:
|
||||
- POSTGRES_DB=${POSTHOG_DB_NAME:-posthog}
|
||||
- POSTGRES_USER=${POSTHOG_DB_USER:-posthog}
|
||||
- POSTGRES_PASSWORD=${POSTHOG_DB_PASSWORD:-posthog}
|
||||
- POSTGRES_HOST_AUTH_METHOD=scram-sha-256
|
||||
networks:
|
||||
- internal
|
||||
healthcheck:
|
||||
test: ["CMD-SHELL", "pg_isready -U ${POSTHOG_DB_USER:-posthog} -d ${POSTHOG_DB_NAME:-posthog}"]
|
||||
interval: 5s
|
||||
timeout: 5s
|
||||
retries: 5
|
||||
|
||||
redis:
|
||||
image: ${POSTHOG_REDIS_IMAGE:-redis:7-alpine}
|
||||
restart: ${POSTHOG_RESTART:-unless-stopped}
|
||||
volumes:
|
||||
- ${VOL_PATH:-/data}/posthog/redis:/data
|
||||
networks:
|
||||
- internal
|
||||
healthcheck:
|
||||
test: ["CMD", "redis-cli", "ping"]
|
||||
interval: 5s
|
||||
timeout: 5s
|
||||
retries: 5
|
||||
|
||||
clickhouse:
|
||||
image: ${POSTHOG_CLICKHOUSE_IMAGE:-clickhouse/clickhouse-server:24-alpine}
|
||||
restart: ${POSTHOG_RESTART:-unless-stopped}
|
||||
volumes:
|
||||
- ${VOL_PATH:-/data}/posthog/clickhouse:/var/lib/clickhouse
|
||||
environment:
|
||||
- CLICKHOUSE_DB=${POSTHOG_CLICKHOUSE_DB:-posthog}
|
||||
- CLICKHOUSE_USER=${POSTHOG_CLICKHOUSE_USER:-clickhouse}
|
||||
- CLICKHOUSE_PASSWORD=${POSTHOG_CLICKHOUSE_PASSWORD:-clickhouse}
|
||||
- CLICKHOUSE_DEFAULT_ACCESS_MANAGEMENT=1
|
||||
networks:
|
||||
- internal
|
||||
|
||||
kafka:
|
||||
image: ${POSTHOG_KAFKA_IMAGE:-docker.io/bitnami/kafka:3.7}
|
||||
restart: ${POSTHOG_RESTART:-unless-stopped}
|
||||
volumes:
|
||||
- ${VOL_PATH:-/data}/posthog/kafka:/bitnami/kafka
|
||||
environment:
|
||||
- KAFKA_CFG_NODE_ID=0
|
||||
- KAFKA_CFG_PROCESS_ROLES=controller,broker
|
||||
- KAFKA_CFG_CONTROLLER_QUORUM_VOTERS=0@kafka:9093
|
||||
- KAFKA_CFG_CONTROLLER_LISTENER_NAMES=CONTROLLER
|
||||
- KAFKA_CFG_LISTENERS=PLAINTEXT://:9092,CONTROLLER://:9093
|
||||
- KAFKA_CFG_ADVERTISED_LISTENERS=PLAINTEXT://kafka:9092
|
||||
- KAFKA_CFG_LISTENER_SECURITY_PROTOCOL_MAP=CONTROLLER:PLAINTEXT,PLAINTEXT:PLAINTEXT
|
||||
- ALLOW_PLAINTEXT_LISTENER=yes
|
||||
- KAFKA_CFG_AUTO_CREATE_TOPICS_ENABLE=true
|
||||
- KAFKA_CFG_LOG_RETENTION_MS=3600000
|
||||
- KAFKA_CFG_LOG_RETENTION_CHECK_INTERVAL_MS=300000
|
||||
- KAFKA_CFG_LOG_RETENTION_HOURS=1
|
||||
networks:
|
||||
- internal
|
||||
|
||||
posthog:
|
||||
image: ${POSTHOG_IMAGE:-posthog/posthog:latest}
|
||||
restart: ${POSTHOG_RESTART:-unless-stopped}
|
||||
command: /compose/start
|
||||
volumes:
|
||||
- ${VOL_PATH:-/data}/posthog/data:/data
|
||||
- ${VOL_PATH:-/data}/posthog/logs:/var/log
|
||||
environment:
|
||||
- SITE_URL=${POSTHOG_SITE_URL:-http://localhost:8000}
|
||||
- SECRET_KEY=${POSTHOG_SECRET_KEY:?must_be_set}
|
||||
- DATABASE_URL=postgres://${POSTHOG_DB_USER:-posthog}:${POSTHOG_DB_PASSWORD:-posthog}@postgres:5432/${POSTHOG_DB_NAME:-posthog}
|
||||
- REDIS_URL=redis://redis:6379/
|
||||
- CLICKHOUSE_HOST=clickhouse
|
||||
- CLICKHOUSE_DATABASE=${POSTHOG_CLICKHOUSE_DB:-posthog}
|
||||
- CLICKHOUSE_USER=${POSTHOG_CLICKHOUSE_USER:-clickhouse}
|
||||
- CLICKHOUSE_PASSWORD=${POSTHOG_CLICKHOUSE_PASSWORD:-clickhouse}
|
||||
- CLICKHOUSE_SECURE=false
|
||||
- CLICKHOUSE_VERIFY=false
|
||||
- KAFKA_HOSTS=kafka:9092
|
||||
- DEPLOYMENT=hobby
|
||||
- OPT_OUT_CAPTURE=true
|
||||
- DISABLE_SECURITY=0
|
||||
- EMAIL_HOST=${POSTHOG_EMAIL_HOST:-}
|
||||
- EMAIL_HOST_USER=${POSTHOG_EMAIL_USER:-}
|
||||
- EMAIL_HOST_PASSWORD=${POSTHOG_EMAIL_PASSWORD:-}
|
||||
- EMAIL_PORT=${POSTHOG_EMAIL_PORT:-587}
|
||||
- EMAIL_USE_TLS=${POSTHOG_EMAIL_TLS:-true}
|
||||
networks:
|
||||
- proxy
|
||||
- internal
|
||||
depends_on:
|
||||
- postgres
|
||||
- redis
|
||||
- clickhouse
|
||||
- kafka
|
||||
|
||||
worker:
|
||||
image: ${POSTHOG_IMAGE:-posthog/posthog:latest}
|
||||
restart: ${POSTHOG_RESTART:-unless-stopped}
|
||||
command: /compose/worker
|
||||
volumes:
|
||||
- ${VOL_PATH:-/data}/posthog/data:/data
|
||||
environment:
|
||||
- SITE_URL=${POSTHOG_SITE_URL:-http://localhost:8000}
|
||||
- SECRET_KEY=${POSTHOG_SECRET_KEY:?must_be_set}
|
||||
- DATABASE_URL=postgres://${POSTHOG_DB_USER:-posthog}:${POSTHOG_DB_PASSWORD:-posthog}@postgres:5432/${POSTHOG_DB_NAME:-posthog}
|
||||
- REDIS_URL=redis://redis:6379/
|
||||
- CLICKHOUSE_HOST=clickhouse
|
||||
- CLICKHOUSE_DATABASE=${POSTHOG_CLICKHOUSE_DB:-posthog}
|
||||
- CLICKHOUSE_USER=${POSTHOG_CLICKHOUSE_USER:-clickhouse}
|
||||
- CLICKHOUSE_PASSWORD=${POSTHOG_CLICKHOUSE_PASSWORD:-clickhouse}
|
||||
- CLICKHOUSE_SECURE=false
|
||||
- CLICKHOUSE_VERIFY=false
|
||||
- KAFKA_HOSTS=kafka:9092
|
||||
- DEPLOYMENT=hobby
|
||||
- OPT_OUT_CAPTURE=true
|
||||
networks:
|
||||
- internal
|
||||
depends_on:
|
||||
- postgres
|
||||
- redis
|
||||
- clickhouse
|
||||
- kafka
|
||||
- posthog
|
||||
|
||||
networks:
|
||||
proxy:
|
||||
external: true
|
||||
internal:
|
||||
@@ -1,3 +0,0 @@
|
||||
---
|
||||
|
||||
# https://hub.docker.com/r/posthog/posthog
|
||||
@@ -0,0 +1,25 @@
|
||||
# Compose
|
||||
VOL_PATH=/data
|
||||
POSTHOG_IMAGE=posthog/posthog:latest
|
||||
POSTHOG_RESTART=unless-stopped
|
||||
|
||||
# Core
|
||||
POSTHOG_SITE_URL=http://localhost:8000
|
||||
POSTHOG_SECRET_KEY=ChangeMeToALongRandomStringHere
|
||||
|
||||
# Database
|
||||
POSTHOG_DB_NAME=posthog
|
||||
POSTHOG_DB_USER=posthog
|
||||
POSTHOG_DB_PASSWORD=ChangeThisPassword
|
||||
|
||||
# ClickHouse
|
||||
POSTHOG_CLICKHOUSE_DB=posthog
|
||||
POSTHOG_CLICKHOUSE_USER=clickhouse
|
||||
POSTHOG_CLICKHOUSE_PASSWORD=ChangeThisPassword
|
||||
|
||||
# Email (optional)
|
||||
POSTHOG_EMAIL_HOST=
|
||||
POSTHOG_EMAIL_USER=
|
||||
POSTHOG_EMAIL_PASSWORD=
|
||||
POSTHOG_EMAIL_PORT=587
|
||||
POSTHOG_EMAIL_TLS=true
|
||||
Reference in New Issue
Block a user