Skip to content

Commit 36fb6ff

Browse files
refactor: parameterize Docker credentials via environment variables
Co-Authored-By: Itamar Hartstein <haritamar@gmail.com>
1 parent dcfa5e6 commit 36fb6ff

2 files changed

Lines changed: 112 additions & 39 deletions

File tree

tests/e2e_dbt_project/docker-compose.yml

Lines changed: 96 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,18 @@ services:
77
- "127.0.0.1:5432:5432"
88
command: postgres -c max_connections=500
99
environment:
10-
POSTGRES_USER: admin
11-
POSTGRES_PASSWORD: admin
10+
POSTGRES_USER: ${POSTGRES_USER:-admin}
11+
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-admin}
1212
volumes:
1313
- postgres:/var/lib/postgresql/data
14+
healthcheck:
15+
test: ["CMD-SHELL", "pg_isready -U ${POSTGRES_USER:-admin}"]
16+
interval: 5s
17+
timeout: 5s
18+
retries: 10
1419

1520
clickhouse:
16-
image: clickhouse/clickhouse-server:latest
21+
image: clickhouse/clickhouse-server:24.3
1722
container_name: clickhouse
1823
ports:
1924
- "8123:8123"
@@ -23,11 +28,16 @@ services:
2328
environment:
2429
CLICKHOUSE_DB: default
2530
CLICKHOUSE_USER: default
26-
CLICKHOUSE_PASSWORD: "default"
31+
CLICKHOUSE_PASSWORD: ${CLICKHOUSE_PASSWORD:-default}
2732
ulimits:
2833
nofile:
2934
soft: 262144
3035
hard: 262144
36+
healthcheck:
37+
test: ["CMD-SHELL", "curl -sf http://localhost:8123/ping"]
38+
interval: 5s
39+
timeout: 5s
40+
retries: 10
3141

3242
# ── Trino (with Iceberg + Hive Metastore + MinIO) ──────────────────
3343
trino:
@@ -37,14 +47,30 @@ services:
3747
volumes:
3848
- ./docker/trino/etc:/usr/lib/trino/etc:ro
3949
- ./docker/trino/catalog:/etc/trino/catalog
50+
depends_on:
51+
hive-metastore:
52+
condition: service_healthy
53+
trino-mc-job:
54+
condition: service_completed_successfully
55+
healthcheck:
56+
test: ["CMD-SHELL", "curl -sf http://localhost:8080/v1/info | grep -q '\"starting\":false'"]
57+
interval: 5s
58+
timeout: 5s
59+
retries: 60
60+
start_period: 10s
4061

4162
trino-metastore-db:
4263
image: postgres:11
4364
hostname: metastore_db
4465
environment:
45-
POSTGRES_USER: hive
46-
POSTGRES_PASSWORD: hive
66+
POSTGRES_USER: ${HIVE_METASTORE_USER:-hive}
67+
POSTGRES_PASSWORD: ${HIVE_METASTORE_PASSWORD:-hive}
4768
POSTGRES_DB: metastore
69+
healthcheck:
70+
test: ["CMD-SHELL", "pg_isready -U ${HIVE_METASTORE_USER:-hive}"]
71+
interval: 5s
72+
timeout: 5s
73+
retries: 10
4874

