PostHog / posthog

🦔 PostHog provides open-source product analytics, session recording, feature flagging and A/B testing that you can self-host.
https://posthog.com
Other
20.61k stars 1.23k forks source link

Deploying self hosted version from script broken docker compose #21586

Open sohaib94 opened 4 months ago

sohaib94 commented 4 months ago

Bug description

When you use the curl command https://posthog.com/docs/self-host to deploy on a Ubuntu machine, you get the following error:

service "temporal" depends on undefined service elasticsearch: invalid compose project

This seems to be caused by the temporal service depending on the existence of elasticsearch in the docker-compose.base.yml file - removing that dependency and running again fixes the issue.

How to reproduce

  1. SSH into a Ubuntu machine
  2. Run /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/posthog/posthog/HEAD/bin/deploy-hobby)"
  3. See error

Additional context

Debug info

- [ ] PostHog Cloud, Debug information: [please copy/paste from https://us.posthog.com/settings/project-details#variables]
- [x] PostHog Hobby self-hosted with `docker compose`, version/commit: latest/7276e4d
- [ ] PostHog self-hosted with Kubernetes (deprecated, see [`Sunsetting Kubernetes support`](https://posthog.com/blog/sunsetting-helm-support-posthog)), version/commit: [please provide]
fnvon commented 4 months ago

Got the same error here when trying to update my instance on ubuntu, using the update command:

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/posthog/posthog/HEAD/bin/upgrade-hobby)"

JasonCrank commented 4 months ago

Same over here, makes updating and installing impossible.

It seems the elasticsearch is missing from the docker-compose.hobby.yml file.

aravind-opsverse commented 4 months ago

Hey folks, Do we have any fixes for this issue? We're seeing the same issue as well.

sohaib94 commented 4 months ago

Hey folks, Do we have any fixes for this issue? We're seeing the same issue as well.

If you have the docker-compose.base.yml file you can directly remove the .services.temporal.depends_on.elasticsearch section and it should come up.

For me, I copied the deploy-hobby script and added a line using yq to remove that block between the echo "Starting the stack!" line and the sudo -E docker-compose -f docker-compose.yml up -d line like so:

echo "Starting the stack!"
yq -i 'del(.services.temporal.depends_on.elasticsearch)' docker-compose.base.yml
sudo -E docker-compose -f docker-compose.yml up -d

(That said my deployment still isn't working - getting a You are using the default SECRET_KEY in a production environment in the temporal-django-worker and an IS_BEHIND_PROXY error in the web one though I think these are separate issues)

For a proper fix, I think the elasticsearch dependency needs to be removed from the docker-compose.base.yml and put in the other docker compose files which require elasticsearch.

Would be happy to do this myself if one of the owners can accept the issue - would be good to finally contribute to an OSS project :D

muncherelli commented 4 months ago

same issue here when installing:

service "temporal" depends on undefined service elasticsearch: invalid compose project

makes it difficult to convince the company I work for to use this product when a developer can't install it

kerlexov commented 4 months ago

same here service "temporal" depends on undefined service "elasticsearch": invalid │ compose project

thinking about changing install script to use different git repository tag but need to find out when this started to occur

marcelgoya commented 4 months ago

same here, would appreciate if this gets fixed soon unless somebody wants to promote their cloud offering .....

UPDATE:

I got it working by using the following version of the docker-compose.base.yml file:

https://github.com/PostHog/posthog/blob/c8545b96929fff173026cb70232da4868dfc002c/docker-compose.base.yml

I also had to remove https support from the caddy config file

viktor-yunenko commented 4 months ago

One workaround for the non-working docker-compose.yml:

  1. Add the missing elasticsearch to docker-compose.yml
  2. Override the upgrade-hobby script to force it to keep your fixed docker-compose.yml instead of pulling the broken version from git master (see the snippet below)
  3. Run the patched upgrade-hobby script.
  4. Stop temporal-django-worker service, as it won't start until the envs loading is fixed.

Details

I couldn't get temporal-django-worker to work, as others said, it doesn't inherit any of the envs. Though it's also not critical - as far as I see the main consequence is the Insights now require a manual press on the "Refresh" button, as it stops auto-refreshing by itself. Some other async routines aren't going to work either, I imagine.

But other services load the env vars correctly and run ok.

viktor-yunenko commented 4 months ago

Forgot to mention the manual fixes required for the non-working docker-compose.hobby.yml. Updated the previous comment.