From 88de58e80e61f396e2ac1d7ea08351d319cc00b6 Mon Sep 17 00:00:00 2001 From: ruslandoga <67764432+ruslandoga@users.noreply.github.com> Date: Wed, 4 Sep 2024 14:54:50 +0700 Subject: [PATCH] v2.1.2 --- ...f-hosting-issues-is-the-community-forum.md | 10 +++ .github/workflows/spellcheck.yml | 20 +++++ .prettierignore | 1 + README.md | 90 +++++++++++++++++++ clickhouse/clickhouse-config.xml | 23 +++++ clickhouse/clickhouse-user-config.xml | 8 ++ compose.yml | 48 ++++++++++ 7 files changed, 200 insertions(+) create mode 100644 .github/ISSUE_TEMPLATE/best-place-for-self-hosting-issues-is-the-community-forum.md create mode 100644 .github/workflows/spellcheck.yml create mode 100644 .prettierignore create mode 100644 README.md create mode 100644 clickhouse/clickhouse-config.xml create mode 100644 clickhouse/clickhouse-user-config.xml create mode 100644 compose.yml diff --git a/.github/ISSUE_TEMPLATE/best-place-for-self-hosting-issues-is-the-community-forum.md b/.github/ISSUE_TEMPLATE/best-place-for-self-hosting-issues-is-the-community-forum.md new file mode 100644 index 0000000..3376c47 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/best-place-for-self-hosting-issues-is-the-community-forum.md @@ -0,0 +1,10 @@ +--- +name: Best place for self-hosting issues is the community forum +about: Please do not submit issues here +title: '' +labels: '' +assignees: '' + +--- + +Please do not submit issues here. Best place for self-hosting issues, questions and ideas is [the community forum here on GitHub](https://github.com/plausible/analytics/discussions/categories/self-hosted-support). Thanks! diff --git a/.github/workflows/spellcheck.yml b/.github/workflows/spellcheck.yml new file mode 100644 index 0000000..1f46d95 --- /dev/null +++ b/.github/workflows/spellcheck.yml @@ -0,0 +1,20 @@ +name: spellcheck + +on: + pull_request: + push: + +jobs: + codespell: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: codespell-project/actions-codespell@v2 + with: + check_filenames: true + + typos: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: crate-ci/typos@master diff --git a/.prettierignore b/.prettierignore new file mode 100644 index 0000000..72e8ffc --- /dev/null +++ b/.prettierignore @@ -0,0 +1 @@ +* diff --git a/README.md b/README.md new file mode 100644 index 0000000..4cf21bb --- /dev/null +++ b/README.md @@ -0,0 +1,90 @@ +

+ + + + + +

+ +

+ A getting started guide to self-hosting Plausible Community Edition +

+ +**Contact**: + +- For release announcements please go to [GitHub releases.](https://github.com/plausible/analytics/releases) +- For a question or advice please go to [GitHub discussions.](https://github.com/plausible/analytics/discussions/categories/self-hosted-support) + +--- + +## Install + +[Plausible Community Edition (or CE for short)](https://plausible.io/blog/community-edition) is designed to be self-hosted through [Docker.](https://docs.docker.com/guides/get-started/) You don't have to be a Docker expert to launch your own instance, but you should have a basic understanding of the command-line and networking to successfully set it up. + +```console +$ curl get-docker.sh +``` + +### Requirements + +The only thing you need to install Plausible CE is a server with Docker. The server must have a CPU with x86_64 or arm64 architecture and support for SSE 4.2 or equivalent NEON instructions. We recommend using a minimum of 4GB of RAM but the requirements will depend on your site traffic. + +We've tested this on [Digital Ocean](https://m.do.co/c/91569eca0213) (affiliate link) but any hosting provider works. If your server doesn't come with Docker pre-installed, you can follow [their docs](https://docs.docker.com/get-docker/) to install it. + +To make your Plausible CE instance accessible on a (sub)domain, you also need to be able to edit your DNS. Plausible CE isn't currently designed for subfolder installations. + +### Quick start + +To get started quickly, clone the [plausible/community-edition](https://github.com/plausible/community-edition) repo. It has everything you need to boot up your own Plausible CE server. + +console +```console +$ git clone -b v2.1.2 --single-branch https://github.com/plausible/community-edition plausible-ce +Cloning into 'community-edition'... +remote: Enumerating objects: 280, done. +remote: Counting objects: 100% (146/146), done. +remote: Compressing objects: 100% (74/74), done. +remote: Total 280 (delta 106), reused 86 (delta 71), pack-reused 134 +Receiving objects: 100% (280/280), 69.44 KiB | 7.71 MiB/s, done. +Resolving deltas: 100% (136/136), done. +$ ls -1 plausible-ce +README.md +clickhouse/ +compose.yml +``` + +This most important file is [compose.yml.](./compose.yml) It installs and orchestrates networking between your Plausible CE server, Postgres database, and Clickhouse database for stats. + +Right now there are some environment variables missing: + +compose.yml +```yaml +BASE_URL: ${BASE_URL} +SECRET_KEY_BASE: ${SECRET_KEY_BASE} +``` + +Let's do as it asks and populate these required environment variables with our own values. + +#### Required configuration + +First we generate the [secret key base](#secret_key_base) using OpenSSL: + +console +```console +$ openssl rand -base64 48 +GLVzDZW04FzuS1gMcmBRVhwgd4Gu9YmSl/k/TqfTUXti7FLBd7aflXeQDdwCj6Cz +``` + +And then we decide on the [base URL](#base_url) where the instance would be accessible: + +plausible-conf.env +```diff +- BASE_URL=replace-me ++ BASE_URL=https://plausible.example.com +- SECRET_KEY_BASE=replace-me ++ SECRET_KEY_BASE=GLVzDZW04FzuS1gMcmBRVhwgd4Gu9YmSl/k/TqfTUXti7FLBd7aflXeQDdwCj6Cz + HTTP_PORT=8000 + HTTPS_PORT=8001 +``` + +We can start our instance now. diff --git a/clickhouse/clickhouse-config.xml b/clickhouse/clickhouse-config.xml new file mode 100644 index 0000000..0dfaa70 --- /dev/null +++ b/clickhouse/clickhouse-config.xml @@ -0,0 +1,23 @@ + + + warning + true + + + + + + + + + + + + + + diff --git a/clickhouse/clickhouse-user-config.xml b/clickhouse/clickhouse-user-config.xml new file mode 100644 index 0000000..56cf1cd --- /dev/null +++ b/clickhouse/clickhouse-user-config.xml @@ -0,0 +1,8 @@ + + + + 0 + 0 + + + diff --git a/compose.yml b/compose.yml new file mode 100644 index 0000000..995824d --- /dev/null +++ b/compose.yml @@ -0,0 +1,48 @@ +services: + plausible_db: + image: postgres:16-alpine + restart: always + volumes: + - db-data:/var/lib/postgresql/data + environment: + - POSTGRES_PASSWORD=postgres + + plausible_events_db: + image: clickhouse/clickhouse-server:24.3.3.102-alpine + restart: always + volumes: + - event-data:/var/lib/clickhouse + - event-logs:/var/log/clickhouse-server + - ./clickhouse/clickhouse-config.xml:/etc/clickhouse-server/config.d/logging.xml:ro + - ./clickhouse/clickhouse-user-config.xml:/etc/clickhouse-server/users.d/logging.xml:ro + ulimits: + nofile: + soft: 262144 + hard: 262144 + + plausible: + image: ghcr.io/plausible/community-edition:v2.1.2 + restart: always + command: sh -c "sleep 10 && /entrypoint.sh db createdb && /entrypoint.sh db migrate && /entrypoint.sh run" + depends_on: + - plausible_db + - plausible_events_db + ports: + - 8000:8000 + - 8001:8001 + volumes: + - plausible-data:/var/lib/plausible + environment: + BASE_URL: ${BASE_URL} + SECRET_KEY_BASE: ${SECRET_KEY_BASE} + HTTP_PORT: 8000 + HTTPS_PORT: 8001 + DATABASE_URL: postgres://postgres:postgres@plausible_db:5432/plausible_db + CLICKHOUSE_DATABASE_URL: http://plausible_events_db:8123/plausible_events_db + DISABLE_REGISTRATION: true + +volumes: + db-data: + event-data: + event-logs: + plausible-data: