-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocker-compose.yml
More file actions
1580 lines (1345 loc) · 46.4 KB
/
docker-compose.yml
File metadata and controls
1580 lines (1345 loc) · 46.4 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
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
# VoIP Development Services - Colima (Apple Silicon)
# Git server, local dev databases, caching, message queue
#
# ARCHITECTURE:
# - PostgreSQL: For Forgejo (Git) and local development ONLY
# - Other services: Redis, RabbitMQ, MongoDB for local dev/testing
# - libvirt VMs have their own PostgreSQL for VoIP services
#
# Run on Apple Silicon Mac with Colima:
# colima start --cpu 4 --memory 8 --disk 60 --network-address
# docker compose up -d
x-logging: &default-logging
driver: "json-file"
options:
max-size: "10m"
max-file: "3"
x-platform: &default-platform
platform: linux/arm64
# =============================================================================
# Shared Init Library Volume Mount
# =============================================================================
# All services using Vault AppRole mount this library for common init functions
x-init-library: &init-library
./scripts/lib:/scripts/lib:ro
# =============================================================================
# Redis Common Configuration (DRY - Don't Repeat Yourself)
# =============================================================================
x-redis-common: &redis-common
<<: *default-platform
image: redis:${REDIS_VERSION:-7.4-alpine3.21}
restart: unless-stopped
entrypoint: ["/init/init-approle.sh"]
environment: &redis-env
VAULT_ADDR: ${VAULT_ADDR:-http://vault:8200}
VAULT_APPROLE_DIR: /vault-approles/redis
REDIS_ENABLE_TLS: ${REDIS_ENABLE_TLS:-false}
command:
- "/usr/local/etc/redis/redis.conf"
- "--port"
- "6379"
- "--cluster-enabled"
- "yes"
- "--cluster-config-file"
- "nodes.conf"
- "--cluster-node-timeout"
- "5000"
- "--appendonly"
- "${REDIS_APPENDONLY:-yes}"
- "--maxmemory"
- "${REDIS_MAXMEMORY:-256mb}"
- "--maxmemory-policy"
- "${REDIS_MAXMEMORY_POLICY:-allkeys-lru}"
healthcheck:
test: ["CMD", "timeout", "1", "redis-cli", "ping"]
interval: ${REDIS_HEALTH_INTERVAL:-60s}
timeout: ${REDIS_HEALTH_TIMEOUT:-5s}
retries: ${REDIS_HEALTH_RETRIES:-5}
start_period: 10s
logging: *default-logging
deploy:
resources:
limits:
cpus: '1'
memory: 512M
reservations:
cpus: '0.25'
memory: 256M
# =============================================================================
# Redis Exporter Common Configuration
# =============================================================================
x-redis-exporter-common: &redis-exporter-common
<<: *default-platform
image: oliver006/redis_exporter:${REDIS_EXPORTER_VERSION:-v1.55.0}
restart: unless-stopped
entrypoint: ["/init/init.sh"]
environment: &redis-exporter-env
VAULT_ADDR: ${VAULT_ADDR:-http://vault:8200}
VAULT_APPROLE_DIR: /vault-approles/redis-exporter
volumes:
- ./configs/exporters/redis/init.sh:/init/init.sh:ro
- ${HOME}/.config/vault/approles/redis-exporter:/vault-approles/redis-exporter:ro
healthcheck:
test: ["CMD", "wget", "--spider", "-Y", "off", "http://localhost:9121/metrics"]
interval: 30s
timeout: 10s
retries: 3
logging: *default-logging
deploy:
resources:
limits:
cpus: '0.25'
memory: 128M
reservations:
cpus: '0.05'
memory: 64M
labels:
- "com.voip.service=redis-exporter"
- "com.voip.platform=colima"
networks:
# Segmented Network Architecture for Security Hardening
# Each tier has its own network for logical isolation
# Infrastructure tier - Vault secrets management (all services connect here)
vault-network:
driver: bridge
ipam:
config:
- subnet: 172.20.1.0/24
gateway: 172.20.1.1
driver_opts:
com.docker.network.bridge.name: br-vault
# Data tier - Databases, cache, message queue
data-network:
driver: bridge
ipam:
config:
- subnet: 172.20.2.0/24
gateway: 172.20.2.1
driver_opts:
com.docker.network.bridge.name: br-data
# Application tier - Forgejo, reference APIs, proxy services
app-network:
driver: bridge
ipam:
config:
- subnet: 172.20.3.0/24
gateway: 172.20.3.1
driver_opts:
com.docker.network.bridge.name: br-app
# Observability tier - Metrics, logs, visualization
observability-network:
driver: bridge
ipam:
config:
- subnet: 172.20.4.0/24
gateway: 172.20.4.1
driver_opts:
com.docker.network.bridge.name: br-obs
volumes:
postgres_data:
mysql_data:
redis_1_data:
redis_2_data:
redis_3_data:
rabbitmq_data:
mongodb_data:
forgejo_data:
vault_data:
prometheus_data:
grafana_data:
loki_data:
services:
# ===========================================================================
# POSTGRESQL - Git Storage & Local Development ONLY
# ===========================================================================
# This PostgreSQL instance is for:
# 1. Forgejo (Git server) - primary use case
# 2. Local development and testing
#
# NOT for production VoIP services - they use libvirt VM PostgreSQL
#
# VAULT INTEGRATION:
# - Credentials fetched from Vault at startup
# - Optional TLS with Vault-issued certificates (POSTGRES_ENABLE_TLS=true)
# - Wrapper script handles Vault authentication and cert management
# ===========================================================================
postgres:
<<: *default-platform
image: postgres:${POSTGRES_VERSION:-18}
container_name: dev-postgres
restart: unless-stopped
# PROFILE: Available in minimal, standard, and full profiles
# Core database for Forgejo (Git server) and local development
profiles: ["minimal", "standard", "full"]
entrypoint: ["/init/init-approle.sh"]
environment:
# Vault configuration (AppRole authentication)
VAULT_ADDR: ${VAULT_ADDR:-http://vault:8200}
VAULT_APPROLE_DIR: /vault-approles/postgres
POSTGRES_ENABLE_TLS: ${POSTGRES_ENABLE_TLS:-false}
POSTGRES_IP: ${POSTGRES_IP:-172.20.0.10}
# PostgreSQL user/db (used for healthchecks, actual credentials from Vault)
POSTGRES_USER: ${POSTGRES_USER:-dev_admin}
POSTGRES_DB: ${POSTGRES_DB:-dev_database}
# PostgreSQL initdb arguments (required for database initialization)
POSTGRES_INITDB_ARGS: "--encoding=UTF8 --locale=C"
# NOTE: POSTGRES_PASSWORD is fetched from Vault via AppRole authentication
ports:
- "${POSTGRES_HOST_PORT:-5432}:5432"
volumes:
- postgres_data:/var/lib/postgresql
- ./configs/postgres:/docker-entrypoint-initdb.d:ro
- ./configs/postgres/scripts/init-approle.sh:/init/init-approle.sh:ro
- *init-library
- ${HOME}/.config/vault/certs/postgres:/var/lib/postgresql/certs:ro
- ${HOME}/.config/vault/approles/postgres:/vault-approles/postgres:ro
networks:
vault-network: # Connect to Vault for AppRole auth
data-network: # Primary network for data tier
ipv4_address: 172.20.2.10
depends_on:
vault:
condition: service_healthy
command:
- "postgres"
- "-c"
- "max_connections=${POSTGRES_MAX_CONNECTIONS:-100}"
- "-c"
- "shared_buffers=${POSTGRES_SHARED_BUFFERS:-256MB}"
- "-c"
- "effective_cache_size=${POSTGRES_EFFECTIVE_CACHE_SIZE:-1GB}"
- "-c"
- "work_mem=${POSTGRES_WORK_MEM:-8MB}"
- "-c"
- "maintenance_work_mem=${POSTGRES_MAINTENANCE_WORK_MEM:-64MB}"
- "-c"
- "synchronous_commit=${POSTGRES_SYNCHRONOUS_COMMIT:-on}"
- "-c"
- "wal_buffers=${POSTGRES_WAL_BUFFERS:-4MB}"
healthcheck:
test: ["CMD-SHELL", "pg_isready -U ${POSTGRES_USER:-dev_admin}"]
interval: ${POSTGRES_HEALTH_INTERVAL:-60s}
timeout: ${POSTGRES_HEALTH_TIMEOUT:-5s}
retries: ${POSTGRES_HEALTH_RETRIES:-5}
start_period: ${POSTGRES_HEALTH_START_PERIOD:-30s}
logging: *default-logging
deploy:
resources:
limits:
cpus: '2'
memory: 2G
reservations:
cpus: '0.5'
memory: 512M
labels:
- "com.voip.service=dev-database"
- "com.voip.platform=colima"
- "com.voip.purpose=git-and-local-dev"
# ===========================================================================
# PGBOUNCER - Connection Pooling for Git/Dev
# ===========================================================================
pgbouncer:
<<: *default-platform
build:
context: ./configs/pgbouncer
args:
PGBOUNCER_VERSION: ${PGBOUNCER_VERSION:-latest}
container_name: dev-pgbouncer
restart: unless-stopped
# PROFILE: Available in minimal, standard, and full profiles
# Connection pooling for PostgreSQL (recommended for all scenarios)
profiles: ["minimal", "standard", "full"]
entrypoint: ["/usr/local/bin/init.sh"]
environment:
VAULT_ADDR: ${VAULT_ADDR:-http://vault:8200}
VAULT_APPROLE_DIR: /vault-approles/pgbouncer
POSTGRES_HOST: postgres
POSTGRES_PORT: 5432
POSTGRES_DB: ${POSTGRES_DB:-dev_database}
AUTH_TYPE: scram-sha-256
POOL_MODE: transaction
MAX_CLIENT_CONN: 100
DEFAULT_POOL_SIZE: 10
volumes:
- ${HOME}/.config/vault/approles/pgbouncer:/vault-approles/pgbouncer:ro
ports:
- "${PGBOUNCER_HOST_PORT:-6432}:5432"
networks:
vault-network: # Connect to Vault for AppRole auth
data-network: # Connect to PostgreSQL
ipv4_address: 172.20.2.11
app-network: # Accept connections from apps
depends_on:
postgres:
condition: service_healthy
healthcheck:
test: ["CMD-SHELL", "PGPASSFILE=/var/lib/postgresql/.pgpass psql -h localhost -U devuser -d devdb -c 'SELECT 1' || exit 1"]
interval: 60s
timeout: 10s
retries: 5
start_period: 30s
logging: *default-logging
deploy:
resources:
limits:
cpus: '0.5'
memory: 256M
reservations:
cpus: '0.1'
memory: 128M
# ===========================================================================
# MYSQL - Legacy Database for Local Development
# ===========================================================================
# VAULT INTEGRATION:
# - Credentials fetched from Vault at startup
# - Optional TLS with Vault-issued certificates (MYSQL_ENABLE_TLS=true)
# - Wrapper script handles Vault authentication and cert management
# ===========================================================================
mysql:
<<: *default-platform
image: mysql:${MYSQL_VERSION:-8.0.40}
container_name: dev-mysql
restart: unless-stopped
# PROFILE: Available in standard and full profiles only
# Legacy database support for multi-database applications
profiles: ["standard", "full"]
entrypoint: ["/init/init-approle.sh"]
environment:
# Vault configuration (AppRole authentication)
VAULT_ADDR: ${VAULT_ADDR:-http://vault:8200}
VAULT_APPROLE_DIR: /vault-approles/mysql
MYSQL_ENABLE_TLS: ${MYSQL_ENABLE_TLS:-false}
MYSQL_IP: ${MYSQL_IP:-172.20.0.12}
# MySQL user/db (used for healthchecks, actual credentials from Vault)
MYSQL_USER: ${MYSQL_USER:-dev_admin}
MYSQL_DATABASE: ${MYSQL_DATABASE:-dev_database}
# NOTE: MYSQL_ROOT_PASSWORD and MYSQL_PASSWORD are fetched from Vault via AppRole
ports:
- "${MYSQL_HOST_PORT:-3306}:3306"
volumes:
- mysql_data:/var/lib/mysql
- ./configs/mysql:/docker-entrypoint-initdb.d:ro
- ./configs/mysql/scripts/init-approle.sh:/init/init-approle.sh:ro
- *init-library
- ${HOME}/.config/vault/approles/mysql:/vault-approles/mysql:ro
- ${HOME}/.config/vault/certs/mysql:/var/lib/mysql-certs:ro
networks:
vault-network: # Connect to Vault for AppRole auth
data-network: # Primary network for data tier
ipv4_address: 172.20.2.12
depends_on:
vault:
condition: service_healthy
command:
- "mysqld"
- "--character-set-server=utf8mb4"
- "--collation-server=utf8mb4_unicode_ci"
- "--max-connections=${MYSQL_MAX_CONNECTIONS:-100}"
- "--innodb-buffer-pool-size=${MYSQL_INNODB_BUFFER_POOL:-256M}"
- "--innodb-log-file-size=${MYSQL_INNODB_LOG_FILE_SIZE:-48M}"
- "--innodb-flush-log-at-trx-commit=${MYSQL_INNODB_FLUSH_LOG_AT_TRX_COMMIT:-1}"
- "--innodb-flush-method=${MYSQL_INNODB_FLUSH_METHOD:-fsync}"
healthcheck:
test: ["CMD", "mysqladmin", "ping", "-h", "localhost"]
interval: ${MYSQL_HEALTH_INTERVAL:-60s}
timeout: ${MYSQL_HEALTH_TIMEOUT:-5s}
retries: ${MYSQL_HEALTH_RETRIES:-5}
logging: *default-logging
deploy:
resources:
limits:
cpus: '2'
memory: 2G
reservations:
cpus: '0.5'
memory: 512M
labels:
- "com.voip.purpose=local-dev-mysql"
# ===========================================================================
# REDIS CLUSTER - Cache & Session Storage (Local Dev)
# ===========================================================================
# 3-node Redis cluster for high availability and horizontal scaling
# All nodes are masters (no replicas in dev environment)
# Uses x-redis-common anchor for DRY configuration
#
# VAULT INTEGRATION:
# - Password fetched from Vault at startup (shared across all nodes)
# - Optional TLS with Vault-issued certificates (REDIS_ENABLE_TLS=true)
# - Wrapper script handles Vault authentication and cert management
# ===========================================================================
redis-1:
<<: *redis-common
container_name: dev-redis-1
# PROFILE: Available in minimal (standalone), standard (cluster), and full profiles
profiles: ["minimal", "standard", "full"]
environment:
<<: *redis-env
REDIS_NODE: redis-1
REDIS_IP: ${REDIS_1_IP:-172.20.2.13}
ports:
- "${REDIS_1_HOST_PORT:-6379}:6379"
- "${REDIS_1_TLS_PORT:-6390}:6380"
- "${REDIS_1_CLUSTER_PORT:-16379}:16379"
volumes:
- redis_1_data:/data
- ./configs/redis/redis-cluster.conf:/usr/local/etc/redis/redis.conf:ro
- ./configs/redis/scripts/init-approle.sh:/init/init-approle.sh:ro
- *init-library
- ${HOME}/.config/vault/approles/redis:/vault-approles/redis:ro
- ${HOME}/.config/vault/certs/redis-1:/etc/redis/certs:ro
networks:
vault-network:
data-network:
ipv4_address: 172.20.2.13
depends_on:
vault:
condition: service_healthy
labels:
- "com.voip.service=redis-cluster"
- "com.voip.cluster.node=1"
redis-2:
<<: *redis-common
container_name: dev-redis-2
# PROFILE: Available in standard and full profiles only (cluster node 2)
profiles: ["standard", "full"]
environment:
<<: *redis-env
REDIS_NODE: redis-2
REDIS_IP: ${REDIS_2_IP:-172.20.2.16}
ports:
- "${REDIS_2_HOST_PORT:-6380}:6379"
- "${REDIS_2_TLS_PORT:-6391}:6380"
- "${REDIS_2_CLUSTER_PORT:-16380}:16379"
volumes:
- redis_2_data:/data
- ./configs/redis/redis-cluster.conf:/usr/local/etc/redis/redis.conf:ro
- ./configs/redis/scripts/init-approle.sh:/init/init-approle.sh:ro
- *init-library
- ${HOME}/.config/vault/approles/redis:/vault-approles/redis:ro
- ${HOME}/.config/vault/certs/redis-2:/etc/redis/certs:ro
networks:
vault-network:
data-network:
ipv4_address: 172.20.2.16
depends_on:
vault:
condition: service_healthy
labels:
- "com.voip.service=redis-cluster"
- "com.voip.cluster.node=2"
redis-3:
<<: *redis-common
container_name: dev-redis-3
# PROFILE: Available in standard and full profiles only (cluster node 3)
profiles: ["standard", "full"]
environment:
<<: *redis-env
REDIS_NODE: redis-3
REDIS_IP: ${REDIS_3_IP:-172.20.2.17}
ports:
- "${REDIS_3_HOST_PORT:-6381}:6379"
- "${REDIS_3_TLS_PORT:-6392}:6380"
- "${REDIS_3_CLUSTER_PORT:-16381}:16379"
volumes:
- redis_3_data:/data
- ./configs/redis/redis-cluster.conf:/usr/local/etc/redis/redis.conf:ro
- ./configs/redis/scripts/init-approle.sh:/init/init-approle.sh:ro
- *init-library
- ${HOME}/.config/vault/approles/redis:/vault-approles/redis:ro
- ${HOME}/.config/vault/certs/redis-3:/etc/redis/certs:ro
networks:
vault-network:
data-network:
ipv4_address: 172.20.2.17
depends_on:
vault:
condition: service_healthy
labels:
- "com.voip.service=redis-cluster"
- "com.voip.cluster.node=3"
# ===========================================================================
# RABBITMQ - Message Queue (Local Dev)
# ===========================================================================
# VAULT INTEGRATION:
# - Credentials fetched from Vault at startup
# - Optional TLS with Vault-issued certificates (RABBITMQ_ENABLE_TLS=true)
# - Wrapper script handles Vault authentication and cert management
# ===========================================================================
rabbitmq:
<<: *default-platform
image: rabbitmq:${RABBITMQ_VERSION:-3.13-management-alpine}
container_name: dev-rabbitmq
restart: unless-stopped
# PROFILE: Available in standard and full profiles only
# Message queue for asynchronous communication between services
profiles: ["standard", "full"]
entrypoint: ["/init/init-approle.sh"]
environment:
VAULT_ADDR: ${VAULT_ADDR:-http://vault:8200}
VAULT_APPROLE_DIR: /vault-approles/rabbitmq
RABBITMQ_ENABLE_TLS: ${RABBITMQ_ENABLE_TLS:-false}
RABBITMQ_IP: ${RABBITMQ_IP:-172.20.2.14}
RABBITMQ_VHOST: ${RABBITMQ_VHOST:-dev_vhost}
ports:
- "${RABBITMQ_AMQP_PORT:-5672}:5672" # AMQP
- "${RABBITMQ_AMQPS_PORT:-5671}:5671" # AMQPS (TLS)
- "${RABBITMQ_MGMT_PORT:-15672}:15672" # Management UI
volumes:
- rabbitmq_data:/var/lib/rabbitmq
- ./configs/rabbitmq/scripts/init-approle.sh:/init/init-approle.sh:ro
- *init-library
- ${HOME}/.config/vault/approles/rabbitmq:/vault-approles/rabbitmq:ro
- ${HOME}/.config/vault/certs/rabbitmq:/etc/rabbitmq/certs:ro
networks:
vault-network:
data-network:
ipv4_address: 172.20.2.14
depends_on:
vault:
condition: service_healthy
command: ["rabbitmq-server"]
healthcheck:
test: rabbitmq-diagnostics -q ping
interval: ${RABBITMQ_HEALTH_INTERVAL:-60s}
timeout: ${RABBITMQ_HEALTH_TIMEOUT:-10s}
retries: ${RABBITMQ_HEALTH_RETRIES:-5}
start_period: 30s
logging: *default-logging
deploy:
resources:
limits:
cpus: '1'
memory: 1G
reservations:
cpus: '0.5'
memory: 512M
# ===========================================================================
# MONGODB - NoSQL Database (Local Dev)
# ===========================================================================
mongodb:
<<: *default-platform
image: mongo:${MONGODB_VERSION:-7.0}
container_name: dev-mongodb
restart: unless-stopped
# PROFILE: Available in standard and full profiles only
# NoSQL document database for unstructured data
profiles: ["standard", "full"]
# Vault Integration: Credentials are fetched from Vault via AppRole at startup
entrypoint: ["/init/init-approle.sh"]
command:
- "mongod"
- "--wiredTigerCacheSizeGB=${MONGODB_WIRED_TIGER_CACHE_SIZE:-0.5}"
- "--wiredTigerJournalCompressor=zstd"
- "--journalCommitInterval=${MONGODB_JOURNAL_COMMIT_INTERVAL:-100}"
environment:
VAULT_ADDR: ${VAULT_ADDR:-http://vault:8200}
VAULT_APPROLE_DIR: /vault-approles/mongodb
MONGODB_IP: ${MONGODB_IP:-172.20.2.15}
MONGODB_ENABLE_TLS: ${MONGODB_ENABLE_TLS:-false}
ports:
- "27017:27017"
volumes:
- mongodb_data:/data/db
- ./configs/mongodb/scripts/init-approle.sh:/init/init-approle.sh:ro
- *init-library
- ${HOME}/.config/vault/approles/mongodb:/vault-approles/mongodb:ro
- ${HOME}/.config/vault/certs/mongodb:/etc/mongodb/certs:ro
networks:
vault-network:
data-network:
ipv4_address: 172.20.2.15
depends_on:
vault:
condition: service_healthy
healthcheck:
test: ["CMD", "mongosh", "--eval", "db.adminCommand('ping')", "--quiet"]
interval: ${MONGODB_HEALTH_INTERVAL:-60s}
timeout: ${MONGODB_HEALTH_TIMEOUT:-5s}
retries: ${MONGODB_HEALTH_RETRIES:-5}
start_period: 30s
logging: *default-logging
deploy:
resources:
limits:
cpus: '2'
memory: 2G
reservations:
cpus: '0.5'
memory: 512M
# ===========================================================================
# FORGEJO - Self-Hosted Git Server
# ===========================================================================
# Forgejo uses the local PostgreSQL instance for git repository storage
# ===========================================================================
forgejo:
<<: *default-platform
build:
context: ./configs/forgejo
args:
FORGEJO_VERSION: ${FORGEJO_VERSION:-1.21.11-0}
container_name: dev-forgejo
restart: unless-stopped
# PROFILE: Available in minimal, standard, and full profiles
# Self-hosted Git server with Forgejo
profiles: ["minimal", "standard", "full"]
environment:
# Vault configuration (AppRole authentication)
VAULT_ADDR: ${VAULT_ADDR:-http://vault:8200}
VAULT_APPROLE_DIR: /vault-approles/forgejo
USER_UID: 1000
USER_GID: 1000
FORGEJO__database__DB_TYPE: postgres
FORGEJO__database__HOST: postgres:5432
FORGEJO__database__NAME: forgejo
FORGEJO__server__DOMAIN: ${FORGEJO_DOMAIN:-localhost}
FORGEJO__server__ROOT_URL: http://${FORGEJO_DOMAIN:-localhost}:3000/
FORGEJO__metrics__ENABLED: true
FORGEJO__metrics__ENABLED_ISSUE_BY_LABEL: false
FORGEJO__metrics__ENABLED_ISSUE_BY_REPOSITORY: false
ports:
- "3000:3000" # HTTP
- "2222:22" # SSH
volumes:
- forgejo_data:/data
- ${HOME}/.config/vault/approles/forgejo:/vault-approles/forgejo:ro
- /etc/timezone:/etc/timezone:ro
- /etc/localtime:/etc/localtime:ro
networks:
vault-network: # Connect to Vault for AppRole auth
data-network: # Connect to PostgreSQL database
app-network: # Primary network for app tier
ipv4_address: 172.20.3.20
depends_on:
postgres:
condition: service_healthy
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:3000/api/healthz"]
interval: 60s
timeout: 10s
retries: 5
logging: *default-logging
deploy:
resources:
limits:
cpus: '2'
memory: 2G
reservations:
cpus: '0.5'
memory: 512M
labels:
- "com.voip.service=git-server"
- "com.voip.platform=colima"
# ===========================================================================
# HASHICORP VAULT - Secrets Management
# ===========================================================================
# Vault uses file storage backend for persistence
# Unseal keys stored in ~/.config/vault/
# ===========================================================================
vault:
<<: *default-platform
image: hashicorp/vault:${VAULT_VERSION:-1.18}
container_name: dev-vault
restart: unless-stopped
# PROFILE: NO PROFILE - Always starts (required for all profiles)
# Secrets management and PKI infrastructure
environment:
VAULT_ADDR: http://127.0.0.1:8200
VAULT_API_ADDR: http://127.0.0.1:8200
VAULT_KEYS_FILE: /vault-keys/keys.json
SKIP_CHOWN: "true"
ports:
- "8200:8200"
volumes:
- vault_data:/vault/data
- ./configs/vault:/vault/config:ro
- ./configs/vault/scripts/vault-auto-unseal.sh:/usr/local/bin/vault-auto-unseal.sh:ro
- ${HOME}/.config/vault:/vault-keys:ro
networks:
vault-network: # Primary network - all services connect here
ipv4_address: 172.20.1.5
# IPC_LOCK capability allows Vault to lock memory pages, preventing sensitive data
# (encryption keys, secrets) from being swapped to disk. This is critical for security
# as it ensures secrets remain in RAM and cannot be recovered from swap files.
# Reference: https://developer.hashicorp.com/vault/docs/configuration#disable_mlock
cap_add:
- IPC_LOCK
entrypoint: >
sh -c "
chown -R vault:vault /vault/data &&
docker-entrypoint.sh server &
/usr/local/bin/vault-auto-unseal.sh &
wait -n
"
healthcheck:
test: ["CMD", "wget", "--spider", "-Y", "off", "http://127.0.0.1:8200/v1/sys/health"]
interval: 10s
timeout: 5s
retries: 6
start_period: 60s
logging: *default-logging
deploy:
resources:
limits:
cpus: '1'
memory: 512M
reservations:
cpus: '0.25'
memory: 256M
labels:
- "com.voip.service=secrets-manager"
- "com.voip.platform=colima"
# ---------------------------------------------------------------------------
# Reference Application - FastAPI
# ---------------------------------------------------------------------------
reference-api:
<<: *default-platform
build: ./reference-apps/fastapi
container_name: dev-reference-api
restart: unless-stopped
# PROFILE: Available in reference profile
# Python FastAPI code-first implementation (port 8000/8443)
profiles: ["reference"]
environment:
VAULT_ADDR: ${VAULT_ADDR:-http://vault:8200}
POSTGRES_HOST: postgres
POSTGRES_PORT: 5432
MYSQL_HOST: mysql
MYSQL_PORT: 3306
MONGODB_HOST: mongodb
MONGODB_PORT: 27017
REDIS_HOST: redis-1
REDIS_PORT: 6379
RABBITMQ_HOST: rabbitmq
RABBITMQ_PORT: 5672
REFERENCE_API_ENABLE_TLS: ${REFERENCE_API_ENABLE_TLS:-false}
ports:
- "${REFERENCE_API_HTTP_PORT:-8000}:8000"
- "${REFERENCE_API_HTTPS_PORT:-8443}:8443"
volumes:
- ${HOME}/.config/vault/certs:/app/vault-certs:ro
- ${HOME}/.config/vault/approles/reference-api:/vault-approles/reference-api:ro
networks:
vault-network: # Connect to Vault for secrets
data-network: # Connect to databases/cache/queue
app-network: # Primary network for app tier
ipv4_address: 172.20.3.100
depends_on:
vault:
condition: service_healthy
postgres:
condition: service_healthy
mysql:
condition: service_healthy
healthcheck:
test: ["CMD", "python", "-c", "import urllib.request; urllib.request.urlopen('http://localhost:8000/health')"]
interval: 30s
timeout: 10s
retries: 3
logging: *default-logging
deploy:
resources:
limits:
cpus: '1'
memory: 1G
reservations:
cpus: '0.25'
memory: 256M
labels:
- "com.voip.service=reference-api"
- "com.voip.platform=colima"
# ---------------------------------------------------------------------------
# Reference Application - FastAPI API-First Implementation
# ---------------------------------------------------------------------------
api-first:
<<: *default-platform
build: ./reference-apps/fastapi-api-first
container_name: dev-api-first
restart: unless-stopped
# PROFILE: Available in reference profile
# Python FastAPI API-first implementation (port 8001/8444)
profiles: ["reference"]
environment:
VAULT_ADDR: ${VAULT_ADDR:-http://vault:8200}
VAULT_APPROLE_DIR: /vault-approles/api-first
POSTGRES_HOST: postgres
POSTGRES_PORT: 5432
MYSQL_HOST: mysql
MYSQL_PORT: 3306
MONGODB_HOST: mongodb
MONGODB_PORT: 27017
REDIS_HOST: redis-1
REDIS_PORT: 6379
RABBITMQ_HOST: rabbitmq
RABBITMQ_PORT: 5672
API_FIRST_ENABLE_TLS: ${API_FIRST_ENABLE_TLS:-false}
ports:
- "${API_FIRST_HTTP_PORT:-8001}:8001"
- "${API_FIRST_HTTPS_PORT:-8444}:8444"
volumes:
- ${HOME}/.config/vault/certs:/root/.config/vault/certs:ro
- ${HOME}/.config/vault/approles/api-first:/vault-approles/api-first:ro
networks:
vault-network: # Connect to Vault for secrets
data-network: # Connect to databases/cache/queue
app-network: # Primary network for app tier
ipv4_address: 172.20.3.104
depends_on:
vault:
condition: service_healthy
postgres:
condition: service_healthy
mysql:
condition: service_healthy
healthcheck:
test: ["CMD", "python", "-c", "import urllib.request; urllib.request.urlopen('http://localhost:8001/health')"]
interval: 30s
timeout: 10s
retries: 3
logging: *default-logging
deploy:
resources:
limits:
cpus: '1'
memory: 1G
reservations:
cpus: '0.25'
memory: 256M
labels:
- "com.voip.service=api-first"
- "com.voip.platform=colima"
# ---------------------------------------------------------------------------
# Reference Application - Golang
# ---------------------------------------------------------------------------
golang-api:
<<: *default-platform
build: ./reference-apps/golang
container_name: dev-golang-api
restart: unless-stopped
# PROFILE: Available in reference profile
# Go with Gin framework (port 8002/8445)
profiles: ["reference"]
environment:
VAULT_ADDR: ${VAULT_ADDR:-http://vault:8200}
VAULT_APPROLE_DIR: /vault-approles/golang-api
POSTGRES_HOST: postgres
POSTGRES_PORT: 5432
MYSQL_HOST: mysql
MYSQL_PORT: 3306
MONGODB_HOST: mongodb
MONGODB_PORT: 27017
REDIS_HOST: redis-1
REDIS_PORT: 6379
RABBITMQ_HOST: rabbitmq
RABBITMQ_PORT: 5672
GOLANG_API_ENABLE_TLS: ${GOLANG_API_ENABLE_TLS:-false}
HTTP_PORT: 8002
HTTPS_PORT: 8445
DEBUG: ${DEBUG:-true}
ENVIRONMENT: development
ports:
- "${GOLANG_HTTP_PORT:-8002}:8002"
- "${GOLANG_HTTPS_PORT:-8445}:8445"
volumes:
- ${HOME}/.config/vault/certs:/root/.config/vault/certs:ro
- ${HOME}/.config/vault/approles/golang-api:/vault-approles/golang-api:ro
networks:
vault-network: # Connect to Vault for secrets
data-network: # Connect to databases/cache/queue
app-network: # Primary network for app tier
ipv4_address: 172.20.3.105
depends_on:
vault:
condition: service_healthy
postgres:
condition: service_healthy
mysql:
condition: service_healthy