Self-hosting is possible based on the docker images and are automatically pushed into [Dockerhub](https://hub.docker.com/r/plausible/analytics) registry for all commits on `master` branch. At the moment, `latest` is the only tag on DockerHub as we haven't reached a stable release of self-hosted Plausible yet.
### Architecture
Plausible runs as a single server, backed by two databases: PostgreSQL for user data and ClickhouseDB for the stats. When you
download and run the docker image you also need to provide connection details for these two databases.
Most hosting providers will offer a managed PostgreSQL instance, but it's not as simple with Clickhouse.
You can [install Clickhouse on a VPS](https://www.digitalocean.com/community/tutorials/how-to-install-and-use-clickhouse-on-ubuntu-18-04),
run it using their [official Docker image](https://hub.docker.com/r/yandex/clickhouse-server/), or use a managed service provided by
[Yandex Cloud](https://cloud.yandex.com/services/managed-clickhousec). [Aiven has announced](https://landing.aiven.io/2020-upcoming-aiven-services-webinar) that they are planning offer a managed ClickHouse service in the future and more hosting providers are following suit.
As of June 2020, here's the setup of the official cloud version of Plausible for reference:
* Web server: Digital Ocean Droplet w/ 1vCPU & 2GB RAM. Managed via the [official Docker app](https://marketplace.digitalocean.com/apps/docke://marketplace.digitalocean.com/apps/docker).
* User database: Digital Ocean Managed PostgreSQL w/ 1vCPU & 1GB RAM.
* Stats database: Digital Ocean Droplet w/ 6vCPU & 16GB RAM. Installed on Ubuntu 18.04 using the [official tutorial](https://www.digitalocean.com/community/tutorials/how-to-install-and-use-clickhouse-on-ubuntu-18-04)
the release will create the pre-packed artifact at `_build/prod/rel/plausible/bin/plausible`, the release will also create a tarball at `_build/prod/` for convenience.
On the initial setup, a migration step is necessary to create database and table schemas needed for initial bootup.
Normally, this done by mix aliases like `ecto.setup` defined in the `mix.exs`. As this not available in "released" artifact, [`plausible_migration.ex`](./lib/plausible_migration.ex) facilitates this process.
Following are the variables that can be used to configure the availability of the server.
- HOST (*String*)
- The hosting address of the server. For running on local system, this can be set to **localhost**. In production systems, this can be your ingress host.
- An internal secret key used by [Phoenix Framework](https://www.phoenixframework.org/). Follow the [instructions](https://hexdocs.pm/phoenix/Mix.Tasks.Phx.Gen.Secret.html#content) to generate one.
For self-hosting, a default user is generated during the [Database Migration](#Database Migration) to access Plausible. To be noted that, a default user is a user whose trial period expires in 100 Years ;).