Skip to content

Commit 4a5c974

Browse files
author
Pascal Klesse
committed
fix: fix plausible service
1 parent a393ab6 commit 4a5c974

File tree

2 files changed

+82
-17
lines changed

2 files changed

+82
-17
lines changed

projects/api/src/server/common/services/docker.service.ts

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -175,18 +175,17 @@ REDIS_PASSWORD=
175175
case ServiceType.PLAUSIBLE:
176176
if (!container.env) {
177177
const secretKeyBase = randomBytes(64).toString('base64');
178-
const dbPassword = randomBytes(16).toString('hex');
179178

180179
container.env = `
181180
# Plausible Configuration
182181
BASE_URL=https://${container.url}
183182
SECRET_KEY_BASE=${secretKeyBase}
184183
185-
# Database
186-
DATABASE_URL=postgres://plausible:${dbPassword}@${container.id}_postgres:5432/plausible
184+
# Database (uses internal service names)
185+
DATABASE_URL=postgres://postgres:postgres@postgres:5432/plausible
187186
188-
# ClickHouse
189-
CLICKHOUSE_DATABASE_URL=http://${container.id}_clickhouse:8123/plausible
187+
# ClickHouse (uses internal service name)
188+
CLICKHOUSE_DATABASE_URL=http://clickhouse:8123/plausible
190189
191190
# SMTP Configuration (replace with your SMTP settings)
192191
MAILER_EMAIL=hello@example.com
@@ -198,11 +197,6 @@ SMTP_HOST_SSL_ENABLED=true
198197
199198
# Registration (set to invite_only to disable public registration)
200199
DISABLE_REGISTRATION=false
201-
202-
# PostgreSQL (internal - must match DATABASE_URL)
203-
POSTGRES_USER=plausible
204-
POSTGRES_PASSWORD=${dbPassword}
205-
POSTGRES_DB=plausible
206200
`;
207201

208202
await this.containerService.updateForce(container.id, { env: container.env });

projects/api/src/server/modules/container/types/service/plausible/compose.ts

Lines changed: 78 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,47 +10,117 @@ networks:
1010
plausible-internal:
1111
driver: overlay
1212
13+
configs:
14+
clickhouse_logs_config:
15+
content: |
16+
<clickhouse>
17+
<logger>
18+
<level>warning</level>
19+
<console>true</console>
20+
</logger>
21+
<query_log replace="1">
22+
<database>system</database>
23+
<table>query_log</table>
24+
<flush_interval_milliseconds>7500</flush_interval_milliseconds>
25+
<engine>
26+
ENGINE = MergeTree
27+
PARTITION BY event_date
28+
ORDER BY (event_time)
29+
TTL event_date + interval 30 day
30+
SETTINGS ttl_only_drop_parts=1
31+
</engine>
32+
</query_log>
33+
<metric_log remove="remove" />
34+
<asynchronous_metric_log remove="remove" />
35+
<query_thread_log remove="remove" />
36+
<text_log remove="remove" />
37+
<trace_log remove="remove" />
38+
<session_log remove="remove" />
39+
<part_log remove="remove" />
40+
</clickhouse>
41+
clickhouse_ipv4_config:
42+
content: |
43+
<clickhouse>
44+
<listen_host>0.0.0.0</listen_host>
45+
</clickhouse>
46+
clickhouse_resources_config:
47+
content: |
48+
<clickhouse>
49+
<mark_cache_size>524288000</mark_cache_size>
50+
<profile>
51+
<default>
52+
<max_threads>1</max_threads>
53+
<max_block_size>8192</max_block_size>
54+
<max_download_threads>1</max_download_threads>
55+
<input_format_parallel_parsing>0</input_format_parallel_parsing>
56+
<output_format_parallel_formatting>0</output_format_parallel_formatting>
57+
</default>
58+
</profile>
59+
</clickhouse>
60+
1361
services:
1462
postgres:
1563
image: postgres:16-alpine
1664
volumes:
1765
- plausibleDb:/var/lib/postgresql/data
1866
environment:
19-
POSTGRES_USER: plausible
20-
POSTGRES_PASSWORD: plausible
21-
POSTGRES_DB: plausible
67+
POSTGRES_PASSWORD: postgres
2268
networks:
2369
- plausible-internal
70+
healthcheck:
71+
test: ["CMD-SHELL", "pg_isready -U postgres"]
72+
start_period: 1m
2473
deploy:
2574
restart_policy:
2675
condition: any
2776
max_attempts: 3
2877
window: 120s
2978
3079
clickhouse:
31-
image: clickhouse/clickhouse-server:24-alpine
80+
image: clickhouse/clickhouse-server:24.12-alpine
3281
volumes:
3382
- clickhouseData:/var/lib/clickhouse
3483
- clickhouseLogs:/var/log/clickhouse-server
84+
configs:
85+
- source: clickhouse_logs_config
86+
target: /etc/clickhouse-server/config.d/logs.xml
87+
- source: clickhouse_ipv4_config
88+
target: /etc/clickhouse-server/config.d/ipv4-only.xml
89+
- source: clickhouse_resources_config
90+
target: /etc/clickhouse-server/config.d/low-resources.xml
91+
environment:
92+
CLICKHOUSE_SKIP_USER_SETUP: "1"
3593
ulimits:
3694
nofile:
3795
soft: 262144
3896
hard: 262144
3997
networks:
4098
- plausible-internal
99+
healthcheck:
100+
test: ["CMD-SHELL", "wget --no-verbose --tries=1 --spider http://localhost:8123/ping || exit 1"]
101+
start_period: 1m
41102
deploy:
42103
restart_policy:
43104
condition: any
44105
max_attempts: 3
45106
window: 120s
46107
47108
plausible:
48-
image: ghcr.io/plausible/community-edition:${container.buildImage || 'latest'}
109+
image: ghcr.io/plausible/community-edition:${container.buildImage || 'v3.1.0'}
110+
command: sh -c "/app/bin/plausible eval Plausible.Release.setup_clickhouse && /app/bin/plausible eval Plausible.Release.migrate && /app/bin/plausible start"
49111
depends_on:
50-
- postgres
51-
- clickhouse
112+
postgres:
113+
condition: service_healthy
114+
clickhouse:
115+
condition: service_healthy
116+
volumes:
117+
- plausibleData:/var/lib/plausible
52118
env_file:
53119
- .env
120+
ulimits:
121+
nofile:
122+
soft: 65535
123+
hard: 65535
54124
networks:
55125
- traefik-public
56126
- plausible-internal
@@ -88,6 +158,7 @@ services:
88158
89159
volumes:
90160
plausibleDb:
161+
plausibleData:
91162
clickhouseData:
92163
clickhouseLogs:
93164
`;

0 commit comments

Comments
 (0)