Compare commits
28 Commits
Author | SHA1 | Date | |
---|---|---|---|
f0416c49e7 | |||
6dc3dfac65 | |||
c5f3386338 | |||
7d18ea8f5a | |||
ffc883de7e | |||
2ecf128d2b | |||
a0191a6924 | |||
dab6263b34 | |||
d6a61a500b | |||
41b38bd384 | |||
2703326e60 | |||
06f122fde5 | |||
3ea11aad26 | |||
4ebc0f6631 | |||
cf97d39241 | |||
9c5b0c9be9 | |||
565906e9f5 | |||
b6d9eac722 | |||
0a9c71320a | |||
bdf1483526 | |||
518aa3a35a | |||
376369fd21 | |||
6096b4e8b8 | |||
5377947618 | |||
33a3413131 | |||
546f641ec1 | |||
1d4f9e93c5 | |||
bb6decee4d |
1
.prettierignore
Normal file
@ -0,0 +1 @@
|
||||
*
|
21
LICENSE
Normal 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.
|
@ -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.0 was tested against PostgreSQL versions 15 and 16
|
||||
# https://github.com/plausible/analytics/blob/v2.1.0/.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.0
|
||||
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
After Width: | Height: | Size: 491 KiB |
BIN
images/1-project-create.png
Normal file
After Width: | Height: | Size: 185 KiB |
BIN
images/1-project-created.png
Normal file
After Width: | Height: | Size: 209 KiB |
BIN
images/1-project-new.png
Normal file
After Width: | Height: | Size: 198 KiB |
BIN
images/1-project-select.png
Normal file
After Width: | Height: | Size: 191 KiB |
BIN
images/2-app-registration-api-and-services-pick.png
Normal file
After Width: | Height: | Size: 265 KiB |
BIN
images/2-app-registration-consent-screen-0.png
Normal file
After Width: | Height: | Size: 227 KiB |
BIN
images/2-app-registration-consent-screen-1.png
Normal file
After Width: | Height: | Size: 198 KiB |
BIN
images/2-app-registration-external.png
Normal file
After Width: | Height: | Size: 206 KiB |
BIN
images/2-app-registration-pick.png
Normal file
After Width: | Height: | Size: 186 KiB |
BIN
images/2-app-registration-scopes-skip.png
Normal file
After Width: | Height: | Size: 205 KiB |
BIN
images/2-app-registration-test-users.png
Normal file
After Width: | Height: | Size: 200 KiB |
BIN
images/3-oauth-client-create.png
Normal file
After Width: | Height: | Size: 217 KiB |
BIN
images/3-oauth-client-created.png
Normal file
After Width: | Height: | Size: 209 KiB |
BIN
images/3-oauth-client-credentials-pick.png
Normal file
After Width: | Height: | Size: 190 KiB |
BIN
images/3-oauth-client-pick.png
Normal file
After Width: | Height: | Size: 196 KiB |
BIN
images/4-search-console-new.png
Normal file
After Width: | Height: | Size: 249 KiB |
BIN
images/4-search-console-verified.png
Normal file
After Width: | Height: | Size: 181 KiB |
BIN
images/4-search-console-verify.png
Normal file
After Width: | Height: | Size: 186 KiB |
BIN
images/5-search-console-api-enable.png
Normal file
After Width: | Height: | Size: 192 KiB |
BIN
images/5-search-console-api-search.png
Normal file
After Width: | Height: | Size: 230 KiB |
BIN
images/6-choose-google-account.png
Normal file
After Width: | Height: | Size: 193 KiB |
BIN
images/6-continue.png
Normal file
After Width: | Height: | Size: 207 KiB |
BIN
images/6-data-continue.png
Normal file
After Width: | Height: | Size: 216 KiB |
BIN
images/6-data-import.png
Normal file
After Width: | Height: | Size: 184 KiB |
BIN
images/6-enabled-apis.png
Normal file
After Width: | Height: | Size: 188 KiB |
BIN
images/6-import-continue.png
Normal file
After Width: | Height: | Size: 187 KiB |
BIN
images/6-import.png
Normal file
After Width: | Height: | Size: 170 KiB |
BIN
images/6-pick-view.png
Normal file
After Width: | Height: | Size: 142 KiB |
BIN
images/6-plausible-settings-pick.png
Normal file
After Width: | Height: | Size: 188 KiB |
BIN
images/6-plausible-settings-search-console.png
Normal file
After Width: | Height: | Size: 166 KiB |
BIN
images/6-property.png
Normal file
After Width: | Height: | Size: 175 KiB |
BIN
images/6-sign-in-copycat.png
Normal file
After Width: | Height: | Size: 194 KiB |
BIN
images/6-view-search-console-data.png
Normal file
After Width: | Height: | Size: 222 KiB |
BIN
images/7-analytics-admin-api-enable.png
Normal file
After Width: | Height: | Size: 193 KiB |
BIN
images/7-analytics-admin-api-search.png
Normal file
After Width: | Height: | Size: 258 KiB |
BIN
images/7-analytics-api-enable.png
Normal file
After Width: | Height: | Size: 226 KiB |
BIN
images/7-analytics-api-search.png
Normal file
After Width: | Height: | Size: 209 KiB |
BIN
images/7-analytics-data-api-enable.png
Normal file
After Width: | Height: | Size: 239 KiB |
BIN
images/7-analytics-data-api-search.png
Normal file
After Width: | Height: | Size: 258 KiB |
BIN
images/7-analytics-reporting-api-enable.png
Normal file
After Width: | Height: | Size: 223 KiB |
BIN
images/7-analytics-reporting-api-search.png
Normal file
After Width: | Height: | Size: 237 KiB |
1
images/logo_dark.svg
Normal file
After Width: | Height: | Size: 23 KiB |
1
images/logo_light.svg
Normal file
After Width: | Height: | Size: 24 KiB |
@ -1,2 +1,3 @@
|
||||
BASE_URL=replace-me
|
||||
SECRET_KEY_BASE=replace-me
|
||||
TOTP_VAULT_KEY=replace-me
|
||||
|
@ -38,7 +38,7 @@ $ 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
|
||||
|
@ -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";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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
|
||||
```
|
||||
|