Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

add PostHog #1145

Merged
merged 4 commits into from
Sep 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
338 changes: 338 additions & 0 deletions public/v4/apps/posthog.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,338 @@
captainVersion: 4
services:
$$cap_appname-db:
image: postgres:12-alpine
environment:
POSTGRES_USER: $$cap_postgres_user
POSTGRES_DB: $$cap_postgres_db
POSTGRES_PASSWORD: $$cap_postgres_password
volumes:
- $$cap_appname-postgres-data:/var/lib/postgresql/data
caproverExtra:
notExposeAsWebApp: 'true'

$$cap_appname-redis:
caproverExtra:
notExposeAsWebApp: 'true'
restart: on-failure
image: redis:6.2.7-alpine
command: sh -c "redis-server --maxmemory-policy allkeys-lru --maxmemory 200mb"

$$cap_appname-redis7:
image: redis:7.2-alpine
restart: on-failure
caproverExtra:
notExposeAsWebApp: 'true'
command: sh -c "redis-server --maxmemory-policy allkeys-lru --maxmemory 200mb"

$$cap_appname-zookeeper:
image: zookeeper:3.7.0
restart: on-failure
caproverExtra:
notExposeAsWebApp: 'true'
volumes:
- $$cap_appname-zookeeper-datalog:/datalog
- $$cap_appname-zookeeper-data:/data
- $$cap_appname-zookeeper-logs:/logs

$$cap_appname-clickhouse:
restart: on-failure
caproverExtra:
notExposeAsWebApp: 'true'
dockerfileLines:
- FROM alpine AS build
- RUN apk add --no-cache curl tar
- WORKDIR /
- RUN mkdir -p "docker"
- RUN curl -L https://github.com/PostHog/posthog/tarball/c25b571388a9ad05d529a14daee8f49819280496 | tar -xz --wildcards --strip-components=2 -C "./" '*/posthog/idl/*'
- RUN curl -L https://github.com/PostHog/posthog/tarball/c25b571388a9ad05d529a14daee8f49819280496 | tar -xz --wildcards --strip-components=2 -C "docker" '*/docker/*'
- RUN sed -i "s|<host>zookeeper</host>|<host>srv-captain--$$cap_appname-zookeeper</host>|" /docker/clickhouse/config.xml
- FROM clickhouse/clickhouse-server:23.11.2.11-alpine
- COPY --from=build /docker/clickhouse/config.xml /etc/clickhouse-server/config.xml
- COPY --from=build /docker/clickhouse/users.xml /etc/clickhouse-server/users.xml
- COPY --from=build /docker/clickhouse/docker-entrypoint-initdb.d /docker-entrypoint-initdb.d
- COPY --from=build /idl /idl
volumes:
- clickhouse-data:/var/lib/clickhouse

$$cap_appname-kafka:
image: ghcr.io/posthog/kafka-container:v2.8.2
restart: on-failure
caproverExtra:
notExposeAsWebApp: 'true'
environment:
KAFKA_BROKER_ID: 1001
KAFKA_CFG_RESERVED_BROKER_MAX_ID: 1001
KAFKA_CFG_LISTENERS: PLAINTEXT://:9092
KAFKA_CFG_ADVERTISED_LISTENERS: PLAINTEXT://srv-captain--$$cap_appname-kafka:9092
KAFKA_CFG_ZOOKEEPER_CONNECT: srv-captain--$$cap_appname-zookeeper:2181
ALLOW_PLAINTEXT_LISTENER: 'true'
depends_on:
- $$cap_appname-zookeeper
volumes:
- $$cap_appname-kafka-data:/bitnami/kafka

