|
1 | 1 | # Self Hosting [Plausible](https://plausible.io/docs/self-hosting) on [Fly.io](https://fly.io/) |
2 | 2 |
|
3 | 3 | This repo is based on the [docker-compose version](https://github.com/plausible/hosting) published by Plausible |
| 4 | + |
| 5 | +## Overview |
| 6 | + |
| 7 | +There are 4-5 Services that are required to run plausible: The plausible service itself, a postgres DB, a Clickhouse Server, an SMTP Service, and an (optional) geolocation database. The self-hosting guide and the associated repository are a great place to start, but they only provide a docker-compose file and kubernetes examples. To run on fly.io, I'd like to deploy each service separately. |
| 8 | + |
| 9 | +## Postgres |
| 10 | + |
| 11 | +Refer to the [Fly.io documenation](https://fly.io/docs/reference/postgres/) for complete instructions. |
| 12 | + |
| 13 | +``` |
| 14 | +flyctl postgres create |
| 15 | +? App Name: plausible-db |
| 16 | +? Select organization: <YOUR ORGANIZATION> |
| 17 | +? Select region: ewr (Secaucus, NJ (US)) |
| 18 | +? Select configuration: Development - Single node, 1x shared CPU, 256MB RAM, 1GB disk |
| 19 | +``` |
| 20 | + |
| 21 | +Save the credentials somewhere safe |
| 22 | + |
| 23 | +## Clickhouse |
| 24 | + |
| 25 | +(from the clickhouse directory) |
| 26 | + |
| 27 | +``` |
| 28 | +flyctl volumes create plausible_clickhouse_data --region ewr --size 1 |
| 29 | +flyctl deploy |
| 30 | +``` |
| 31 | + |
| 32 | +## Plausible |
| 33 | + |
| 34 | +(from the plausible directory) |
| 35 | + |
| 36 | +``` |
| 37 | +flyctl postgres attach --postgres-app plausible-db |
| 38 | +
|
| 39 | +openssl rand -base64 64 | tr -d '\n' ; echo |
| 40 | +
|
| 41 | +flyctl secrets set SECRET_KEY_BASE=<FROM ABOVE> |
| 42 | +
|
| 43 | +<SET ADDITIONAL CONFIGURATION (See Below)> |
| 44 | +
|
| 45 | +flyctl deploy |
| 46 | +``` |
| 47 | + |
| 48 | +The default VM was running out of memory: |
| 49 | + |
| 50 | +``` |
| 51 | +fly scale memory 1024 |
| 52 | +``` |
| 53 | + |
| 54 | +``` |
| 55 | +fly ssh console |
| 56 | +
|
| 57 | +entrypoint.sh db init-admin |
| 58 | +``` |
| 59 | + |
| 60 | +### [DNS Entries / SSL](https://fly.io/docs/app-guides/custom-domains-with-fly/) |
| 61 | +A Record |
| 62 | +AAAA Record |
| 63 | + |
| 64 | +``` |
| 65 | +flyctl certs create <BASE_URL> |
| 66 | +``` |
| 67 | + |
| 68 | +### Secrets & Configuration |
| 69 | + |
| 70 | +Please refer the [configuration documentation](https://plausible.io/docs/self-hosting-configuration#mailersmtp-setup) |
| 71 | + |
| 72 | +These are the configurations we used: |
| 73 | + |
| 74 | +``` |
| 75 | +ADMIN_USER_NAME |
| 76 | +ADMIN_USER_EMAIL |
| 77 | +ADMIN_USER_PWD |
| 78 | +
|
| 79 | +BASE_URL |
| 80 | +SECRET_KEY_BASE |
| 81 | +DISABLE_REGISTRATION=true |
| 82 | +
|
| 83 | +MAILER_ADAPTER=Bamboo.PostmarkAdapter |
| 84 | +POSTMARK_API_KEY |
| 85 | +MAILER_EMAIL |
| 86 | +
|
| 87 | +GOOGLE_CLIENT_ID |
| 88 | +GOOGLE_CLIENT_SECRET |
| 89 | +``` |
0 commit comments