4975
hive-metastore:
5076
hostname: hive-metastore
@@ -54,12 +80,12 @@ services:
5480
environment:
5581
HIVE_METASTORE_DRIVER: org.postgresql.Driver
5682
HIVE_METASTORE_JDBC_URL: jdbc:postgresql://metastore_db:5432/metastore
57-
HIVE_METASTORE_USER: hive
58-
HIVE_METASTORE_PASSWORD: hive
83+
HIVE_METASTORE_USER: ${HIVE_METASTORE_USER:-hive}
84+
HIVE_METASTORE_PASSWORD: ${HIVE_METASTORE_PASSWORD:-hive}
5985
HIVE_METASTORE_WAREHOUSE_DIR: s3://datalake/
6086
S3_ENDPOINT: http://trino-minio:9000
61-
S3_ACCESS_KEY: minio
62-
S3_SECRET_KEY: minio123
87+
S3_ACCESS_KEY: ${TRINO_MINIO_ACCESS_KEY:-minio}
88+
S3_SECRET_KEY: ${TRINO_MINIO_SECRET_KEY:-minio123}
6389
S3_PATH_STYLE_ACCESS: "true"
6490
REGION: ""
6591
GOOGLE_CLOUD_KEY_FILE_PATH: ""
@@ -77,7 +103,16 @@ services:
77103
AZURE_WASB_ACCESS_KEY: ""
78104
HIVE_METASTORE_USERS_IN_ADMIN_ROLE: "admin"
79105
depends_on:
80-
- trino-metastore-db
106+
trino-metastore-db:
107+
condition: service_healthy
108+
trino-minio:
109+
condition: service_healthy
110+
healthcheck:
111+
test: ["CMD-SHELL", "nc -z localhost 9083"]
112+
interval: 5s
113+
timeout: 5s
114+
retries: 30
115+
start_period: 10s
81116

82117
trino-minio:
83118
hostname: minio
@@ -86,36 +121,48 @@ services:
86121
- "9002:9000"
87122
- "9003:9001"
88123
environment:
89-
MINIO_ACCESS_KEY: minio
90-
MINIO_SECRET_KEY: minio123
124+
MINIO_ACCESS_KEY: ${TRINO_MINIO_ACCESS_KEY:-minio}
125+
MINIO_SECRET_KEY: ${TRINO_MINIO_SECRET_KEY:-minio123}
91126
command: server /data --console-address ":9001"
127+
healthcheck:
128+
test: ["CMD-SHELL", "curl -sf http://localhost:9000/minio/health/live"]
129+
interval: 5s
130+
timeout: 5s
131+
retries: 10
92132

93133
trino-mc-job:
94134
image: "minio/mc:RELEASE.2022-05-09T04-08-26Z"
95135
entrypoint: |
96136
/bin/bash -c "
97-
sleep 5;
98-
/usr/bin/mc config --quiet host add myminio http://minio:9000 minio minio123;
99-
/usr/bin/mc mb --quiet myminio/datalake
137+
until /usr/bin/mc config --quiet host add myminio http://minio:9000 $${TRINO_MINIO_ACCESS_KEY:-minio} $${TRINO_MINIO_SECRET_KEY:-minio123}; do
138+
sleep 2;
139+
done;
140+
/usr/bin/mc mb --quiet --ignore-existing myminio/datalake
100141
"
101142
depends_on:
102-
- trino-minio
143+
trino-minio:
144+
condition: service_healthy
103145

104146
# ── Dremio (with Nessie + MinIO) ───────────────────────────────────
105147
nessie:
106-
image: projectnessie/nessie:latest
148+
image: projectnessie/nessie:0.80.0
107149
container_name: catalog
108150
networks:
109151
- dremio-lakehouse
110152
ports:
111153
- "19120:19120"
154+
healthcheck:
155+
test: ["CMD-SHELL", "curl -sf http://localhost:19120/api/v2/config || exit 1"]
156+
interval: 5s
157+
timeout: 5s
158+
retries: 10
112159

113160
dremio-minio:
114-
image: minio/minio:latest
161+
image: minio/minio:RELEASE.2024-01-18T22-51-28Z
115162
container_name: dremio-storage
116163
environment:
117-
- MINIO_ROOT_USER=admin
118-
- MINIO_ROOT_PASSWORD=password
164+
- MINIO_ROOT_USER=${DREMIO_MINIO_ROOT_USER:-admin}
165+
- MINIO_ROOT_PASSWORD=${DREMIO_MINIO_ROOT_PASSWORD:-password}
119166
- MINIO_DOMAIN=storage
120167
- MINIO_REGION_NAME=us-east-1
121168
- MINIO_REGION=us-east-1
@@ -127,27 +174,29 @@ services:
127174
command: ["server", "/data", "--console-address", ":9001"]
128175
volumes:
129176
- dremio-minio-data:/data
177+
healthcheck:
178+
test: ["CMD-SHELL", "curl -sf http://localhost:9000/minio/health/live"]
179+
interval: 5s
180+
timeout: 5s
181+
retries: 10
130182