$$cap_appname-worker:
image: posthog/posthog:$$cap_posthog_version
command: ./bin/docker-worker-celery --with-scheduler
caproverExtra:
notExposeAsWebApp: 'true'
restart: on-failure
environment:
SITE_URL: http://$$cap_appname-web.$$cap_root_domain
SECRET_KEY: $$cap_secret_key
DATABASE_URL: postgres://$$cap_postgres_user:$$cap_postgres_password@srv-captain--$$cap_appname-db:$$cap_postgres_port/$$cap_postgres_db
REDIS_URL: redis://srv-captain--$$cap_appname-redis:6379/
CLICKHOUSE_HOST: srv-captain--$$cap_appname-clickhouse
KAFKA_HOSTS: srv-captain--$$cap_appname-kafka:9092
IS_BEHIND_PROXY: $$cap_behind_proxy
TRUST_ALL_PROXIES: $$cap_trust_all_proxies
CLICKHOUSE_SECURE: $$cap_clickhouse_secure
DISABLE_SECURE_SSL_REDIRECT: $$cap_disable_ssl_redirect
OBJECT_STORAGE_ACCESS_KEY_ID: $$cap_object_storage_root_user
OBJECT_STORAGE_SECRET_ACCESS_KEY: $$cap_object_storage_root_password
OBJECT_STORAGE_ENDPOINT: http://srv-captain--$$cap_appname-objectstorage:19000
OBJECT_STORAGE_ENABLED: $$cap_enable_object_storage

$$cap_appname-objectstorage:
image: minio/minio:RELEASE.2022-06-25T15-50-16Z
restart: on-failure
volumes:
- $$cap_appname-objectstorage:/data
ports:
- '19000:19000'
- '19001:19001'
environment:
MINIO_ROOT_USER: $$cap_object_storage_root_user
MINIO_ROOT_PASSWORD: $$cap_object_storage_root_password
command: sh -c 'mkdir -p /data/posthog && minio server --address ":19000" --console-address ":19001" /data'

$$cap_appname-plugin:
image: posthog/posthog:$$cap_posthog_version
depends_on:
- $$cap_appname-db
- $$cap_appname-redis
- $$cap_appname-clickhouse
- $$cap_appname-kafka
- $$cap_appname-objectstorage
caproverExtra:
notExposeAsWebApp: 'true'
environment:
SECRET_KEY: $$cap_secret_key
SITE_URL: http://$$cap_appname-web.$$cap_root_domain
DATABASE_URL: postgres://$$cap_postgres_user:$$cap_postgres_password@srv-captain--$$cap_appname-db:$$cap_postgres_port/$$cap_postgres_db
REDIS_URL: redis://srv-captain--$$cap_appname-redis:6379/
CLICKHOUSE_HOST: srv-captain--$$cap_appname-clickhouse
KAFKA_HOSTS: srv-captain--$$cap_appname-kafka:9092
DISABLE_SECURE_SSL_REDIRECT: $$cap_disable_ssl_redirect
OBJECT_STORAGE_ACCESS_KEY_ID: $$cap_object_storage_root_user
OBJECT_STORAGE_SECRET_ACCESS_KEY: $$cap_object_storage_root_password
OBJECT_STORAGE_ENDPOINT: http://srv-captain--$$cap_appname-objectstorage:19000
OBJECT_STORAGE_ENABLED: $$cap_enable_object_storage
CLICKHOUSE_SECURE: $$cap_clickhouse_secure
CDP_REDIS_HOST: srv-captain--$$cap_appname-redis7
CDP_REDIS_PORT: 6379
command: ./bin/plugin-server

