Skip to content

Commit a47d851

Browse files
committed
plausible + other improvments
1 parent c826a35 commit a47d851

File tree

12 files changed

+156
-13
lines changed

12 files changed

+156
-13
lines changed

.env.example

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,7 @@ POSTGRESQL_DATABASE=db
1111

1212
# [REDIS]
1313
REDIS_PASSWORD=123456qwerty
14-
REDIS_DISABLE_COMMANDS=FLUSHDB,FLUSHALL
14+
REDIS_DISABLE_COMMANDS=FLUSHDB,FLUSHALL
15+
16+
# [PLAUSIBLE]
17+
PLAUSIBLE_POSTGRES_PASSWORD=123456qwerty

README.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,25 @@ Current setup requires you to fill in `.env` file with variables that are used i
132132

133133
</details>
134134

135+
<details>
136+
<summary>Plausible</summary>
137+
138+
`.env` file:
139+
140+
- `PLAUSIBLE_POSTGRES_PASSWORD` - password for Plausible PostgreSQL.
141+
142+
`services/plausible/conf.env` file:
143+
144+
- `SECRET_KEY_BASE` - secret key of your app. Can be generated by running `openssl rand -base64 64 | tr -d '\n' ; echo`.
145+
- `BASE_URL` - base url where this instance is accessible, including the scheme (eg. `http://` or `https://`), the domain name, and optionally a port.
146+
- `ADMIN_USER_EMAIL` - admin email.
147+
- `ADMIN_USER_NAME` - admin usenamename.
148+
- `ADMIN_USER_PWD` - admin password.
149+
150+
> [Original docs](https://plausible.io/docs/self-hosting).
151+
152+
</details>
153+
135154
## Enhancements
136155

137156
There are still some things I would like to add to the backend setup:

run/sadd.sh

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
SNAME=$1
2+
3+
# -- adding docker compose file
4+
SDC=services/docker-compose.$SNAME.yml
5+
if [ ! -f "$SDC" ]; then
6+
touch $SDC
7+
fi
8+
9+
# -- adding service folder
10+
SDIR=services/$SNAME
11+
if [ ! -d "$SDIR" ]; then
12+
mkdir $SDIR
13+
fi
14+
15+
# -- adding script
16+
SSH=services/$SNAME/index.sh
17+
if [ ! -f "$SSH" ]; then
18+
touch $SSH > SNAME=$SNAME
19+
fi

run/sdel.sh

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,4 @@ fi
1010
SDC=services/docker-compose.$SNAME.yml
1111
if [ -f "$SDC" ]; then
1212
rm -rf $SDC
13-
fi
14-
15-
# -- deleting script
16-
SSH=run/services/$SNAME.sh
17-
if [ -f "$SSH" ]; then
18-
rm -rf $SSH
19-
fi
13+
fi
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
# taken from -- https://github.com/plausible/hosting/blob/master/docker-compose.yml
2+
version: "3.3"
3+
4+
services:
5+
mail:
6+
image: bytemark/smtp
7+
restart: always
8+
9+
plausible_db:
10+
image: postgres:14-alpine
11+
restart: always
12+
volumes:
13+
- ./services/plausible/data:/var/lib/postgresql/data
14+
environment:
15+
- POSTGRES_PASSWORD=${PLAUSIBLE_POSTGRES_PASSWORD}
16+
labels:
17+
- "traefik.enable=false"
18+
19+
plausible_events_db:
20+
image: clickhouse/clickhouse-server:22.6-alpine
21+
restart: always
22+
volumes:
23+
- event-data:/var/lib/clickhouse
24+
- ./services/plausible/clickhouse/clickhouse-config.xml:/etc/clickhouse-server/config.d/logging.xml:ro
25+
- ./services/plausible/clickhouse/clickhouse-user-config.xml:/etc/clickhouse-server/users.d/logging.xml:ro
26+
ulimits:
27+
nofile:
28+
soft: 262144
29+
hard: 262144
30+
labels:
31+
- "traefik.enable=false"
32+
33+
plausible:
34+
image: plausible/analytics:latest
35+
restart: always
36+
command: sh -c "sleep 10 && /entrypoint.sh db createdb && /entrypoint.sh db migrate && /entrypoint.sh db init-admin && /entrypoint.sh run"
37+
depends_on:
38+
- plausible_db
39+
- plausible_events_db
40+
- mail
41+
# ports:
42+
# - 8000:8000
43+
env_file:
44+
- ./services/plausible/conf.env
45+
labels:
46+
- "traefik.enable=true"
47+
- "traefik.http.routers.plausible.rule=Host(`plausible.${DOMAIN_NAME}`)"
48+
- "traefik.http.routers.plausible.entryPoints=http"
49+
- "traefik.http.routers.plausible.middlewares=https_redirect"
50+
- "traefik.http.middlewares.https_redirect.redirectscheme.scheme=https"
51+
- "traefik.http.routers.plausible_tls.rule=Host(`plausible.${DOMAIN_NAME}`)"
52+
- "traefik.http.routers.plausible_tls.entryPoints=https"
53+
- "traefik.http.routers.plausible_tls.tls.certresolver=mydnschallenge"
54+
- "traefik.http.services.plausible.loadbalancer.server.port=8000"
55+
56+
volumes:
57+
db-data:
58+
driver: local
59+
event-data:
60+
driver: local
61+
geoip:
62+
driver: local
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<!-- taken from https://github.com/plausible/hosting/blob/master/clickhouse/clickhouse-config.xml -->
2+
<yandex>
3+
<logger>
4+
<level>warning</level>
5+
<console>true</console>
6+
</logger>
7+
8+
<!-- Stop all the unnecessary logging -->
9+
<query_thread_log remove="remove"/>
10+
<query_log remove="remove"/>
11+
<text_log remove="remove"/>
12+
<trace_log remove="remove"/>
13+
<metric_log remove="remove"/>
14+
<asynchronous_metric_log remove="remove"/>
15+
</yandex>
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<!-- taken from https://github.com/plausible/hosting/blob/master/clickhouse/clickhouse-user-config.xml -->
2+
<yandex>
3+
<profiles>
4+
<default>
5+
<log_queries>0</log_queries>
6+
<log_query_threads>0</log_query_threads>
7+
</default>
8+
</profiles>
9+
</yandex>

services/plausible/conf.env

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
ADMIN_USER_EMAIL=replace-me
2+
ADMIN_USER_NAME=replace-me
3+
ADMIN_USER_PWD=replace-me
4+
BASE_URL=replace-me
5+
SECRET_KEY_BASE=replace-me

services/plausible/index.sh

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
SNAME=plausible
2+
3+
# -- creating folder for Plausible service
4+
DIR=services/$SNAME
5+
if [ ! -d "$DIR" ]; then
6+
mkdir $DIR
7+
fi
8+
9+
# -- creating folder for storing data
10+
DIR_DATA=$DIR/data
11+
if [ ! -d "$DIR_DATA" ]; then
12+
mkdir $DIR_DATA
13+
fi
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1+
SNAME=postgresql
2+
13
# -- creating folder for PostgreSQL service
2-
DIR=services/postgresql
4+
DIR=services/$SNAME
35
if [ ! -d "$DIR" ]; then
46
mkdir $DIR
57
fi

0 commit comments

Comments
 (0)