Compare commits
3 Commits
Author | SHA1 | Date | |
---|---|---|---|
e32be4cef1 | |||
f9902dbce7 | |||
746c7d0e90 |
20
.github/workflows/spellcheck.yml
vendored
@ -1,20 +0,0 @@
|
|||||||
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
|
|
3
.gitignore
vendored
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
plausible-conf.env
|
||||||
|
.env
|
||||||
|
data/
|
@ -1 +0,0 @@
|
|||||||
*
|
|
21
LICENSE
@ -1,21 +0,0 @@
|
|||||||
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.
|
|
@ -3,13 +3,6 @@
|
|||||||
<level>warning</level>
|
<level>warning</level>
|
||||||
<console>true</console>
|
<console>true</console>
|
||||||
</logger>
|
</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 -->
|
<!-- Stop all the unnecessary logging -->
|
||||||
<query_thread_log remove="remove"/>
|
<query_thread_log remove="remove"/>
|
||||||
|
@ -1,20 +1,19 @@
|
|||||||
|
version: "3.3"
|
||||||
services:
|
services:
|
||||||
plausible_db:
|
plausible_db:
|
||||||
# Plausible v2.1.1 was tested against PostgreSQL versions 15 and 16
|
# supported versions are 12, 13, and 14
|
||||||
# https://github.com/plausible/analytics/blob/v2.1.1/.github/workflows/elixir.yml#L21-L32
|
image: postgres:14-alpine
|
||||||
image: postgres:16-alpine
|
|
||||||
restart: always
|
restart: always
|
||||||
volumes:
|
volumes:
|
||||||
- db-data:/var/lib/postgresql/data
|
- ./data/postgres:/var/lib/postgresql/data
|
||||||
environment:
|
environment:
|
||||||
- POSTGRES_PASSWORD=postgres
|
- POSTGRES_PASSWORD=postgres
|
||||||
|
|
||||||
plausible_events_db:
|
plausible_events_db:
|
||||||
image: clickhouse/clickhouse-server:24.3.3.102-alpine
|
image: clickhouse/clickhouse-server:23.3.7.5-alpine
|
||||||
restart: always
|
restart: always
|
||||||
volumes:
|
volumes:
|
||||||
- event-data:/var/lib/clickhouse
|
- ./data/clickhouse:/var/lib/clickhouse
|
||||||
- event-logs:/var/log/clickhouse-server
|
|
||||||
- ./clickhouse/clickhouse-config.xml:/etc/clickhouse-server/config.d/logging.xml:ro
|
- ./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
|
- ./clickhouse/clickhouse-user-config.xml:/etc/clickhouse-server/users.d/logging.xml:ro
|
||||||
ulimits:
|
ulimits:
|
||||||
@ -23,21 +22,13 @@ services:
|
|||||||
hard: 262144
|
hard: 262144
|
||||||
|
|
||||||
plausible:
|
plausible:
|
||||||
image: ghcr.io/plausible/community-edition:v2.1.1
|
image: plausible/analytics:v2.0
|
||||||
restart: always
|
restart: always
|
||||||
command: sh -c "sleep 10 && /entrypoint.sh db createdb && /entrypoint.sh db migrate && /entrypoint.sh run"
|
command: sh -c "sleep 10 && /entrypoint.sh db createdb && /entrypoint.sh db migrate && /entrypoint.sh run"
|
||||||
depends_on:
|
depends_on:
|
||||||
- plausible_db
|
- plausible_db
|
||||||
- plausible_events_db
|
- plausible_events_db
|
||||||
ports:
|
ports:
|
||||||
- 127.0.0.1:8000:8000
|
- 127.0.0.1:84:8000
|
||||||
env_file:
|
env_file:
|
||||||
- plausible-conf.env
|
- .env
|
||||||
|
|
||||||
volumes:
|
|
||||||
db-data:
|
|
||||||
driver: local
|
|
||||||
event-data:
|
|
||||||
driver: local
|
|
||||||
event-logs:
|
|
||||||
driver: local
|
|
||||||
|
Before Width: | Height: | Size: 491 KiB |
Before Width: | Height: | Size: 185 KiB |
Before Width: | Height: | Size: 209 KiB |
Before Width: | Height: | Size: 198 KiB |
Before Width: | Height: | Size: 191 KiB |
Before Width: | Height: | Size: 265 KiB |
Before Width: | Height: | Size: 227 KiB |
Before Width: | Height: | Size: 198 KiB |
Before Width: | Height: | Size: 206 KiB |
Before Width: | Height: | Size: 186 KiB |
Before Width: | Height: | Size: 205 KiB |
Before Width: | Height: | Size: 200 KiB |
Before Width: | Height: | Size: 217 KiB |
Before Width: | Height: | Size: 209 KiB |
Before Width: | Height: | Size: 190 KiB |
Before Width: | Height: | Size: 196 KiB |
Before Width: | Height: | Size: 249 KiB |
Before Width: | Height: | Size: 181 KiB |
Before Width: | Height: | Size: 186 KiB |
Before Width: | Height: | Size: 192 KiB |
Before Width: | Height: | Size: 230 KiB |
Before Width: | Height: | Size: 193 KiB |
Before Width: | Height: | Size: 207 KiB |
Before Width: | Height: | Size: 216 KiB |
Before Width: | Height: | Size: 184 KiB |
Before Width: | Height: | Size: 188 KiB |
Before Width: | Height: | Size: 187 KiB |
Before Width: | Height: | Size: 170 KiB |
Before Width: | Height: | Size: 142 KiB |
Before Width: | Height: | Size: 188 KiB |
Before Width: | Height: | Size: 166 KiB |
Before Width: | Height: | Size: 175 KiB |
Before Width: | Height: | Size: 194 KiB |
Before Width: | Height: | Size: 222 KiB |
Before Width: | Height: | Size: 193 KiB |
Before Width: | Height: | Size: 258 KiB |
Before Width: | Height: | Size: 226 KiB |
Before Width: | Height: | Size: 209 KiB |
Before Width: | Height: | Size: 239 KiB |
Before Width: | Height: | Size: 258 KiB |
Before Width: | Height: | Size: 223 KiB |
Before Width: | Height: | Size: 237 KiB |
Before Width: | Height: | Size: 23 KiB |
Before Width: | Height: | Size: 24 KiB |
@ -1,3 +0,0 @@
|
|||||||
BASE_URL=replace-me
|
|
||||||
SECRET_KEY_BASE=replace-me
|
|
||||||
TOTP_VAULT_KEY=replace-me
|
|
@ -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:
|
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
|
```shell
|
||||||
$ sudo a2enmod proxy proxy_http proxy_ajp remoteip headers proxy_wstunnel
|
$ sudo a2enmod proxy proxy_http proxy_ajp remoteip headers
|
||||||
$ sudo systemctl restart apache2
|
$ sudo systemctl restart apache2
|
||||||
$ sudo cp reverse-proxy/apache2/plausible.conf /etc/apache2/sites-available/
|
$ sudo cp reverse-proxy/apache2/plausible.conf /etc/apache2/sites-available/
|
||||||
$ sudo a2ensite plausible.conf
|
$ sudo a2ensite plausible.conf
|
||||||
$ sudo systemctl restart apache2
|
$ sudo systemctl restart apache2
|
||||||
$ sudo certbot --apache
|
$ sudo certbot --apache
|
||||||
```
|
```
|
@ -4,8 +4,6 @@
|
|||||||
ServerName example.com
|
ServerName example.com
|
||||||
|
|
||||||
ProxyPreserveHost On
|
ProxyPreserveHost On
|
||||||
ProxyAddHeaders On
|
|
||||||
ProxyPassMatch ^/(live/websocket)$ ws://localhost:8000/$1
|
|
||||||
ProxyPass / http://localhost:8000/
|
ProxyPass / http://localhost:8000/
|
||||||
ProxyPassReverse / http://localhost:8000/
|
ProxyPassReverse / http://localhost:8000/
|
||||||
|
|
||||||
|
@ -8,12 +8,5 @@ server {
|
|||||||
location / {
|
location / {
|
||||||
proxy_pass http://127.0.0.1:8000;
|
proxy_pass http://127.0.0.1:8000;
|
||||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
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";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,39 +6,57 @@ Guide to upgrading PostgreSQL version `>= 12` to version `14` using `pg_dump` an
|
|||||||
|
|
||||||
### Plan
|
### Plan
|
||||||
|
|
||||||
1. dump contents of the old version PostgreSQL to a file
|
1. dump contents of the old version PostgreSQL to a file in a mounted volume
|
||||||
1. copy the dump to the host
|
|
||||||
1. replace old version PostgreSQL with new version PostgreSQL
|
1. replace old version PostgreSQL with new version PostgreSQL
|
||||||
1. copy and load the dump into new version PostgreSQL
|
1. load dump from the mounted volume into new version PostgreSQL
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
### Steps
|
### Steps
|
||||||
|
|
||||||
1. Stop `plausible` to avoid writing to old `plausible_db`
|
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`
|
||||||
|
|
||||||
```console
|
```console
|
||||||
> docker compose stop plausible
|
> docker compose stop plausible plausible_db
|
||||||
[+] Running 2/2
|
[+] Running 2/2
|
||||||
⠿ Container hosting-plausible-1 Stopped 6.5s
|
⠿ Container hosting-plausible-1 Stopped 6.5s
|
||||||
|
⠿ Container hosting-plausible_db-1 Stopped 0.2s
|
||||||
```
|
```
|
||||||
|
|
||||||
2. Dump old `plausible_db` contents to a backup file
|
3. Restart `plausible_db` container to attach volume
|
||||||
|
|
||||||
```console
|
```console
|
||||||
> docker compose exec plausible_db sh -c "pg_dump -U postgres plausible_db > plausible_db.bak"
|
> docker compose up plausible_db -d
|
||||||
|
[+] Running 1/1
|
||||||
|
⠿ Container hosting-plausible_db-1 Started 0.3s
|
||||||
```
|
```
|
||||||
|
|
||||||
3. Copy the backup to the host
|
4. Dump old `plausible_db` contents to a backup file
|
||||||
|
|
||||||
```console
|
```console
|
||||||
> docker compose cp plausible_db:plausible_db.bak plausible_db.bak
|
> docker compose exec plausible_db sh -c "pg_dump -U postgres plausible_db > /backup/plausible_db.bak"
|
||||||
```
|
```
|
||||||
|
|
||||||
4. (Optional) verify backup went OK
|
5. (Optional) verify backup went OK
|
||||||
|
|
||||||
```console
|
```console
|
||||||
> head plausible_db.bak
|
> ls backup
|
||||||
|
plausible_db.bak
|
||||||
|
|
||||||
|
> head backup/plausible_db.bak
|
||||||
--
|
--
|
||||||
-- PostgreSQL database dump
|
-- PostgreSQL database dump
|
||||||
--
|
--
|
||||||
@ -51,7 +69,7 @@ SET lock_timeout = 0;
|
|||||||
SET idle_in_transaction_session_timeout = 0;
|
SET idle_in_transaction_session_timeout = 0;
|
||||||
```
|
```
|
||||||
|
|
||||||
5. Edit `docker-compose.yml` to use new PostgreSQL version, here we update from `v12` to `v14`, alpine flavour.
|
6. Edit `docker-compose.yml` to use new PostgreSQL version, here we update from `v12` to `v14`, alpine flavour.
|
||||||
|
|
||||||
```diff
|
```diff
|
||||||
plausible_db:
|
plausible_db:
|
||||||
@ -60,11 +78,12 @@ SET idle_in_transaction_session_timeout = 0;
|
|||||||
restart: always
|
restart: always
|
||||||
volumes:
|
volumes:
|
||||||
- db-data:/var/lib/postgresql/data
|
- db-data:/var/lib/postgresql/data
|
||||||
|
- ./backup:/backup
|
||||||
environment:
|
environment:
|
||||||
- POSTGRES_PASSWORD=postgres
|
- POSTGRES_PASSWORD=postgres
|
||||||
```
|
```
|
||||||
|
|
||||||
6. Ensure relevant containers are stopped
|
7. Ensure relevant containers are stopped
|
||||||
|
|
||||||
```console
|
```console
|
||||||
> docker compose stop plausible plausible_db
|
> docker compose stop plausible plausible_db
|
||||||
@ -73,7 +92,7 @@ SET idle_in_transaction_session_timeout = 0;
|
|||||||
⠿ Container hosting-plausible_db-1 Stopped 0.2s
|
⠿ Container hosting-plausible_db-1 Stopped 0.2s
|
||||||
```
|
```
|
||||||
|
|
||||||
7. Remove old `plausible_db` container to be able to nuke its volume in the next step
|
8. Remove old `plausible_db` container to be able to nuke its volume in the next step
|
||||||
|
|
||||||
```console
|
```console
|
||||||
> docker compose rm plausible_db
|
> docker compose rm plausible_db
|
||||||
@ -82,7 +101,7 @@ SET idle_in_transaction_session_timeout = 0;
|
|||||||
⠿ Container hosting-plausible_db-1 Removed 0.0s
|
⠿ Container hosting-plausible_db-1 Removed 0.0s
|
||||||
```
|
```
|
||||||
|
|
||||||
8. Remove old `plausible_db` volume, mine is named `hosting_db-data`
|
9. Remove old `plausible_db` volume, mine is named `hosting_db-data`
|
||||||
|
|
||||||
```console
|
```console
|
||||||
> docker volume ls
|
> docker volume ls
|
||||||
@ -96,7 +115,7 @@ local hosting_event-data
|
|||||||
hosting_db-data
|
hosting_db-data
|
||||||
```
|
```
|
||||||
|
|
||||||
9. Start new version `plausible_db` container
|
10. Start new version `plausible_db` container
|
||||||
|
|
||||||
```console
|
```console
|
||||||
> docker compose up plausible_db -d
|
> docker compose up plausible_db -d
|
||||||
@ -115,13 +134,12 @@ hosting_db-data
|
|||||||
⠿ Container hosting-plausible_db-1 Started 0.5s
|
⠿ Container hosting-plausible_db-1 Started 0.5s
|
||||||
```
|
```
|
||||||
|
|
||||||
10. Create new DB and load data into it
|
11. Create new DB and load data into it
|
||||||
|
|
||||||
```console
|
```console
|
||||||
> docker compose exec plausible_db createdb -U postgres plausible_db
|
> 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 < plausible_db.bak"
|
> docker compose exec plausible_db sh -c "psql -U postgres -d plausible_db < /backup/plausible_db.bak"
|
||||||
SET
|
SET
|
||||||
SET
|
SET
|
||||||
SET
|
SET
|
||||||
@ -140,7 +158,7 @@ CREATE EXTENSION
|
|||||||
<...snip...>
|
<...snip...>
|
||||||
```
|
```
|
||||||
|
|
||||||
11. Start all other containers
|
12. Start all other containers
|
||||||
|
|
||||||
```console
|
```console
|
||||||
> docker compose up -d
|
> docker compose up -d
|
||||||
@ -151,9 +169,19 @@ CREATE EXTENSION
|
|||||||
⠿ Container hosting-plausible-1 Started 0.5s
|
⠿ Container hosting-plausible-1 Started 0.5s
|
||||||
```
|
```
|
||||||
|
|
||||||
12. (Optional) Remove backups from the container and the host
|
13. (Optional) Remove backups from `docker-compose.yml` and your filesystem
|
||||||
|
|
||||||
```console
|
```diff
|
||||||
> rm plausible_db.bak
|
plausible_db:
|
||||||
> docker compose exec plausible_db rm plausible_db.bak
|
image: postgres:14-alpine
|
||||||
|
restart: always
|
||||||
|
volumes:
|
||||||
|
- db-data:/var/lib/postgresql/data
|
||||||
|
- - ./backup:/backup
|
||||||
|
environment:
|
||||||
|
- POSTGRES_PASSWORD=postgres
|
||||||
|
```
|
||||||
|
|
||||||
|
```
|
||||||
|
> rm -rf ./backup
|
||||||
```
|
```
|
||||||
|