Skip to content

Commit f90c1ce

Browse files
committed
Configs
1 parent d3bdce3 commit f90c1ce

File tree

6 files changed

+97
-26
lines changed

6 files changed

+97
-26
lines changed

.env.test

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
CLICKHOUSE_URL
2+
CLICKHOUSE_PORT
3+
CLICKHOUSE_USER
4+
CLICKHOUSE_PASSWORD
5+
CLICKHOUSE_SECURE

Dockerfile

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,28 @@ RUN apt-get update && \
77
apt-get clean && \
88
rm -rf /var/lib/apt/lists/*
99

10+
# Create a non-root user
11+
ARG USER_ID=1000
12+
ARG GROUP_ID=1000
13+
RUN addgroup --gid $GROUP_ID appgroup && \
14+
adduser --disabled-password --gecos '' --uid $USER_ID --gid $GROUP_ID appuser
15+
1016
# Setup the working directory
1117
WORKDIR /app
18+
RUN chown -R appuser:appgroup /app && chmod -R 755 /app
19+
20+
# Switch to non-root user
21+
USER appuser
1222

1323
# Copy the Python requirements and install them
14-
COPY /requirements.txt /app/requirements.txt
15-
RUN pip install -r /app/requirements.txt
24+
COPY requirements.txt /app/requirements.txt
25+
RUN pip install --user -r /app/requirements.txt
1626

1727
# Set environment variable to specify the DBT project path
1828
ENV DBT_PROJECT_PATH /app/src
1929

2030
# Optionally expose a port for dbt docs if needed
21-
EXPOSE 8080
31+
EXPOSE 8080
32+
33+
# Set PATH to include user-level binaries
34+
ENV PATH=/home/appuser/.local/bin:$PATH

docker-compose.yml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
services:
2+
dbt:
3+
container_name: dbt
4+
build:
5+
context: .
6+
dockerfile: Dockerfile
7+
args:
8+
USER_ID: ${USER_ID:-1000}
9+
GROUP_ID: ${GROUP_ID:-1000}
10+
restart: unless-stopped
11+
ports:
12+
- "8080:8000"
13+
command: >
14+
/bin/bash -c "exec python -m http.server 8000 --directory logs & tail -f /dev/null"
15+
environment:
16+
CLICKHOUSE_USER: ${CLICKHOUSE_USER}
17+
CLICKHOUSE_PASSWORD: ${CLICKHOUSE_PASSWORD}
18+
CLICKHOUSE_URL: ${CLICKHOUSE_URL}
19+
CLICKHOUSE_PORT: ${CLICKHOUSE_PORT}
20+
CLICKHOUSE_SECURE: ${CLICKHOUSE_SECURE}
21+
volumes:
22+
- type: bind
23+
source: ./
24+
target: /app
25+
consistency: cached
26+
- ./profiles.yml:/home/appuser/.dbt/profiles.yml
27+
working_dir: /app
28+
user: appuser
29+
networks:
30+
- dbt_net
31+
32+
33+
networks:
34+
dbt_net:
Lines changed: 10 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,14 @@
11
WITH consensus_power AS (
2-
SELECT * FROM (
3-
VALUES
4-
(4, 'Lighthouse', 2.75),
5-
(5, 'Lighthouse', 3.14),
6-
(6, 'Lighthouse', 18.84),
7-
(4, 'Teku', 3.71),
8-
(5, 'Teku', 3.32),
9-
(6, 'Teku', 27.46),
10-
(4, 'Lodestar', 3.14),
11-
(5, 'Lodestar', 3.89),
12-
(6, 'Lodestar', 33.55),
13-
(4, 'Nimbus', 1.67),
14-
(5, 'Nimbus', 2.08),
15-
(6, 'Nimbus', 17.11),
16-
(4, 'Prysm', 3.51),
17-
(5, 'Prysm', 2.87),
18-
(6, 'Prysm', 24.33)
19-
) AS t(type, client, mean)
2+
SELECT
3+
type,
4+
client,
5+
mean
6+
FROM (
7+
SELECT
8+
arrayJoin([4, 5, 6, 4, 5, 6, 4, 5, 6, 4, 5, 6, 4, 5, 6]) AS type,
9+
arrayJoin(['Lighthouse', 'Lighthouse', 'Lighthouse', 'Teku', 'Teku', 'Teku', 'Lodestar', 'Lodestar', 'Lodestar', 'Nimbus', 'Nimbus', 'Nimbus', 'Prysm', 'Prysm', 'Prysm']) AS client,
10+
arrayJoin([2.75, 3.14, 18.84, 3.71, 3.32, 27.46, 3.14, 3.89, 33.55, 1.67, 2.08, 17.11, 3.51, 2.87, 24.33]) AS mean
11+
)
2012
)
2113

2214
SELECT * FROM consensus_power

profiles.yml

Lines changed: 29 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,41 @@
11
gnosis_dbt:
2-
target: clickhouse
2+
target: ch-dbt
33
outputs:
4-
clickhouse: # ClickHouse configuration for additional data sourcing
4+
ch-dbt:
55
type: clickhouse
6-
schema: "{{ env_var('CLICKHOUSE_SCHEMA') }}"
6+
schema: "dbt"
77
verify: False
88
host: "{{ env_var('CLICKHOUSE_URL') }}"
99
port: "{{ env_var('CLICKHOUSE_PORT', '8123') | int }}"
1010
secure: "{{ (env_var('CLICKHOUSE_SECURE', 'False') | lower) == 'true' }}"
11-
cluster: '{cluster}'
12-
cluster_mode: True
1311
user: "{{ env_var('CLICKHOUSE_USER') }}"
1412
password: "{{ env_var('CLICKHOUSE_PASSWORD') }}"
1513
threads: 40
1614
connect_timeout: 60 # Increase the connect timeout (in seconds)
1715
read_timeout: 3000 # Increase the read timeout (in seconds)
16+
17+
ch-valtrack:
18+
type: clickhouse
19+
schema: "valtrack_preview"
20+
verify: False
21+
host: "{{ env_var('CLICKHOUSE_URL') }}"
22+
port: "{{ env_var('CLICKHOUSE_PORT', '8123') | int }}"
23+
secure: "{{ (env_var('CLICKHOUSE_SECURE', 'False') | lower) == 'true' }}"
24+
user: "{{ env_var('CLICKHOUSE_USER') }}"
25+
password: "{{ env_var('CLICKHOUSE_PASSWORD') }}"
26+
threads: 40
27+
connect_timeout: 60
28+
read_timeout: 3000
29+
30+
ch-goteth:
31+
type: clickhouse
32+
schema: "goteth_preview"
33+
verify: False
34+
host: "{{ env_var('CLICKHOUSE_URL') }}"
35+
port: "{{ env_var('CLICKHOUSE_PORT', '8123') | int }}"
36+
secure: "{{ (env_var('CLICKHOUSE_SECURE', 'False') | lower) == 'true' }}"
37+
user: "{{ env_var('CLICKHOUSE_USER') }}"
38+
password: "{{ env_var('CLICKHOUSE_PASSWORD') }}"
39+
threads: 40
40+
connect_timeout: 60
41+
read_timeout: 3000

requirements.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
dbt-core==1.8.7
2+
dbt-clickhouse==1.8.4
3+
pytest==8.2.1

0 commit comments

Comments
 (0)