Skip to content

Commit 0bf77e3

Browse files
committed
WKBCH-13: Add automatic permission handling for Clickhouse shards
1 parent 0a86037 commit 0bf77e3

File tree

4 files changed

+29
-2
lines changed

4 files changed

+29
-2
lines changed

cmd/configure.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,9 @@ func generateMigrationToolsConfig(cfg EnvironmentConfig, path string) error {
205205

206206
func generateClickhouseConfig(cfg EnvironmentConfig, path string) error {
207207
templates := []string{
208+
"Dockerfile.shard",
208209
"Dockerfile.setup",
210+
"entrypoint.sh",
209211
"cluster-config.xml",
210212
"ports-shard-1.xml",
211213
"ports-shard-2.xml",
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
ARG BASE_IMAGE
2+
FROM $BASE_IMAGE
3+
4+
USER root
5+
6+
COPY --chmod=755 entrypoint.sh /usr/local/bin/
7+
8+
ENTRYPOINT ["/usr/local/bin/entrypoint.sh"]

templates/clickhouse/entrypoint.sh

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/bin/sh
2+
set -e
3+
4+
# Fix permissions on data and log directories
5+
chown -R clickhouse:clickhouse /var/lib/clickhouse
6+
chown -R clickhouse:clickhouse /var/log/clickhouse-server
7+
8+
# Switch to clickhouse user and start server
9+
exec su clickhouse -s /bin/sh -c 'exec /usr/bin/clickhouse-server --config-file=/etc/clickhouse-server/config.xml'

templates/global/docker-compose.yaml

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,11 @@ services:
294294
- feature-migration
295295

296296
clickhouse-shard-1:
297-
image: ${CLICKHOUSE_IMAGE}
297+
build:
298+
context: ./config/clickhouse
299+
dockerfile: Dockerfile.shard
300+
args:
301+
BASE_IMAGE: ${CLICKHOUSE_IMAGE}
298302
container_name: workbench-clickhouse-shard-1
299303
hostname: clickhouse-shard-1
300304
network_mode: host
@@ -316,7 +320,11 @@ services:
316320
- feature-access-logging
317321

318322
clickhouse-shard-2:
319-
image: ${CLICKHOUSE_IMAGE}
323+
build:
324+
context: ./config/clickhouse
325+
dockerfile: Dockerfile.shard
326+
args:
327+
BASE_IMAGE: ${CLICKHOUSE_IMAGE}
320328
container_name: workbench-clickhouse-shard-2
321329
hostname: clickhouse-shard-2
322330
network_mode: host

0 commit comments

Comments
 (0)