131183
dremio-minio-setup:
132-
image: minio/mc
184+
image: minio/mc:RELEASE.2024-01-18T07-03-39Z
133185
container_name: dremio-minio-setup
134186
depends_on:
135-
- dremio-minio
187+
dremio-minio:
188+
condition: service_healthy
136189
entrypoint: >
137190
/bin/sh -c "
138-
until (echo > /dev/tcp/dremio-storage/9000) >/dev/null 2>&1; do
139-
echo 'Waiting for MinIO...';
140-
sleep 2;
141-
done;
142-
mc alias set myminio http://dremio-storage:9000 admin password;
143-
mc mb myminio/datalake;
191+
mc alias set myminio http://dremio-storage:9000 $${DREMIO_MINIO_ROOT_USER:-admin} $${DREMIO_MINIO_ROOT_PASSWORD:-password};
192+
mc mb --ignore-existing myminio/datalake;
144193
mc ls myminio;
145194
"
146195
networks:
147196
- dremio-lakehouse
148197

149198
dremio:
150-
image: dremio/dremio-oss:latest
199+
image: dremio/dremio-oss:25.1.0
151200
platform: linux/amd64
152201
ports:
153202
- "9047:9047"
@@ -172,11 +221,18 @@ services:
172221
start_period: 15s
173222

174223
dremio-setup:
175-
image: alpine:latest
224+
image: alpine:3.19
176225
container_name: dremio-setup
177226
depends_on:
178227
dremio:
179228
condition: service_healthy
229+
dremio-minio-setup:
230+
condition: service_completed_successfully
231+
environment:
232+
DREMIO_USER: ${DREMIO_USER:-dremio}
233+
DREMIO_PASS: ${DREMIO_PASS:-dremio123}
234+
MINIO_ROOT_USER: ${DREMIO_MINIO_ROOT_USER:-admin}
235+
MINIO_ROOT_PASSWORD: ${DREMIO_MINIO_ROOT_PASSWORD:-password}
180236
volumes:
181237
- ./docker/dremio/dremio-setup.sh:/dremio-setup.sh
182238
command: sh /dremio-setup.sh
@@ -193,7 +249,8 @@ services:
193249
- "10000:10000"
194250
- "4040:4040"
195251
depends_on:
196-
- spark-hive-metastore
252+
spark-hive-metastore:
253+
condition: service_healthy
197254
command: >
198255
--class org.apache.spark.sql.hive.thriftserver.HiveThriftServer2
199256
--name Thrift JDBC/ODBC Server
@@ -216,9 +273,14 @@ services:
216273
volumes:
217274
- spark-hive-metastore:/var/lib/postgresql/data
218275
environment:
219-
- POSTGRES_USER=dbt
220-
- POSTGRES_PASSWORD=dbt
276+
- POSTGRES_USER=${SPARK_METASTORE_USER:-dbt}
277+
- POSTGRES_PASSWORD=${SPARK_METASTORE_PASSWORD:-dbt}
221278
- POSTGRES_DB=metastore
279+
healthcheck:
280+
test: ["CMD-SHELL", "pg_isready -U ${SPARK_METASTORE_USER:-dbt}"]
281+
interval: 5s
282+
timeout: 5s
283+
retries: 10
222284

223285
networks:
224286
dremio-lakehouse:

tests/e2e_dbt_project/docker/dremio/dremio-setup.sh

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#!/bin/sh
2+
set -e
23

34
# Install required tools
45
apk add --no-cache curl jq
@@ -12,22 +13,32 @@ done
1213
echo "Dremio is up. Proceeding with configuration..."
1314