$$cap_appname-web:
image: posthog/posthog:$$cap_posthog_version
caproverExtra:
containerHttpPort: '8000'
restart: on-failure
depends_on:
- $$cap_appname-db
- $$cap_appname-redis
- $$cap_appname-clickhouse
- $$cap_appname-kafka
environment:
SITE_URL: http://$$cap_appname-web.$$cap_root_domain
SECRET_KEY: $$cap_secret_key
DATABASE_URL: postgres://$$cap_postgres_user:$$cap_postgres_password@srv-captain--$$cap_appname-db:$$cap_postgres_port/$$cap_postgres_db
REDIS_URL: redis://srv-captain--$$cap_appname-redis:6379/
CLICKHOUSE_HOST: srv-captain--$$cap_appname-clickhouse
KAFKA_HOSTS: srv-captain--$$cap_appname-kafka:9092
IS_BEHIND_PROXY: $$cap_behind_proxy
TRUST_ALL_PROXIES: $$cap_trust_all_proxies
CLICKHOUSE_SECURE: $$cap_clickhouse_secure
DISABLE_SECURE_SSL_REDIRECT: $$cap_disable_ssl_redirect
OBJECT_STORAGE_ACCESS_KEY_ID: $$cap_object_storage_root_user
OBJECT_STORAGE_SECRET_ACCESS_KEY: $$cap_object_storage_root_password
OBJECT_STORAGE_ENDPOINT: http://srv-captain--$$cap_appname-objectstorage:19000
OBJECT_STORAGE_ENABLED: $$cap_enable_object_storage
command: sh -c "./bin/migrate && ./bin/docker-server"

# Temporal containers
$$cap_appname-elasticsearch:
caproverExtra:
notExposeAsWebApp: 'true'
environment:
cluster.routing.allocation.disk.threshold_enabled: true
cluster.routing.allocation.disk.watermark.low: 512mb
cluster.routing.allocation.disk.watermark.high: 256mb
cluster.routing.allocation.disk.watermark.flood_stage: 128mb
discovery.type: single-node
ES_JAVA_OPTS: -Xms256m -Xmx256m
xpack.security.enabled: false
image: elasticsearch:7.16.2
expose:
- 9200
volumes:
- $$cap_appname-elasticsearch:/var/lib/elasticsearch/data

$$cap_appname-temporal:
restart: on-failure
caproverExtra:
notExposeAsWebApp: 'true'
environment:
DB: postgresql
DB_PORT: $$cap_postgres_port
POSTGRES_USER: $$cap_postgres_user
POSTGRES_PWD: $$cap_postgres_password
POSTGRES_SEEDS: srv-captain--$$cap_appname-db
ENABLE_ES: $$cap_enable_elastic_search
ES_SEEDS: srv-captain--$$cap_appname-elasticsearch
ES_VERSION: v7
image: temporalio/auto-setup:1.20.0
ports:
- 7233:7233
depends_on:
$$cap_appname-db:
condition: service_healthy
$$cap_appname-elasticsearch:
condition: service_started

$$cap_appname-temporal-admin-tools:
environment:
TEMPORAL_CLI_ADDRESS: srv-captain--$$cap_appname-temporal:7233
image: temporalio/admin-tools:1.20.0
caproverExtra:
notExposeAsWebApp: 'true'
depends_on:
- $$cap_appname-temporal

$$cap_appname-temporal-ui:
caproverExtra:
containerHttpPort: '8080'
environment:
TEMPORAL_ADDRESS: srv-captain--$$cap_appname-temporal:7233
TEMPORAL_CORS_ORIGINS: http://localhost:3000
image: temporalio/ui:2.10.3
ports:
- 8081:8080
depends_on:
- $$cap_appname-temporal
- $$cap_appname-db

$$cap_appname-temporal-django-worker:
image: posthog/posthog:$$cap_posthog_version
command: ./bin/temporal-django-worker
restart: on-failure
caproverExtra:
notExposeAsWebApp: 'true'
environment:
SITE_URL: http://$$cap_appname-web.$$cap_root_domain
SECRET_KEY: $$cap_secret_key
DATABASE_URL: postgres://$$cap_postgres_user:$$cap_postgres_password@srv-captain--$$cap_appname-db:$$cap_postgres_port/$$cap_postgres_db
REDIS_URL: redis://srv-captain--$$cap_appname-redis:6379/
CLICKHOUSE_HOST: srv-captain--$$cap_appname-clickhouse
KAFKA_HOSTS: srv-captain--$$cap_appname-kafka:9092
IS_BEHIND_PROXY: $$cap_behind_proxy
TRUST_ALL_PROXIES: $$cap_trust_all_proxies
CLICKHOUSE_SECURE: $$cap_clickhouse_secure
DISABLE_SECURE_SSL_REDIRECT: $$cap_disable_ssl_redirect
TEMPORAL_HOST: srv-captain--$$cap_appname-temporal
depends_on:
- $$cap_appname-db
- $$cap_appname-redis
- $$cap_appname-clickhouse
- $$cap_appname-kafka
- $$cap_appname-objectstorage
- $$cap_appname-temporal

