Skip to content

Commit 8bbafd0

Browse files
authored
Add TLS disable option for ClickHouse and include Docker Compose file (#93)
2 parents 23edc5e + 68baa73 commit 8bbafd0

File tree

4 files changed

+78
-6
lines changed

4 files changed

+78
-6
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -343,6 +343,7 @@ storage:
343343
user: "admin"
344344
password: "admin"
345345
database: "base"
346+
disableTLS: false
346347
staging:
347348
driver: "memory"
348349
memory:

configs/config.go

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,12 @@ type StorageConnectionConfig struct {
5454
}
5555

5656
type ClickhouseConfig struct {
57-
Host string `mapstructure:"host"`
58-
Port int `mapstructure:"port"`
59-
Username string `mapstructure:"username"`
60-
Password string `mapstructure:"password"`
61-
Database string `mapstructure:"database"`
57+
Host string `mapstructure:"host"`
58+
Port int `mapstructure:"port"`
59+
Username string `mapstructure:"username"`
60+
Password string `mapstructure:"password"`
61+
Database string `mapstructure:"database"`
62+
DisableTLS bool `mapstructure:"disableTLS"`
6263
}
6364

6465
type MemoryConfig struct {

docker-compose.yml

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
services:
2+
redis:
3+
image: redis:latest
4+
ports:
5+
- "6379:6379"
6+
volumes:
7+
- redis_data:/data
8+
command: redis-server --appendonly yes
9+
profiles:
10+
- redis
11+
12+
# http://localhost:8123/play <- web ui
13+
clickhouse:
14+
image: clickhouse/clickhouse-server:latest
15+
ports:
16+
- "8123:8123"
17+
- "9000:9000"
18+
volumes:
19+
- clickhouse_data:/var/lib/clickhouse
20+
ulimits:
21+
nofile:
22+
soft: 262144
23+
hard: 262144
24+
25+
prometheus:
26+
image: prom/prometheus:latest
27+
ports:
28+
- "9090:9090"
29+
command:
30+
- '--config.file=/etc/prometheus/prometheus.yml'
31+
configs:
32+
- source: prometheus_config
33+
target: /etc/prometheus/prometheus.yml
34+
extra_hosts:
35+
- "host.docker.internal:host-gateway"
36+
profiles:
37+
- monitoring
38+
39+
grafana:
40+
image: grafana/grafana:latest
41+
environment:
42+
- GF_SECURITY_ADMIN_USER=admin
43+
- GF_SECURITY_ADMIN_PASSWORD=admin
44+
ports:
45+
- "4000:3000"
46+
volumes:
47+
- grafana_data:/var/lib/grafana
48+
profiles:
49+
- monitoring
50+
51+
volumes:
52+
redis_data:
53+
clickhouse_data:
54+
grafana_data:
55+
56+
configs:
57+
prometheus_config:
58+
content: |
59+
global:
60+
scrape_interval: 15s
61+
62+
scrape_configs:
63+
- job_name: 'local_service'
64+
static_configs:
65+
- targets: ['host.docker.internal:2112']

internal/storage/clickhouse.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,12 @@ func connectDB(cfg *config.ClickhouseConfig) (clickhouse.Conn, error) {
4343
conn, err := clickhouse.Open(&clickhouse.Options{
4444
Addr: []string{fmt.Sprintf("%s:%d", cfg.Host, port)},
4545
Protocol: clickhouse.Native,
46-
TLS: &tls.Config{}, // enable secure TLS
46+
TLS: func() *tls.Config {
47+
if cfg.DisableTLS {
48+
return nil
49+
}
50+
return &tls.Config{}
51+
}(),
4752
Auth: clickhouse.Auth{
4853
Username: cfg.Username,
4954
Password: cfg.Password,

0 commit comments

Comments
 (0)