ZooKeeper, ClickHouse Docker MacOS

ZooKeeper

The issue with zookeeper is chmod the mounted volume and got permission denied when running as root. But if run as default user, it got permission denied when trying to read config. Here is a simple solution, create a Dockerfile:

# Use the base image
FROM bitnami/zookeeper:3.7.1

# Switch to root user to change permissions
USER root

# Change ownership or permissions of /opt/bitnami
RUN chown -R 1001:1001 /opt/bitnami && chmod -R 775 /opt/bitnami

# Switch back to the non-root user
USER 1001

And build the image with:

$ docker build -t custom-zookeeper:3.7.1 .

ClickHouse

ClickHouse also perform chmod on its startup and can cause permission denied. The helpful solution could be useful from here: https://clickhouse-experts.com/blog/2021/03/20/clickhouse-container-permissions-and-faster-startup/

Define environment variables:

CLICKHOUSE_DO_NOT_CHOWN=1
CLICKHOUSE_UID=101
CLICKHOUSE_GID=101

These is solution for image clickhouse/clickhouse-server:24.1.2-alpine.

C++ Hot-Reload

Having hot-reload during development can save time. Typically, in programming, we follow a Coding-Build-Execute Loop pattern. In C++, the build process can be optimized using incremental builds, which only compile the files that have changed. However, executing the application from the start often requires additional steps to replicate the state necessary to test the updated feature. Hot-reload is incredibly useful in this scenario, as it eliminates the need to restart the application, allowing you to see changes directly without extra setup.

Hot-reload has become standard practice when developing front-end applications. However, for C++ or desktop applications, it is not usually a default feature, execept for game programming.

But hot-reload in C++ already exists over decade. Here is some of its implementations:

  • Live++ – Windows – commercial
  • cr – Cross (C) – opensource MIT [Nov 21, 2017]
  • jet-live – Macos & Linux – opensource MIT [Jan 3, 2019]
  • blink – Windows – opensource BSD2 [Jan 3, 2016]
  • RuntimeCompiledCPlusPlus – Cross – opensource zlib [Jun 25, 2011]
  • hotswap-cpp (hscpp) – Cross – opensource MIT [Jul 13, 2020]

My favorite implementation is hotswap-cpp (hscpp).