Towards ghost setup

This commit is contained in:
Luciano Gervasoni
2025-04-16 20:10:33 +02:00
parent 4dd351f4ef
commit 212d8fb65d
4 changed files with 197 additions and 0 deletions

View File

@@ -0,0 +1,3 @@
<clickhouse>
<listen_host>0.0.0.0</listen_host>
</clickhouse>

View File

@@ -0,0 +1,28 @@
<clickhouse>
<logger>
<level>warning</level>
<console>true</console>
</logger>
<query_log replace="1">
<database>system</database>
<table>query_log</table>
<flush_interval_milliseconds>7500</flush_interval_milliseconds>
<engine>
ENGINE = MergeTree
PARTITION BY event_date
ORDER BY (event_time)
TTL event_date + interval 30 day
SETTINGS ttl_only_drop_parts=1
</engine>
</query_log>
<!-- Stops unnecessary logging -->
<metric_log remove="remove" />
<asynchronous_metric_log remove="remove" />
<query_thread_log remove="remove" />
<text_log remove="remove" />
<trace_log remove="remove" />
<session_log remove="remove" />
<part_log remove="remove" />
</clickhouse>

View File

@@ -0,0 +1,23 @@
<!-- https://clickhouse.com/docs/en/operations/tips#using-less-than-16gb-of-ram -->
<clickhouse>
<!--
https://clickhouse.com/docs/en/operations/server-configuration-parameters/settings#mark_cache_size -->
<mark_cache_size>524288000</mark_cache_size>
<profile>
<default>
<!-- https://clickhouse.com/docs/en/operations/settings/settings#max_threads -->
<max_threads>1</max_threads>
<!-- https://clickhouse.com/docs/en/operations/settings/settings#max_block_size -->
<max_block_size>8192</max_block_size>
<!-- https://clickhouse.com/docs/en/operations/settings/settings#max_download_threads -->
<max_download_threads>1</max_download_threads>
<!--
https://clickhouse.com/docs/en/operations/settings/settings#input_format_parallel_parsing -->
<input_format_parallel_parsing>0</input_format_parallel_parsing>
<!--
https://clickhouse.com/docs/en/operations/settings/settings#output_format_parallel_formatting -->
<output_format_parallel_formatting>0</output_format_parallel_formatting>
</default>
</profile>
</clickhouse>

143
website/docker-compose.yml Normal file
View File

