diff --git a/website/clickhouse/ipv4-only.xml b/website/clickhouse/ipv4-only.xml new file mode 100644 index 0000000..7eb0a5c --- /dev/null +++ b/website/clickhouse/ipv4-only.xml @@ -0,0 +1,3 @@ + + 0.0.0.0 + diff --git a/website/clickhouse/logs.xml b/website/clickhouse/logs.xml new file mode 100644 index 0000000..3902fdd --- /dev/null +++ b/website/clickhouse/logs.xml @@ -0,0 +1,28 @@ + + + warning + true + + + + system + query_log
+ 7500 + + ENGINE = MergeTree + PARTITION BY event_date + ORDER BY (event_time) + TTL event_date + interval 30 day + SETTINGS ttl_only_drop_parts=1 + +
+ + + + + + + + + +
diff --git a/website/clickhouse/low-resources.xml b/website/clickhouse/low-resources.xml new file mode 100644 index 0000000..a75e843 --- /dev/null +++ b/website/clickhouse/low-resources.xml @@ -0,0 +1,23 @@ + + + + 524288000 + + + + + 1 + + 8192 + + 1 + + 0 + + 0 + + + diff --git a/website/docker-compose.yml b/website/docker-compose.yml new file mode 100644 index 0000000..f7c3bba --- /dev/null +++ b/website/docker-compose.yml @@ -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 \ No newline at end of file