Giter Site home page Giter Site logo

Comments (6)

rajasekhar-gundala avatar rajasekhar-gundala commented on August 20, 2024 3

Hi All,
Today I deployed self-hosted Plausible in the docker swarm environment successfully behind Caddy Server. I used the external Postgres database because I have a Postgres database container already running in the docker swarm.

You have to create plausible_events_db in the clickhouse server container for the first time.

Run docker ps to find out the container ID of the clickhouse server

Run docker exec -it <clickhousecontainerid> clickhouse-client to log into clickhouse server

Then run create database plausible_events_db; to create plausible events database. In this case plausible_events_db

Exit from the container by entering exit

Please find docker-compose stack below

version: "3.7"

services:
  mail:
    image: bytemark/smtp
    networks:
      - caddy
    deploy:
      placement:
        constraints: [node.role == worker]
      replicas: 1
      update_config:
        parallelism: 2
        delay: 10s
      restart_policy:
        condition: on-failure  
  plausible_events_db:
    image: yandex/clickhouse-server:latest
    volumes:
      - /mnt/clickhouse:/var/lib/clickhouse
      - /mnt/config/clickhouse-config.xml:/etc/clickhouse-server/config.d/logging.xml:ro
      - /mnt/config/clickhouse-user-config.xml:/etc/clickhouse-server/users.d/logging.xml:ro
    ulimits:
      nofile:
        soft: 262144
        hard: 262144
    networks:
      - caddy
    deploy:
      placement:
        constraints: [node.role == worker]
      replicas: 1
      update_config:
        parallelism: 2
        delay: 10s
      restart_policy:
        condition: on-failure  
  plausible:
    image: plausible/analytics:latest
    command: sh -c "sleep 10 && /entrypoint.sh db migrate && /entrypoint.sh db init-admin && /entrypoint.sh run"
    depends_on:
      - postgres
      - plausible_events_db
      - mail
    environment:
      - ADMIN_USER_NAME=admin
      - [email protected]
      - ADMIN_USER_PWD=password
      - DATABASE_URL=postgres://username:password@postgresservicename:5432/plausibledatabsename
      - DATABASE_NAME=plausibledatabsename
      - CLICKHOUSE_DATABASE_URL=http://plausible_events_db:8123/clickhousedatabsename
      - CLICKHOUSE_FLUSH_INTERVAL_MS=5000
      - CLICKHOUSE_MAX_BUFFER_SIZE=10000
      - BASE_URL=https://plausible.example.com
      - PORT=8000
      - LISTEN_IP=0.0.0.0
      - SECRET_KEY_BASE=generate one using 'openssl rand -hex 64'
      - [email protected]
      - SMTP_HOST_ADDR=smtp host name
      - SMTP_HOST_PORT=smtp port
      - SMTP_USER_NAME=smtp user name
      - SMTP_USER_PWD=smtp password
      - SMTP_HOST_SSL_ENABLED=false
      - SMTP_RETRIES=2
    networks:
      - caddy
    ports:
      - "8000:8000"
    deploy:
      placement:
        constraints: [node.role == manager]
      replicas: 1
      update_config:
        parallelism: 2
        delay: 10s
      restart_policy:
        condition: on-failure
volumes:
  clickhouse:
    driver: "local"
  config:
    driver: "local"
networks:
  caddy:
    external: true

from community-edition.

productdevbook avatar productdevbook commented on August 20, 2024

iam ubuntu 22 and docker swarm used

from community-edition.

DarthMikke avatar DarthMikke commented on August 20, 2024

I encountered the same error today. @productdevbook , did you get the self-hosted solution to work in some other way?

from community-edition.

productdevbook avatar productdevbook commented on August 20, 2024

@rajaseg please share /mnt/ all docs

from community-edition.

rajasekhar-gundala avatar rajasekhar-gundala commented on August 20, 2024

@rajaseg please share /mnt/ all docs

@productdevbook, I deployed GlusterFS as a replicated volume in my docker swarm environment for data availability throughout the cluster.

That's why I mounted clickhouse server volume and configuration files to /mnt directory

Please find the configuration files below.

/mnt/config/clickhouse-config.xml

<yandex>
    <logger>
        <level>warning</level>
        <console>true</console>
    </logger>

    <!-- Stop all the unnecessary logging -->
    <query_thread_log remove="remove"/>
    <query_log remove="remove"/>
    <text_log remove="remove"/>
    <trace_log remove="remove"/>
    <metric_log remove="remove"/>
    <asynchronous_metric_log remove="remove"/>
</yandex>

/mnt/config/clickhouse-user-config.xml

<yandex>
    <profiles>
        <default>
            <log_queries>0</log_queries>
            <log_query_threads>0</log_query_threads>
        </default>
    </profiles>
</yandex>

Link for the configuration files below.

https://github.com/plausible/hosting/tree/master/clickhouse

from community-edition.

ruslandoga avatar ruslandoga commented on August 20, 2024

Closing as docker swarm setups are not officially supported.

from community-edition.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.