Skip to content

colinwilson/terraform-docker-plausible

Repository files navigation

Terraform Docker Plausible Module

A Terraform module to provision the self-hosted version of Plausible Analytics on a Docker Swarm cluster with the Traefik ingress controller. A great way to quickly deploy Plausible for development/testing or 'low traffic' sites.

Plausible Analytics Dashboard

Compatibility/Requirements

Usage

Basic usage of this module is as follows:

module "plausible_docker" {
  source = "github.com/colinwilson/terraform-docker-plausible"

  hostname           = "plausible.example.com"
  base_url           = "https://plausible.example.com"
  networks           = ["traefik"] # name of your Traefik Network
}

Example output:

connected_networks = [
  "traefik",
]
options_status = {
  "external_pg_enabled" = false
  "maxmind_enabled" = false
  "smtp_enabled" = false
}

Setup DNS records pointing your domain to your ingress and navigate to your hostname e.g. https://plausible.example.com

You'll be presented with a registration page to create the admin/owner account.

Plausible Analytics Registration Page

Inputs

Name Description Type Default Required
base_url Plausible base URL string "http://localhost" no
clickhouse_container_name ClickHouse Container name. string "plausible_event_db" no
clickhouse_db_name ClickHouse Database name. string "plausible" no
clickhouse_version ClickHouse image version. string "22.6-alpine" no
disable_registration Disables registration of new users. Valid options are true, false & invite_only string "invite_only" no
ext_postgres_creds Postgres database credentials.
object({
enabled = optional(bool, false)
config = optional(object({
username = optional(string)
password = optional(string)
host = optional(string)
port = optional(number, 5432)
db_name = optional(string)
ssl = optional(bool, false)
}), {})
})
{} no
geoip_creds MaxMind credentials.
object({
acc = string
key = string
})
{
"acc": null,
"key": null
}
no
geoip_db Set which MaxMind Database Plausible will utilise? string "GeoLite2-City" no
geoip_version MaxMind GeoIP Update Tool image version. string "v5.1.1" no
google_api_creds Google API Console credentials.
object({
id = string
secret = string
})
{
"id": null,
"secret": null
}
no
hcaptcha_creds hCaptcha credentials.
object({
sitekey = string
secret = string
})
{
"secret": null,
"sitekey": null
}
no
hostname Plausible hostname string "localhost" no
log_level Log level string "warn" no
networks Set of existing networks to connect Plausible to. set(string) [] no
plausible_version Plausible Analytics image version. string "v2.0.0" no
postgres_container_name Postgres container name string "plausible_db" no
postgres_version PostgreSQL image version. string "14-alpine" no
reduce_event_logging Reduce the level of query logging in ClickHouse? bool true no
smtp_creds SMTP Credentials
object({
mailname = string
host = string
port = number
username = string
password = string
})
{
"host": null,
"mailname": null,
"password": null,
"port": null,
"username": null
}
no

Outputs

Name Description
connected_networks List of existing networks the Plausible service is connected to.
options_status Brief summary of which options are enabled?