Skip to content

Commit

Permalink
clickhouse: Add initial clickhouse configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
raimannma committed Oct 8, 2024
1 parent 6150aa5 commit de827b1
Show file tree
Hide file tree
Showing 8 changed files with 73 additions and 2 deletions.
8 changes: 8 additions & 0 deletions .env-example
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,11 @@ AWS_SECRET_ACCESS_KEY=
S3_ENDPOINT=
S3_REGION=
S3_BUCKET_NAME=

# Clickhouse
CLICKHOUSE_HOST=clickhouse
CLICKHOUSE_HTTP_PORT=8123
CLICKHOUSE_TCP_PORT=9000
CLICKHOUSE_DB=default
CLICKHOUSE_USER=default
CLICKHOUSE_PASSWORD=
10 changes: 10 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ repos:
- id: mixed-line-ending
- id: pretty-format-json
args: [--autofix]
- repo: https://github.com/sqlfluff/sqlfluff
rev: 3.2.2
hooks:
- id: sqlfluff-fix
args: ["--dialect", "clickhouse", "-e", "CP03,CP05"]

# Hooks for validation
- repo: https://github.com/pre-commit/pre-commit-hooks
Expand All @@ -28,3 +33,8 @@ repos:
rev: 3.0.3
hooks:
- id: editorconfig-checker
- repo: https://github.com/sqlfluff/sqlfluff
rev: 3.2.2
hooks:
- id: sqlfluff-lint
args: ["--dialect", "clickhouse", "-e", "CP03,CP05"]
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Define the list of all directories containing the compose files
ALL_DIRS=webserver monitoring authentik rabbitmq parser user-ingest spectator/server
ALL_DIRS=clickhouse webserver monitoring authentik rabbitmq parser user-ingest spectator/server

# If specific directories are passed as arguments, use them; otherwise, use ALL_DIRS
DIRS=$(if $(filter $(ALL_DIRS), $(MAKECMDGOALS)), $(filter $(ALL_DIRS), $(MAKECMDGOALS)), $(ALL_DIRS))
Expand Down
2 changes: 1 addition & 1 deletion authentik/docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ services:
- ./custom-templates:/templates
env_file: .env
ports:
- "9000:9000"
- "9001:9000"
networks:
- default
- monitoring
Expand Down
2 changes: 2 additions & 0 deletions clickhouse/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
data/
log/
2 changes: 2 additions & 0 deletions clickhouse/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
data/
log/
20 changes: 20 additions & 0 deletions clickhouse/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Clickhouse

### Migration

#### Python-Dependencies

- clickhouse-migrations (See: https://github.com/zifter/clickhouse-migrations)

#### Run Migration

1. Add a migration file in the `migrations` directory. (must be ascending order)
2. Run the following command to apply the migrations.
```bash
clickhouse-migrations \
--db-host $CLICKHOUSE_URL \
--db-user $CLICKHOUSE_USER \
--db-password $CLICKHOUSE_PASSWORD \
--db-name $CLICKHOUSE_DB \
--migrations-dir ./migrations
```
29 changes: 29 additions & 0 deletions clickhouse/docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
services:
clickhouse:
image: clickhouse/clickhouse-server
restart: always
ports:
- "127.0.0.1:8123:8123"
- "127.0.0.1:9000:9000"
ulimits:
nofile:
soft: 262144
hard: 262144
privileged: true
volumes:
- ./data:/var/lib/clickhouse
- ./log:/var/log/clickhouse-server
env_file: ../.env
environment:
CLICKHOUSE_DEFAULT_ACCESS_MANAGEMENT: 1
healthcheck:
test: ["CMD", "clickhouse-client", "--query", "SELECT 1"]
interval: 10s
timeout: 5s
retries: 3
networks:
- clickhouse

networks:
clickhouse:
name: clickhouse

0 comments on commit de827b1

Please sign in to comment.