Deploying to Google Cloud
Google Computing Services, also known as GCS or Google Cloud, is one of the most well-established Cloud Providers. GCS has a rather intuitive integrated dashboard, as well as an extensive Free Trial.
To deploy on Google Cloud, our suggested method is deploying with Docker, which we'll explain in detail on this page. If you would rather not use Docker, you can consider deploying from source, as well as other providers with one-click installs, like Heroku or AWS.
The first thing you'll need is a GCS Account. Once you have that up and running, you're good to go!
- Access your Console
- On the left-hand sidebar, head over to 'Compute' and hover over 'Compute Engine'. This should bring up a submenu where you can click 'VM Instances' at the top.
- On the 'VM Instances' page, click 'Create'
- Set up your desired configuration. We'll be using the 'Ubuntu 18.04' boot disk for this tutorial. The default on GCS is Debian, and you can change that by clicking 'Change' uder the 'Boot disk' section.
You will also want to allow HTTP and HTTPS Traffic. It is recommended to set security preferences and allowed IPs for these ports.
Finally, for the server specifications, we recommend a config with about the following specs for a medium volume instance: - 4GB of RAM - 2 CPUs - 50GB of storage
However, this will vary based on the volume you're expecting. If you're expecting a low volume, a lighter instance may do just fine. Conversely, if you are expecting high volume, you should probably scale up from the specs above.
- Click 'Create' at the bottom once you're done with the configuration steps
- Once your instance is live, that means you're ready to move on to the next tutorial.
On the page for your instance, you can choose how to access it. Clicking SSH will take you to a virtual terminal in your browser where you can interact with the virtual machine. However, you may want to SSH in from your own terminal. In this case, you need to follow this tutorial to provide you Public Key to the VM Instace.
- After accessing the instance, install Docker Engine
- Then install Docker Compose
- Setup Docker to run without root priviledges (optional but strongly recommended)
You should already have
gitinstalled. In that case, skip this step. Otherwise, install
sudo apt-get update && sudo apt-get install git
To clone the PostHog repository and enter the new directory, run:
git clone https://github.com/posthog/posthog.git && cd posthog
Then, to run PostHog, do:
docker-compose up -d
- You're good to go! PostHog should be accessible on the domain you set up or the IP of your instance.
- (Optional) Consider using something like Supervisor to monitor the process
PostHog needs to run on HTTPS because:
a) It will fail
b) It is a grave security concern and potentially illegal
If you are unable to connect to a certain port, this might be due to the firewall or security group settings for your VM Instance.
Generally, this is a matter of running:
sudo ufw allow <PORT> && sudo ufw reload
To check that the changes were applied, run:
sudo ufw status
You can read this tutorial for more information.
Here's a good GCS Tutorial about this.
See this PostHog tutorial about upgrading your PostHog version with Docker.