-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdocker-compose.yaml
More file actions
340 lines (319 loc) · 12.3 KB
/
docker-compose.yaml
File metadata and controls
340 lines (319 loc) · 12.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
# Docker Compose for Local Development
# Uses local storage alternatives (Azurite for Azure Storage emulation)
#
# Prerequisites:
# 1. Create the external network first:
# docker compose -f docker-compose-network.yaml up -d
# 2. Copy .env.local to .env:
# cp .env.local .env
#
# Usage:
# docker compose up -d
# OR with explicit env file:
# docker compose --env-file .env.local up -d
#
# Services:
# - dagster-webserver: http://localhost:3001
# - spark-master-ui: http://localhost:8070
# - spark-worker-1-ui: http://localhost:8071
# - spark-worker-2-ui: http://localhost:8072
# - hive-metastore: thrift://localhost:9083
# - azurite (blob): http://localhost:10000
# - azurite (queue): http://localhost:10001
# - azurite (table): http://localhost:10002
x-common-config: &common-config
init: true
restart: unless-stopped
x-dagster-common-config: &dagster-common-config
<<: *common-config
env_file: .env
build:
context: ./dagster
dockerfile: Dockerfile
# Local build - no external registry needed
environment:
DAGSTER_HOME: ${DAGSTER_HOME}
COMMIT_SHA: ${COMMIT_SHA:-local}
DAGSTER_SENSOR_GRPC_TIMEOUT_SECONDS: ${DAGSTER_SENSOR_GRPC_TIMEOUT_SECONDS}
# PostgreSQL connection
PG_HOST: ${PG_HOST}
PG_PORT: ${PG_PORT}
# Hive Metastore connection
HIVE_METASTORE_URI: ${HIVE_METASTORE_URI}
# Spark connection
SPARK_MASTER_URL: ${SPARK_MASTER_URL}
# Local Azure Storage (Azurite) configuration
AZURE_STORAGE_ACCOUNT_NAME: ${AZURE_STORAGE_ACCOUNT_NAME}
AZURE_BLOB_CONTAINER_NAME: ${AZURE_BLOB_CONTAINER_NAME}
AZURE_STORAGE_ACCOUNT_KEY: ${AZURE_STORAGE_ACCOUNT_KEY}
AZURE_STORAGE_CONNECTION_STRING: ${AZURE_STORAGE_CONNECTION_STRING}
USE_AZURITE: ${USE_AZURITE}
volumes:
- ./dagster:/app
- ./dagster/.tmp/warehouse:/opt/spark/warehouse
- ./dagster/.venv-docker:/app/.venv
depends_on:
dagster-storage:
condition: service_healthy
azurite:
condition: service_healthy
x-spark-common-config: &spark-common-config
<<: *common-config
user: "1001:1001"
# Custom Dockerfile based on bitnami/spark:3.5.0 with Azure/Delta dependencies
build:
context: .
dockerfile: spark/Dockerfile
env_file: .env
environment:
SPARK_RPC_AUTHENTICATION_ENABLED: ${SPARK_RPC_AUTHENTICATION_ENABLED}
SPARK_RPC_ENCRYPTION_ENABLED: ${SPARK_RPC_ENCRYPTION_ENABLED}
SPARK_RPC_AUTHENTICATION_SECRET: ${SPARK_RPC_AUTHENTICATION_SECRET}
SPARK_SSL_NEED_CLIENT_AUTH: ${SPARK_SSL_NEED_CLIENT_AUTH}
# Local Azure Storage (Azurite)
AZURE_STORAGE_ACCOUNT_NAME: ${AZURE_STORAGE_ACCOUNT_NAME}
AZURE_BLOB_CONTAINER_NAME: ${AZURE_BLOB_CONTAINER_NAME}
AZURE_STORAGE_ACCOUNT_KEY: ${AZURE_STORAGE_ACCOUNT_KEY}
AZURE_STORAGE_CONNECTION_STRING: ${AZURE_STORAGE_CONNECTION_STRING}
USE_AZURITE: ${USE_AZURITE}
x-spark-worker-common-config: &spark-worker-common-config
<<: *spark-common-config
working_dir: /opt/bitnami/spark/app
volumes:
- ./dagster:/opt/bitnami/spark/app
depends_on:
- spark-master
x-spark-worker-common-env: &spark-worker-common-env
SPARK_MODE: worker
SPARK_MASTER_URL: ${SPARK_MASTER_URL}
SPARK_WORKER_HOST: 0.0.0.0
SPARK_WORKER_CORES: ${SPARK_WORKER_CORES}
SPARK_WORKER_MEMORY: ${SPARK_WORKER_MEMORY}
SPARK_PUBLIC_DNS: localhost
PYTHONPATH: /opt/bitnami/spark/app
volumes:
dagster-storage:
hms-db-storage:
azurite-data:
spark-warehouse:
networks:
default:
name: giga-dataops
external: true
services:
# =============================================================================
# LOCAL STORAGE (Azurite - Azure Storage Emulator)
# =============================================================================
azurite:
<<: *common-config
image: mcr.microsoft.com/azure-storage/azurite:3.29.0
hostname: ${AZURE_STORAGE_ACCOUNT_NAME}.blob.core.windows.net
# Use port 80 for blob service so wasb:// (HTTP) protocol works with Hadoop
command: "azurite --blobHost 0.0.0.0 --blobPort 80 --queueHost 0.0.0.0 --tableHost 0.0.0.0 --loose --skipApiVersionCheck"
volumes:
- azurite-data:/data
ports:
- "10000:80" # Blob service (internal 80 for wasb://, exposed as 10000)
- "10001:10001" # Queue service
- "10002:10002" # Table service
healthcheck:
test: ["CMD", "nc", "-z", "127.0.0.1", "80"]
interval: 10s
timeout: 5s
retries: 5
start_period: 10s
networks:
default:
aliases:
- ${AZURE_STORAGE_ACCOUNT_NAME}.blob.core.windows.net
# Initialize Azurite container on startup
azurite-init:
image: mcr.microsoft.com/azure-cli:2.57.0
depends_on:
azurite:
condition: service_healthy
environment:
AZURE_STORAGE_CONNECTION_STRING: ${AZURE_STORAGE_CONNECTION_STRING}
AZURE_BLOB_CONTAINER_NAME: ${AZURE_BLOB_CONTAINER_NAME}
AZURE_DELTA_LAKE_CONTAINER_NAME: ${AZURE_DELTA_LAKE_CONTAINER_NAME}
entrypoint: ["/bin/sh", "-c"]
command:
- |
echo "Creating blob container..."
az storage container create --name $$AZURE_BLOB_CONTAINER_NAME --connection-string "$$AZURE_STORAGE_CONNECTION_STRING" || true
az storage container create --name $$AZURE_DELTA_LAKE_CONTAINER_NAME --connection-string "$$AZURE_STORAGE_CONNECTION_STRING" || true
echo "Blob containers created successfully"
restart: "no"
# =============================================================================
# DAGSTER SERVICES
# =============================================================================
dagster-storage:
<<: *common-config
image: public.ecr.aws/bitnami/postgresql:14.10.0-debian-11-r31
env_file: .env
environment:
POSTGRESQL_USERNAME: ${POSTGRESQL_USERNAME}
POSTGRESQL_PASSWORD: ${POSTGRESQL_PASSWORD}
POSTGRESQL_DATABASE: ${POSTGRESQL_DATABASE}
POSTGRESQL_PGAUDIT_LOG: "NONE"
volumes:
- dagster-storage:/bitnami/postgresql
ports:
- "5433:5432"
healthcheck:
test: ["CMD", "pg_isready", "-U", "${POSTGRESQL_USERNAME}"]
interval: 10s
timeout: 5s
retries: 5
start_period: 10s
dagster-webserver:
<<: *dagster-common-config
command: ["./docker-entrypoint.dev.sh"]
ports:
- "3001:3002"
- "5678:5678" # Debug port
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:3002/server_info"]
interval: 30s
timeout: 10s
retries: 3
start_period: 60s
dagster-daemon:
<<: *dagster-common-config
command: ["bash", "-c", "poetry install --with dev,dagster,pipelines,spark && poetry run dagster-daemon run"]
environment:
DAGSTER_HOME: ${DAGSTER_HOME}
COMMIT_SHA: ${COMMIT_SHA:-local}
DAGSTER_SENSOR_GRPC_TIMEOUT_SECONDS: ${DAGSTER_SENSOR_GRPC_TIMEOUT_SECONDS}
PG_HOST: ${PG_HOST}
PG_PORT: ${PG_PORT}
HIVE_METASTORE_URI: ${HIVE_METASTORE_URI}
SPARK_MASTER_URL: ${SPARK_MASTER_URL}
DAGSTER_DAEMON_HEARTBEAT_TOLERANCE: ${DAGSTER_DAEMON_HEARTBEAT_TOLERANCE}
# Local Azure Storage (Azurite)
AZURE_STORAGE_ACCOUNT_NAME: ${AZURE_STORAGE_ACCOUNT_NAME}
AZURE_BLOB_CONTAINER_NAME: ${AZURE_BLOB_CONTAINER_NAME}
AZURE_STORAGE_CONNECTION_STRING: ${AZURE_STORAGE_CONNECTION_STRING}
# =============================================================================
# SPARK SERVICES
# =============================================================================
spark-master:
<<: *spark-common-config
environment:
SPARK_MODE: master
SPARK_MASTER_HOST: 0.0.0.0
SPARK_MASTER_PORT: 7077
SPARK_MASTER_WEBUI_PORT: 8070
SPARK_PUBLIC_DNS: localhost
THRIFT_PORT: 10000
SPARK_RPC_AUTHENTICATION_ENABLED: ${SPARK_RPC_AUTHENTICATION_ENABLED}
SPARK_RPC_ENCRYPTION_ENABLED: ${SPARK_RPC_ENCRYPTION_ENABLED}
SPARK_RPC_AUTHENTICATION_SECRET: ${SPARK_RPC_AUTHENTICATION_SECRET}
# Local Azure Storage (Azurite)
AZURE_STORAGE_ACCOUNT_NAME: ${AZURE_STORAGE_ACCOUNT_NAME}
AZURE_BLOB_CONTAINER_NAME: ${AZURE_BLOB_CONTAINER_NAME}
AZURE_STORAGE_CONNECTION_STRING: ${AZURE_STORAGE_CONNECTION_STRING}
volumes:
- spark-warehouse:/opt/spark/warehouse
ports:
- "7077:7077" # Spark master
- "8070:8070" # Spark master UI
- "4040:4040" # Spark driver UI
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:8070"]
interval: 30s
timeout: 10s
retries: 3
start_period: 30s
depends_on:
azurite:
condition: service_healthy
spark-worker-1:
<<: [*spark-common-config, *spark-worker-common-config]
environment:
<<: *spark-worker-common-env
SPARK_WORKER_WEBUI_PORT: 8071
SPARK_RPC_AUTHENTICATION_ENABLED: ${SPARK_RPC_AUTHENTICATION_ENABLED}
SPARK_RPC_ENCRYPTION_ENABLED: ${SPARK_RPC_ENCRYPTION_ENABLED}
SPARK_RPC_AUTHENTICATION_SECRET: ${SPARK_RPC_AUTHENTICATION_SECRET}
# Local Azure Storage (Azurite)
AZURE_STORAGE_ACCOUNT_NAME: ${AZURE_STORAGE_ACCOUNT_NAME}
AZURE_BLOB_CONTAINER_NAME: ${AZURE_BLOB_CONTAINER_NAME}
AZURE_STORAGE_CONNECTION_STRING: ${AZURE_STORAGE_CONNECTION_STRING}
ports:
- "8071:8071"
spark-worker-2:
<<: [*spark-common-config, *spark-worker-common-config]
environment:
<<: *spark-worker-common-env
SPARK_WORKER_WEBUI_PORT: 8072
SPARK_RPC_AUTHENTICATION_ENABLED: ${SPARK_RPC_AUTHENTICATION_ENABLED}
SPARK_RPC_ENCRYPTION_ENABLED: ${SPARK_RPC_ENCRYPTION_ENABLED}
SPARK_RPC_AUTHENTICATION_SECRET: ${SPARK_RPC_AUTHENTICATION_SECRET}
# Local Azure Storage (Azurite)
AZURE_STORAGE_ACCOUNT_NAME: ${AZURE_STORAGE_ACCOUNT_NAME}
AZURE_BLOB_CONTAINER_NAME: ${AZURE_BLOB_CONTAINER_NAME}
AZURE_STORAGE_CONNECTION_STRING: ${AZURE_STORAGE_CONNECTION_STRING}
ports:
- "8072:8072"
# =============================================================================
# HIVE METASTORE SERVICES
# =============================================================================
hms-database:
<<: *common-config
image: public.ecr.aws/bitnami/postgresql:14.10.0-debian-11-r31
env_file: .env
environment:
POSTGRESQL_USERNAME: ${HMS_POSTGRESQL_USERNAME}
POSTGRESQL_PASSWORD: ${HMS_POSTGRESQL_PASSWORD}
POSTGRESQL_DATABASE: ${HMS_POSTGRESQL_DATABASE}
POSTGRESQL_PGAUDIT_LOG: "NONE"
POSTGRESQL_INITSCRIPTS_USERNAME: ${HMS_POSTGRESQL_USERNAME}
POSTGRESQL_INITSCRIPTS_PASSWORD: ${HMS_POSTGRESQL_PASSWORD}
POSTGRESQL_PG_HBA_CONF: |
# TYPE DATABASE USER ADDRESS METHOD
local all all trust
host all all 127.0.0.1/32 md5
host all all ::1/128 md5
host all all 0.0.0.0/0 md5
volumes:
- hms-db-storage:/bitnami/postgresql
ports:
- "5434:5432"
healthcheck:
test: ["CMD", "pg_isready", "-U", "${HMS_POSTGRESQL_USERNAME}"]
timeout: 3s
start_period: 5s
retries: 5
hive-metastore:
<<: *common-config
build:
context: ./hive
dockerfile: Dockerfile
env_file: .env
environment:
DB_DRIVER: postgres
SERVICE_NAME: metastore
METASTORE_HOME: /opt/hive
HMS_DATABASE_URL: jdbc:postgresql://hms-database:5432/${HMS_POSTGRESQL_DATABASE}
HMS_POSTGRESQL_USERNAME: ${HMS_POSTGRESQL_USERNAME}
HMS_POSTGRESQL_PASSWORD: ${HMS_POSTGRESQL_PASSWORD}
# Local development - use local file path for warehouse (simpler than wasbs with Azurite)
STORAGE_ACCOUNT_NAME: ${STORAGE_ACCOUNT_NAME}
STORAGE_CONTAINER_NAME: ${STORAGE_CONTAINER_NAME}
AZURE_STORAGE_ACCOUNT_KEY: ${AZURE_STORAGE_ACCOUNT_KEY}
AZURE_SAS_TOKEN: ${AZURE_SAS_TOKEN}
# Use wasb:// (HTTP) for warehouse - wasbs:// (HTTPS) times out with Azurite
METASTORE_WAREHOUSE_DIR: ${METASTORE_WAREHOUSE_DIR}
volumes:
- ./hive/hive-site.template.xml:/opt/hive/tpl/hive-site.template.xml
- ./hive/metastore-site.local.template.xml:/opt/hive/tpl/metastore-site.template.xml
- ./hive/hms-entrypoint.sh:/opt/hive/bin/hms-entrypoint.sh
- spark-warehouse:/opt/spark/warehouse
ports:
- "9083:9083"
depends_on:
hms-database:
condition: service_healthy
azurite:
condition: service_healthy