caproverOneClickApp:
variables:
- id: $$cap_postgres_db
label: Postgres DB name
defaultValue: posthog

- id: $$cap_postgres_user
label: Postgres User
defaultValue: posthog

- id: $$cap_postgres_password
defaultValue: $$cap_gen_random_hex(12)
label: Postgres Password

- id: $$cap_postgres_port
defaultValue: 5432
label: Postgres Port
validRegex: /^\d+$/

- id: $$cap_posthog_version
label: PostHog's version
defaultValue: 577f7abaec6cdf6e162bc51096c4f774e21f29ee

- id: $$cap_secret_key
label: PostHog-LLM Secret Key
defaultValue: $$cap_gen_random_hex(23)
validRegex: /^([^\s^\/])+$/

- id: $$cap_behind_proxy
label: Is PostHog running behind a proxy
defaultValue: 'true'
validRegex: /^(true|false)$/
description: 'Set to true if PostHog is running behind proxy (Caddy, nginx)'

- id: $$cap_trust_all_proxies
label: Trust all proxies
defaultValue: 'false'
validRegex: /^(true|false)$/
description: 'Determines if all proxies can be trusted.'

- id: $$cap_disable_ssl_redirect
label: Disable Secure SSL Redirect
defaultValue: 'true'
validRegex: /^(true|false)$/
description: Disables automatic redirect from port 80 (HTTP) to port 443 (HTTPS).

- id: $$cap_clickhouse_secure
label: Clickhouse secure
defaultValue: 'false'
validRegex: /^(true|false)$/
description: Whether to secure ClickHouse connection

- id: $$cap_enable_object_storage
label: Enable Object storage
validRegex: /^(true|false)$/
defaultValue: 'true'

- id: $$cap_object_storage_root_user
label: Object Storage Root User
description: The access key for the root user for MinIO
defaultValue: object_storage_root_user

- id: $$cap_object_storage_root_password
label: Object Storage Password Key
description: The secret key for the root user
defaultValue: $$cap_gen_random_hex(23)
validRegex: /^([^\s^\/])+$/

- id: $$cap_enable_elastic_search
description: Enable elastic search with Temporal
label: Enable Elastic Search
defaultValue: 'false'
validRegex: /^(true|false)$/

instructions:
start: >-
Enter your PostHog Configuration parameters and click on next. The process will take a just a few minutes to finish.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is one of the most complex apps that we have in the repo. Can you please add a suggested minimum hardware requirement for this suite of apps?

Also, maybe add a note saying that "this one click app deploys 16 distinct apps and it requires ....."


**Note**: This One Click App deploys a **total of 16 different apps** and it requires at least 8GB of RAM with a a Quad-Core CPU.
end: >
Posthog is deployed and available as $$cap_appname-web. Migrations from Clickhouse and Postgres have now started.

IMPORTANT: It will take up to 5-8 minutes for PostHog to be ready. Before that, you might see a 502 error page. Check the logs under the Deployment tab.
displayName: PostHog
isOfficial: false
description: 🦔 PostHog provides open-source product analytics, session recording, feature flagging and A/B testing that you can self-host.
documentation: https://posthog.com/docs
Binary file added public/v4/logos/posthog.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading