39 Commits

Author SHA1 Message Date
d4324158d8 Create LICENSE 2024-12-04 19:19:32 +07:00
4e949e84f7 Revert "Add health check to docker compose (#141)"
This reverts commit 43e8842846.
2024-08-02 22:35:10 +07:00
9cd73d990c Revert "remove sleep from plausible.command"
This reverts commit 5930193510.
2024-08-02 22:35:05 +07:00
5930193510 remove sleep from plausible.command 2024-07-22 13:48:24 +07:00
bfcbf76cde run spellcheck on all pushes 2024-07-22 13:44:11 +07:00
26c2804763 add spellcheckers 2024-07-22 13:40:46 +07:00
250fabfa65 Update README.md (#144) 2024-07-21 00:48:45 +07:00
43e8842846 Add health check to docker compose (#141)
* Add healtcheck to docker compose

* Add start interval for faster startup
2024-07-16 16:06:01 +07:00
e023cf8874 Add ws proxy to apache2/plausible.conf
Websocket connections on apache2 were failing until it was routed correctly - caused tocket creation to fail.
2024-06-19 02:47:49 +07:00
92f2445fbe Disable IPv6 in Clickhouse config (#137) 2024-06-17 02:27:46 +07:00
8152c57c31 update comment 2024-06-06 20:26:23 +07:00
5632dbc22f v2.1.1 2024-06-06 20:23:00 +07:00
6dc3dfac65 update google guide 2024-06-04 18:23:27 +07:00
c5f3386338 Fix Nginx websocket config: proxy_pass is not inherited 2024-05-24 03:20:17 +07:00
7d18ea8f5a Fix Nginx websocket config 2024-05-24 03:03:30 +07:00
ffc883de7e use newer image version 2024-05-23 17:37:11 +07:00
2ecf128d2b update Mua link to v2.1.0 discussion 2024-05-23 17:35:32 +07:00
a0191a6924 more links 2024-05-18 11:42:52 +07:00
dab6263b34 v2.1.0 2024-05-11 10:21:10 +07:00
d6a61a500b Remove version tag from compose file 2024-05-11 10:17:08 +07:00
41b38bd384 flatten docs, no details 2024-05-10 18:43:12 +07:00
2703326e60 Merge pull request #113 from plausible/allow-nginx-ws
allow ws proxying in nginx
2024-04-26 01:53:24 +08:00
06f122fde5 Merge pull request #118 from plausible/ch-logs-volume
save CH logs into a named volume
2024-04-16 20:19:49 +08:00
3ea11aad26 save CH logs into a named volume 2024-04-16 00:35:54 +08:00
4ebc0f6631 Merge pull request #112 from plausible/doc-remove-localhost-only
add note about removing localhost-only binding
2024-03-25 17:48:01 +08:00
cf97d39241 allow ws proxying in nginx
Relevant:
- https://github.com/plausible/analytics/discussions/3826
- https://github.com/plausible/analytics/discussions/3817#discussioncomment-8615006
2024-03-25 15:58:51 +08:00
9c5b0c9be9 Merge pull request #110 from onzecki/patch-1
Add WebSocket Proxy mod
2024-03-25 11:42:13 +08:00
565906e9f5 add note about removing localhost-only binding 2024-03-25 11:38:18 +08:00
b6d9eac722 Add WebSocket Proxy mod 2024-03-23 16:26:43 +01:00
0a9c71320a explain PostgreSQL "supported versions" message 2024-02-26 22:04:11 +08:00
bdf1483526 we actually test against PostgreSQL 13, 14, and 15 2024-02-24 20:20:55 +08:00
518aa3a35a make Plausible listen on 127.0.0.1 by default 2024-02-24 01:50:30 +08:00
376369fd21 add ls after clone to verify right files were copied 2024-02-24 00:06:04 +08:00
6096b4e8b8 it's plausible/community-edition now 2024-02-24 00:04:21 +08:00
5377947618 Merge pull request #90 from plausible/new-docs
New docs
2024-02-23 14:04:04 +02:00
33a3413131 new docs 2024-02-23 20:00:42 +08:00
546f641ec1 drop TOTP_VAULT_KEY for v2.0.0 for now 2024-02-23 19:58:56 +08:00
hq1
1d4f9e93c5 Add TOTP_VAULT_KEY placeholder (#89) 2024-02-19 09:32:53 +01:00
bb6decee4d simplify upgrade-postgres guide 2023-10-12 20:35:53 +08:00
55 changed files with 1152 additions and 74 deletions

20
.github/workflows/spellcheck.yml vendored Normal file
View File

@ -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

1
.prettierignore Normal file
View File

@ -0,0 +1 @@
*

21
LICENSE Normal file
View File

@ -0,0 +1,21 @@
MIT License
Copyright (c) 2024 Plausible Analytics
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

1065
README.md

File diff suppressed because it is too large Load Diff

View File

@ -3,6 +3,13 @@
<level>warning</level>
<console>true</console>
</logger>
<!--
Avoid the warning: "Listen [::]:9009 failed: Address family for hostname not supported".
If Docker has IPv6 disabled, bind ClickHouse to IPv4 to prevent this issue.
Add this to the configuration to ensure it listens on all IPv4 interfaces:
<listen_host>0.0.0.0</listen_host>
-->
<!-- Stop all the unnecessary logging -->
<query_thread_log remove="remove"/>

View File

@ -1,12 +1,8 @@
version: "3.3"
services:
mail:
image: bytemark/smtp
restart: always
plausible_db:
# supported versions are 12, 13, and 14
image: postgres:14-alpine
# Plausible v2.1.1 was tested against PostgreSQL versions 15 and 16
# https://github.com/plausible/analytics/blob/v2.1.1/.github/workflows/elixir.yml#L21-L32
image: postgres:16-alpine
restart: always
volumes:
- db-data:/var/lib/postgresql/data
@ -14,10 +10,11 @@ services:
- POSTGRES_PASSWORD=postgres
plausible_events_db:
image: clickhouse/clickhouse-server:23.3.7.5-alpine
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:
@ -26,15 +23,14 @@ services:
hard: 262144
plausible:
image: plausible/analytics:v2.0
image: ghcr.io/plausible/community-edition:v2.1.1
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
- mail
ports:
- 8000:8000
- 127.0.0.1:8000:8000
env_file:
- plausible-conf.env
@ -43,3 +39,5 @@ volumes:
driver: local
event-data:
driver: local
event-logs:
driver: local

BIN
images/0-google-cloud.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 491 KiB

BIN
images/1-project-create.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 185 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 209 KiB

BIN
images/1-project-new.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 198 KiB

BIN
images/1-project-select.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 191 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 265 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 227 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 198 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 206 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 186 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 205 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 200 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 217 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 209 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 190 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 196 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 249 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 181 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 186 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 192 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 230 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 193 KiB

BIN
images/6-continue.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 207 KiB

BIN
images/6-data-continue.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 216 KiB

BIN
images/6-data-import.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 184 KiB

BIN
images/6-enabled-apis.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 188 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 187 KiB

BIN
images/6-import.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 170 KiB

BIN
images/6-pick-view.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 142 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 188 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 166 KiB

BIN
images/6-property.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 175 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 194 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 222 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 193 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 258 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 226 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 209 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 239 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 258 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 223 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 237 KiB

1
images/logo_dark.svg Normal file

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 23 KiB

1
images/logo_light.svg Normal file

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 24 KiB

View File

@ -1,2 +1,3 @@
BASE_URL=replace-me
SECRET_KEY_BASE=replace-me
TOTP_VAULT_KEY=replace-me

View File

@ -38,10 +38,10 @@ $ docker-compose -f docker-compose.yml -f reverse-proxy/traefik/docker-compose.t
Install the necessary Apache modules and restart Apache. Edit the file `reverse-proxy/apache2/plausible.conf` to contain the domain name you use for your server, then copy it into Apache's configuration folder. Enable it by creating a symlink in Apache's enabled sites folder with `a2ensite` command. Finally use Certbot to create a TLS certificate for your site:
```shell
$ sudo a2enmod proxy proxy_http proxy_ajp remoteip headers
$ sudo a2enmod proxy proxy_http proxy_ajp remoteip headers proxy_wstunnel
$ sudo systemctl restart apache2
$ sudo cp reverse-proxy/apache2/plausible.conf /etc/apache2/sites-available/
$ sudo a2ensite plausible.conf
$ sudo systemctl restart apache2
$ sudo certbot --apache
```
```

View File

@ -4,6 +4,8 @@
ServerName example.com
ProxyPreserveHost On
ProxyAddHeaders On
ProxyPassMatch ^/(live/websocket)$ ws://localhost:8000/$1
ProxyPass / http://localhost:8000/
ProxyPassReverse / http://localhost:8000/

View File

@ -8,5 +8,12 @@ server {
location / {
proxy_pass http://127.0.0.1:8000;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
location = /live/websocket {
proxy_pass http://127.0.0.1:8000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "Upgrade";
}
}
}

View File

@ -6,57 +6,39 @@ Guide to upgrading PostgreSQL version `>= 12` to version `14` using `pg_dump` an
### Plan
1. dump contents of the old version PostgreSQL to a file in a mounted volume
1. dump contents of the old version PostgreSQL to a file
1. copy the dump to the host
1. replace old version PostgreSQL with new version PostgreSQL
1. load dump from the mounted volume into new version PostgreSQL
1. copy and load the dump into new version PostgreSQL
---
### Steps
1. Add a backup volume to `plausible_db` in your `docker-compose.yml`
```diff
plausible_db:
image: postgres:12
restart: always
volumes:
- db-data:/var/lib/postgresql/data
+ - ./backup:/backup
environment:
- POSTGRES_PASSWORD=postgres
```
2. Stop relevant containers to avoid writing to old `plausible_db`
1. Stop `plausible` to avoid writing to old `plausible_db`
```console
> docker compose stop plausible plausible_db
> docker compose stop plausible
[+] Running 2/2
⠿ Container hosting-plausible-1 Stopped 6.5s
⠿ Container hosting-plausible_db-1 Stopped 0.2s
```
3. Restart `plausible_db` container to attach volume
2. Dump old `plausible_db` contents to a backup file
```console
> docker compose up plausible_db -d
[+] Running 1/1
⠿ Container hosting-plausible_db-1 Started 0.3s
> docker compose exec plausible_db sh -c "pg_dump -U postgres plausible_db > plausible_db.bak"
```
4. Dump old `plausible_db` contents to a backup file
3. Copy the backup to the host
```console
> docker compose exec plausible_db sh -c "pg_dump -U postgres plausible_db > /backup/plausible_db.bak"
> docker compose cp plausible_db:plausible_db.bak plausible_db.bak
```
5. (Optional) verify backup went OK
4. (Optional) verify backup went OK
```console
> ls backup
plausible_db.bak
> head backup/plausible_db.bak
> head plausible_db.bak
--
-- PostgreSQL database dump
--
@ -69,7 +51,7 @@ SET lock_timeout = 0;
SET idle_in_transaction_session_timeout = 0;
```
6. Edit `docker-compose.yml` to use new PostgreSQL version, here we update from `v12` to `v14`, alpine flavour.
5. Edit `docker-compose.yml` to use new PostgreSQL version, here we update from `v12` to `v14`, alpine flavour.
```diff
plausible_db:
@ -78,12 +60,11 @@ SET idle_in_transaction_session_timeout = 0;
restart: always
volumes:
- db-data:/var/lib/postgresql/data
- ./backup:/backup
environment:
- POSTGRES_PASSWORD=postgres
```
7. Ensure relevant containers are stopped
6. Ensure relevant containers are stopped
```console
> docker compose stop plausible plausible_db
@ -92,7 +73,7 @@ SET idle_in_transaction_session_timeout = 0;
⠿ Container hosting-plausible_db-1 Stopped 0.2s
```
8. Remove old `plausible_db` container to be able to nuke its volume in the next step
7. Remove old `plausible_db` container to be able to nuke its volume in the next step
```console
> docker compose rm plausible_db
@ -101,7 +82,7 @@ SET idle_in_transaction_session_timeout = 0;
⠿ Container hosting-plausible_db-1 Removed 0.0s
```
9. Remove old `plausible_db` volume, mine is named `hosting_db-data`
8. Remove old `plausible_db` volume, mine is named `hosting_db-data`
```console
> docker volume ls
@ -115,7 +96,7 @@ local hosting_event-data
hosting_db-data
```
10. Start new version `plausible_db` container
9. Start new version `plausible_db` container
```console
> docker compose up plausible_db -d
@ -134,12 +115,13 @@ hosting_db-data
⠿ Container hosting-plausible_db-1 Started 0.5s
```
11. Create new DB and load data into it
10. Create new DB and load data into it
```console
> docker compose exec plausible_db createdb -U postgres plausible_db
> docker compose cp plausible_db.bak plausible_db:plausible_db.bak
> docker compose exec plausible_db sh -c "psql -U postgres -d plausible_db < /backup/plausible_db.bak"
> docker compose exec plausible_db sh -c "psql -U postgres -d plausible_db < plausible_db.bak"
SET
SET
SET
@ -158,7 +140,7 @@ CREATE EXTENSION
<...snip...>
```
12. Start all other containers
11. Start all other containers
```console
> docker compose up -d
@ -169,19 +151,9 @@ CREATE EXTENSION
⠿ Container hosting-plausible-1 Started 0.5s
```
13. (Optional) Remove backups from `docker-compose.yml` and your filesystem
12. (Optional) Remove backups from the container and the host
```diff
plausible_db:
image: postgres:14-alpine
restart: always
volumes:
- db-data:/var/lib/postgresql/data
- - ./backup:/backup
environment:
- POSTGRES_PASSWORD=postgres
```
```
> rm -rf ./backup
```console
> rm plausible_db.bak
> docker compose exec plausible_db rm plausible_db.bak
```