Skip to content

fix(service): posthog template#8739

Open
n0 wants to merge 3 commits intocoollabsio:nextfrom
n0:fix/posthog-template
Open

fix(service): posthog template#8739
n0 wants to merge 3 commits intocoollabsio:nextfrom
n0:fix/posthog-template

Conversation

@n0
Copy link

@n0 n0 commented Mar 2, 2026

Changes

Rewrote PostHog template. It has been disabled since September 2025 #6677 (⁶🤷‍♂️⁷ just had to) because of broken ClickHouse configs and missing env vars.

What changed:

  • ClickHouse configs are now inline via content: mounts instead of downloading from GitHub at runtime
  • Added the missing hobby deployment services (temporal, livestream, feature-flags, capture, replay-capture, cymbal, etc)
  • Added a geoip-init container that downloads the MaxMind DB from PostHog so cymbal/feature-flags don't crash
  • Caddy config routes capture/replay/livestream/flags to the right backend services
  • Fixed missing env vars (TEMPORAL_HOST, CLICKHOUSE_API/APP users, etc)

Issues

Category

  • Fixing or updating existing one click service

AI Usage

  • AI is NOT used in the process of creating this PR

Steps to Test

  • Step 1 - create a new service, paste the yaml from templates/compose/posthog.yaml
  • Step 2 - deploy, wait a few minutes for initial migrations to finish
  • Step 3 - hit the service url, should redirect to /preflight setup page

Contributor Agreement

Important

  • I have read and understood the contributor guidelines. If I have failed to follow any guideline, I understand that this PR may be closed without review.
  • I have tested the changes thoroughly and am confident that they will work as expected without issues when the maintainer tests them

Comment on lines +1687 to +1751
proxy:
image: caddy:2-alpine
command: caddy run -c /etc/caddy/Caddyfile
restart: always
environment:
- SERVICE_URL_PROXY_8000
depends_on:
- web
- capture
- livestream
volumes:
- type: bind
source: ./caddy/Caddyfile
target: /etc/caddy/Caddyfile
content: |
:8000 {
@replay-capture {
path /s /s/ /s/*
}
@capture {
path /e /e/ /e/*
path /i/v0 /i/v0/ /i/v0/*
path /batch /batch/ /batch/*
path /capture /capture/ /capture/*
}
@livestream {
path /livestream /livestream/ /livestream/*
}
@flags {
path /flags /flags/ /flags/*
}
@webhooks {
path /public/webhooks /public/webhooks/ /public/webhooks/*
path /public/m/ /public/m/*
}
@objectstorage {
path /posthog /posthog/ /posthog/*
}
handle @livestream {
uri strip_prefix /livestream
reverse_proxy livestream:8080 {
flush_interval -1
}
}
handle @replay-capture {
reverse_proxy replay-capture:3000
}
handle @capture {
reverse_proxy capture:3000
}
handle @flags {
reverse_proxy feature-flags:3001
}
handle @webhooks {
reverse_proxy plugins:6738
}
handle @objectstorage {
reverse_proxy objectstorage:19000
}
handle {
reverse_proxy web:8000
}
}
- posthog-caddy-data:/data
- posthog-caddy-config:/config
Copy link
Member

Choose a reason for hiding this comment

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

Coolify already provides a proxy. Is it not possible to configure this in the Coolify proxy?
This can just be a bit confusing for people to handle / deal with two chained proxies.

Copy link
Author

@n0 n0 Mar 5, 2026

Choose a reason for hiding this comment

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

PostHog's architecture requires path-based routing from a single public URL to multiple internal services running on different ports.

Happy to explore Traefik labels if you'd prefer

Copy link
Member

Choose a reason for hiding this comment

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

if it's possible that would be great. Caddy labels would also be needed, for people that use caddy.

Copy link
Author

Choose a reason for hiding this comment

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

if it's possible that would be great. Caddy labels would also be needed, for people that use caddy.

The internal Caddy is there because PostHog needs path-based routing from one URL to multiple backend services, and some of it doesn't map cleanly to Coolify's proxy labels:

  • capture needs 4 different path prefixes (/e, /i/v0, /batch, /capture) routed to the same service — labels only support one path per service
  • livestream needs flush_interval -1 for SSE streaming, which isn't expressible via Traefik/Caddy labels
  • some routes need strip_prefix, others don't & labels apply it uniformly per service

I can switch to labels using the Appwrite pattern (SERVICE_URL_POSTHOG=/path on each service), but we'd lose the extra capture paths (they'd fall back to the Django web service instead of the optimized capture service) and the streaming config for livestream. Both are fine for hobby-scale deployments tbh, just technically worse

Happy to go either way, let me know what you'd prefer

@Cinzya Cinzya added the 💤 Waiting for feedback Issues awaiting a response from the author. label Mar 4, 2026
@n0 n0 force-pushed the fix/posthog-template branch from 632523f to c879456 Compare March 6, 2026 00:37
Copy link
Author

@n0 n0 left a comment

Choose a reason for hiding this comment

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

fix config mount path, remove restart policies, add proxy port and env fallbacks

@m1guer
Copy link

m1guer commented Mar 6, 2026

preview of when it will get merged?

@bkempinski
Copy link

When we can expect this to be merged and fixed? Thank you

@Cinzya Cinzya added 💤 Waiting for changes PRs awaiting changes from the author. and removed 💤 Waiting for feedback Issues awaiting a response from the author. labels Mar 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

quality/verified 💤 Waiting for changes PRs awaiting changes from the author.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants