-
Notifications
You must be signed in to change notification settings - Fork 6
/
docker-compose.yaml
258 lines (245 loc) · 6.56 KB
/
docker-compose.yaml
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
services:
ui:
profiles: ["ui"]
build:
context: ./ui
target: dev
command: yarn start:local
develop:
watch:
- path: ./ui/src
action: rebuild
depends_on:
api:
condition: service_healthy
ports:
- 5173:5173
api:
build: ./api
ports:
- 9000:9000
develop:
watch:
- path: ./api/app
action: rebuild
environment:
DB_HOST: "postgres"
DB_PORT: 5432
DB_USER: "postgres"
DB_PWD: "postgres"
DB_NAME: "radicalbit"
DB_SCHEMA: "public"
AWS_ACCESS_KEY_ID: "minio"
AWS_SECRET_ACCESS_KEY: "minio123"
AWS_REGION: "us-east-1"
S3_ENDPOINT_URL: "http://minio:9000"
S3_BUCKET_NAME: "test-bucket"
KUBECONFIG_FILE_PATH: "/opt/kubeconfig/kubeconfig.yaml"
SPARK_IMAGE: "radicalbit-spark-py:develop"
depends_on:
postgres:
condition: service_healthy
migrations:
condition: service_completed_successfully
createbuckets:
condition: service_completed_successfully
k3s:
condition: service_healthy
healthcheck:
test: [ "CMD-SHELL", "curl -s http://localhost:9000/healthcheck" ]
interval: 5s
timeout: 5s
retries: 5
volumes:
- ./docker/k3s_data/kubeconfig/kubeconfig.yaml:/opt/kubeconfig/kubeconfig.yaml
migrations:
container_name: migrations
build:
context: ./api
dockerfile: ./migrations.Dockerfile
environment:
DB_HOST: "postgres"
DB_PORT: 5432
DB_USER: "postgres"
DB_PWD: "postgres"
DB_NAME: "radicalbit"
DB_SCHEMA: "public"
depends_on:
postgres:
condition: service_healthy
volumes:
- ./api/alembic:/app/alembic
- ./api/app/db/tables:/app/app/db/tables
postgres:
image: postgres:latest
container_name: postgres-container
ports:
- 5432:5432
environment:
POSTGRES_DB: radicalbit
POSTGRES_PASSWORD: postgres
volumes:
- radicalbit-data:/var/lib/postgresql/data
healthcheck:
test: [ "CMD-SHELL", "pg_isready -U postgres" ]
interval: 5s
timeout: 5s
retries: 5
adminer:
image: adminer:latest
ports:
- 8090:8080
depends_on:
postgres:
condition: service_healthy
minio:
image: minio/minio
ports:
- "9090:9000"
- "9091:9001"
volumes:
- minio_storage:/data
environment:
MINIO_ROOT_USER: minio
MINIO_ROOT_PASSWORD: minio123
command: server --console-address ":9001" /data
healthcheck:
test: timeout 5s bash -c ':> /dev/tcp/127.0.0.1/9000' || exit 1
start_period: 5s
interval: 10s
timeout: 5s
retries: 2
createbuckets:
image: minio/mc
depends_on:
minio:
condition: service_healthy
entrypoint: >
/bin/sh -c "
/usr/bin/mc alias set myminio http://minio:9000 minio minio123;
/usr/bin/mc mb myminio/test-bucket;
/usr/bin/mc policy set public myminio/test-bucket;
exit 0;
"
init-data:
profiles: [ "init-data" ]
image: postgres:latest
depends_on:
migrations:
condition: service_completed_successfully
environment:
POSTGRES_DB: radicalbit
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_SCHEMA: public
volumes:
- ./init-data/init_db.sql:/docker-entrypoint-initdb.d/init_db.sql
entrypoint: >
/bin/sh -c "
sleep 10;
PGPASSWORD=postgres PGOPTIONS="--search_path=$${POSTGRES_SCHEMA}" psql -h postgres -U postgres -d radicalbit -f /docker-entrypoint-initdb.d/init_db.sql;
"
minio-mirror:
profiles: ["init-data"]
image: minio/mc
depends_on:
minio:
condition: service_healthy
entrypoint: /bin/sh /scripts/mirror_files.sh
volumes:
- ./init-data/mirror_files.sh:/scripts/mirror_files.sh
- ./docs/quickstarts/data:/data
k3s:
image: rancher/k3s:v1.30.1-k3s1
networks:
- default
entrypoint: /bin/sh
command: "-c /opt/entrypoint/entrypoint.sh"
tmpfs:
- /run
- /var/run
ulimits:
nproc: 65535
nofile:
soft: 65535
hard: 65535
privileged: true
restart: no
environment:
K3S_KUBECONFIG_OUTPUT: /output/kubeconfig.yaml
K3S_KUBECONFIG_MODE: 666
depends_on:
docker-client:
condition: service_completed_successfully
volumes:
- k3s-server:/var/lib/rancher/k3s
# This is just so that we get the kubeconfig file out
- ./docker/k3s_data/kubeconfig:/output
# Init spark needed resources, add other custom yaml file here below if needed (e.g. secrets)
- ./docker/k3s_data/manifests/spark-init.yaml:/var/lib/rancher/k3s/server/manifests/spark-init.yaml
# Mount entrypoint
- ./docker/k3s_data/init/entrypoint.sh:/opt/entrypoint/entrypoint.sh
# Preload docker images
- ./docker/k3s_data/images:/var/lib/rancher/k3s/agent/images
expose:
- "6443" # Kubernetes API Server
- "80" # Ingress controller port 80
- "443" # Ingress controller port 443
ports:
- 6443:6443
healthcheck:
test: [ "CMD-SHELL", "netstat -tuln | grep ':6443 ' || exit 1" ]
interval: 10s
timeout: 5s
start_period: 5s
retries: 2
dind:
image: docker:dind
privileged: true
hostname: dind
environment:
DOCKER_TLS_CERTDIR: /certs
volumes:
- docker-certs-ca:/certs
- docker-certs-client:/certs/client
healthcheck:
test: nc -w 5 -z localhost 2376
start_period: 5s
interval: 10s
timeout: 5s
retries: 2
docker-client:
image: docker:cli
command: "/bin/sh -c 'docker build ./spark -t radicalbit-spark-py:develop && docker save radicalbit-spark-py:develop -o /images/radicalbit-spark-py:develop.tar'"
environment:
DOCKER_TLS_CERTDIR: /certs
DOCKER_HOST: tcp://dind:2376
depends_on:
dind:
condition: service_healthy
volumes:
- docker-certs-client:/certs/client:ro
- ./spark:/spark
- ./docker/k3s_data/images:/images
k9s:
profiles: ["k9s"]
image: quay.io/derailed/k9s:latest
stdin_open: true
tty: true
command: -A
ports:
- 4040:4040 # Spark UI port if forwarded from k9s
volumes:
- ./docker/k3s_data/kubeconfig/kubeconfig.yaml:/root/.kube/config
volumes:
k3s-server: {}
radicalbit-data: {}
minio_storage: {}
docker-certs-ca: {}
docker-certs-client: {}
networks:
default:
ipam:
driver: default
config:
- subnet: "172.98.0.0/16" # Self-defined subnet on local machine