1415
# Log in to Dremio to get the auth token
16+
# Credentials are passed via environment variables from docker-compose.yml
17+
DREMIO_USER="${DREMIO_USER:-dremio}"
18+
DREMIO_PASS="${DREMIO_PASS:-dremio}"
1519
AUTH_TOKEN=$(curl -s -X POST "http://dremio:9047/apiv2/login" \
1620
-H "Content-Type: application/json" \
17-
--data "{\"userName\":\"dremio\", \"password\":\"dremio123\"}" | jq -r .token)
21+
--data "{\"userName\":\"$DREMIO_USER\", \"password\":\"$DREMIO_PASS\"}" | jq -r '.token // empty')
1822

19-
# Check if AUTH_TOKEN is not empty
20-
if [ -z "$AUTH_TOKEN" ]; then
23+
# Check if AUTH_TOKEN is not empty or null
24+
if [ -z "$AUTH_TOKEN" ] || [ "$AUTH_TOKEN" = "null" ]; then
2125
echo "Failed to obtain Dremio auth token"
2226
exit 1
2327
fi
2428

2529
echo "Obtained Dremio auth token"
2630

2731
# Create a Nessie catalog source in Dremio (used as "database" for views)
28-
curl -s -X PUT "http://dremio:9047/apiv2/source/NessieSource" \
32+
HTTP_CODE=$(curl -s -o /tmp/dremio_source_response.json -w "%{http_code}" -X PUT "http://dremio:9047/apiv2/source/NessieSource" \
2933
-H "Content-Type: application/json" \
3034
-H "Authorization: _dremio$AUTH_TOKEN" \
31-
--data "{\"name\":\"NessieSource\",\"config\":{\"nessieEndpoint\":\"http://catalog:19120/api/v2\",\"nessieAuthType\":\"NONE\",\"credentialType\":\"ACCESS_KEY\",\"awsAccessKey\":\"admin\",\"awsAccessSecret\":\"password\",\"awsRootPath\":\"datalake\",\"secure\":false,\"propertyList\":[{\"name\":\"fs.s3a.path.style.access\",\"value\":\"true\"},{\"name\":\"fs.s3a.endpoint\",\"value\":\"dremio-storage:9000\"},{\"name\":\"dremio.s3.compat\",\"value\":\"true\"}]},\"type\":\"NESSIE\",\"metadataPolicy\":{\"deleteUnavailableDatasets\":true,\"autoPromoteDatasets\":false,\"namesRefreshMillis\":3600000,\"datasetDefinitionRefreshAfterMillis\":3600000,\"datasetDefinitionExpireAfterMillis\":10800000,\"authTTLMillis\":86400000,\"updateMode\":\"PREFETCH_QUERIED\"}}"
35+
--data "{\"name\":\"NessieSource\",\"config\":{\"nessieEndpoint\":\"http://catalog:19120/api/v2\",\"nessieAuthType\":\"NONE\",\"credentialType\":\"ACCESS_KEY\",\"awsAccessKey\":\"${MINIO_ROOT_USER:-admin}\",\"awsAccessSecret\":\"${MINIO_ROOT_PASSWORD:-password}\",\"awsRootPath\":\"datalake\",\"secure\":false,\"propertyList\":[{\"name\":\"fs.s3a.path.style.access\",\"value\":\"true\"},{\"name\":\"fs.s3a.endpoint\",\"value\":\"dremio-storage:9000\"},{\"name\":\"dremio.s3.compat\",\"value\":\"true\"}]},\"type\":\"NESSIE\",\"metadataPolicy\":{\"deleteUnavailableDatasets\":true,\"autoPromoteDatasets\":false,\"namesRefreshMillis\":3600000,\"datasetDefinitionRefreshAfterMillis\":3600000,\"datasetDefinitionExpireAfterMillis\":10800000,\"authTTLMillis\":86400000,\"updateMode\":\"PREFETCH_QUERIED\"}}")
36+
37+
38+
if [ "$HTTP_CODE" -lt 200 ] || [ "$HTTP_CODE" -ge 300 ]; then
39+
echo "Failed to create Nessie Source in Dremio (HTTP $HTTP_CODE)"
40+
cat /tmp/dremio_source_response.json
41+
exit 1
42+
fi
3243

3344
echo "Nessie Source created in Dremio"

0 commit comments

Comments
 (0)