@@ -0,0 +1,143 @@
services:
ghost:
image: ghost:5-alpine
container_name: ghost
restart: unless-stopped
ports:
- 2368 #- 8080:2368
environment:
# see https://ghost.org/docs/config/#configuration-options
database__client: mysql
database__connection__host: ghost_db
database__connection__user: root
database__connection__password: example
database__connection__database: ghost
url: news.matitos.org
# contrary to the default mentioned in the linked documentation, this image defaults to NODE_ENV=production (so development mode needs to be explicitly specified if desired)
#NODE_ENV: development
volumes:
- ./docker_data/ghost:/var/lib/ghost/content
labels: # Reverse proxy sample
- "traefik.enable=true"
- "traefik.http.routers.news.rule=Host(`news.matitos.org`)"
- "traefik.http.routers.news.entrypoints=websecure"
- "traefik.http.routers.news.tls.certresolver=myresolvercd"
- "traefik.http.services.news.loadbalancer.server.port=2368"
networks:
- default # This network
- docker_default # Reverse proxy network
ghost_db:
image: mysql:8.0
container_name: ghost_db
restart: unless-stopped
environment:
MYSQL_ROOT_PASSWORD: example
volumes:
- ./docker_data/ghost_db:/var/lib/mysql
plausible_db:
image: postgres:16-alpine
restart: unless-stopped
container_name: plausible_db
volumes:
- ./docker_data/plausible_db_data:/var/lib/postgresql/data
environment:
- POSTGRES_PASSWORD=postgres
healthcheck:
test: ["CMD-SHELL", "pg_isready -U postgres"]
start_period: 1m
plausible_events_db:
image: clickhouse/clickhouse-server:24.12-alpine
restart: unless-stopped
container_name: plausible_events_db
volumes:
- ./docker_data/event-data:/var/lib/clickhouse
- ./docker_data/event-logs:/var/log/clickhouse-server
- ./clickhouse/logs.xml:/etc/clickhouse-server/config.d/logs.xml:ro
# This makes ClickHouse bind to IPv4 only, since Docker doesn't enable IPv6 in bridge networks by default.
# Fixes "Listen [::]:9000 failed: Address family for hostname not supported" warnings.
- ./clickhouse/ipv4-only.xml:/etc/clickhouse-server/config.d/ipv4-only.xml:ro
# This makes ClickHouse consume less resources, which is useful for small setups.
# https://clickhouse.com/docs/en/operations/tips#using-less-than-16gb-of-ram
- ./clickhouse/low-resources.xml:/etc/clickhouse-server/config.d/low-resources.xml:ro
ulimits:
nofile:
soft: 262144
hard: 262144
environment:
- CLICKHOUSE_SKIP_USER_SETUP=1
healthcheck:
test: ["CMD-SHELL", "wget --no-verbose --tries=1 -O - http://127.0.0.1:8123/ping || exit 1"]
start_period: 1m
plausible:
image: ghcr.io/plausible/community-edition:v3.0.1
restart: unless-stopped
container_name: plausible
command: sh -c "/entrypoint.sh db createdb && /entrypoint.sh db migrate && /entrypoint.sh run"
depends_on:
plausible_db:
condition: service_healthy
plausible_events_db:
condition: service_healthy
#volumes:
# - ./docker_data/plausible_data:/var/lib/plausible # https://github.com/plausible/community-edition/issues/163
ulimits:
nofile:
soft: 65535
hard: 65535
ports:
- 8000 # :8000
environment:
- TMPDIR=/var/lib/plausible/tmp
# required: https://github.com/plausible/community-edition/wiki/configuration#required
#- BASE_URL=${BASE_URL}
#- SECRET_KEY_BASE=${SECRET_KEY_BASE}
- BASE_URL=https://plausible.matitos.org
- SECRET_KEY_BASE=KKfwEjeK3Xp6NdH7eCJ2szWliTueiB0vcCT4XpHvEE8ZHgvRg0Vle90wOrETQZoC
# optional: https://github.com/plausible/community-edition/wiki/configuration#optional
# registration: https://github.com/plausible/community-edition/wiki/configuration#registration
- TOTP_VAULT_KEY
- DISABLE_REGISTRATION
- ENABLE_EMAIL_VERIFICATION
# web: https://github.com/plausible/community-edition/wiki/configuration#web
- HTTP_PORT=8000
- HTTPS_PORT
# databases: https://github.com/plausible/community-edition/wiki/configuration#database
- DATABASE_URL
- CLICKHOUSE_DATABASE_URL
# Google: https://github.com/plausible/community-edition/wiki/configuration#google
- GOOGLE_CLIENT_ID
- GOOGLE_CLIENT_SECRET
# geolocation: https://github.com/plausible/community-edition/wiki/configuration#ip-geolocation
- IP_GEOLOCATION_DB
- GEONAMES_SOURCE_FILE
- MAXMIND_LICENSE_KEY
- MAXMIND_EDITION
# email: https://github.com/plausible/community-edition/wiki/configuration#email
- MAILER_ADAPTER
- MAILER_EMAIL
- MAILER_NAME
- SMTP_HOST_ADDR
- SMTP_HOST_PORT
- SMTP_USER_NAME
- SMTP_USER_PWD
- SMTP_HOST_SSL_ENABLED
- POSTMARK_API_KEY
- MAILGUN_API_KEY
- MAILGUN_DOMAIN
- MAILGUN_BASE_URI
- MANDRILL_API_KEY
- SENDGRID_API_KEY
labels: # Reverse proxy sample
- "traefik.enable=true"
- "traefik.http.routers.plausible.rule=Host(`plausible.matitos.org`)"
- "traefik.http.routers.plausible.entrypoints=websecure"
- "traefik.http.routers.plausible.tls.certresolver=myresolvercd"
- "traefik.http.services.plausible.loadbalancer.server.port=8000"
networks:
- default # This network
- docker_default # Reverse proxy network