forked from saxenasanket/sso-rbac-auth-system
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathdocker-compose.yaml
146 lines (136 loc) · 4.5 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
version: '3.8'
services:
postgres:
image: postgres:16.2
# Mounts the PostgreSQL data directory to persist data
volumes:
- postgres_data:/var/lib/postgresql/data
environment:
# Environment variables for PostgreSQL configuration
POSTGRES_DB: ${POSTGRES_DB}
POSTGRES_USER: ${POSTGRES_USER}
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
keycloak:
image: quay.io/keycloak/keycloak:23.0.6
# Starts the Keycloak server with a specific command
command: start
environment:
# Environment variables for Keycloak configuration
KC_HOSTNAME: ${KEYCLOAK_HOSTNAME}
KC_HOSTNAME_PORT: ${KEYCLOAK_PORT}
KC_HOSTNAME_STRICT_BACKCHANNEL: 'false'
KC_HTTP_ENABLED: 'true'
KC_HOSTNAME_STRICT_HTTPS: 'false'
KC_HEALTH_ENABLED: 'true'
KEYCLOAK_ADMIN: ${KEYCLOAK_ADMIN}
KEYCLOAK_ADMIN_PASSWORD: ${KEYCLOAK_ADMIN_PASSWORD}
KC_DB: postgres
KC_DB_URL: jdbc:postgresql://postgres/${POSTGRES_DB}
KC_DB_USERNAME: ${POSTGRES_USER}
KC_DB_PASSWORD: ${POSTGRES_PASSWORD}
ports:
# Exposes Keycloak on port 8080
- 8080:8080
# Restarts the container automatically on failure
restart: always
# Ensures Keycloak starts after PostgreSQL
depends_on:
- postgres
redis:
image: redis:alpine
# Exposes Redis on port 6379
ports:
- "6379:6379"
api-gateway:
image: api-gateway:latest
# Builds the API Gateway from the specified Dockerfile
build:
context: ./api-gateway
dockerfile: Dockerfile
ports:
# Exposes the API Gateway on port 8081
- "8081:8081"
environment:
# Environment variables for API Gateway configuration
- PORT=8081
- REDIS_HOST=${REDIS_HOST}
- REDIS_PORT=${REDIS_PORT}
- AUTH_URL=${AUTH_URL}
- SERVICE_A_URL=${SERVICE_A_URL}
depends_on:
# Ensures API Gateway starts after Redis and Keycloak
- redis
- keycloak
auth-service:
image: auth-service:latest
# Builds the Auth Service from the specified Dockerfile
build:
context: ./auth-service
dockerfile: Dockerfile
ports:
# Exposes the Auth Service on port 8083
- "8083:8083"
environment:
# Environment variables for Auth Service configuration
- PORT=8083
- KEYCLOAK_AUTH_SERVER_URL=${KEYCLOAK_AUTH_SERVER_URL}
- KEYCLOAK_REALM=${KEYCLOAK_REALM}
- KEYCLOAK_CLIENT_ID=${KEYCLOAK_CLIENT_ID_APP}
- KEYCLOAK_CLIENT_SECRET=${KEYCLOAK_CLIENT_SECRET}
depends_on:
# Ensures Auth Service starts after Keycloak and API Gateway
- keycloak
- api-gateway
crm:
image: crm:latest
# Builds the CRM service from the specified Dockerfile
build:
context: ./crm
dockerfile: Dockerfile
ports:
# Exposes the CRM service on port 8090
- "8090:8090"
environment:
# Environment variables for CRM configuration
- PORT=8090
- REDIS_HOST=${REDIS_HOST}
- REDIS_PORT=${REDIS_PORT}
depends_on:
# Ensures CRM starts after the Auth Service
- auth-service
mssql:
container_name: mssql-db
hostname: mssql-db
image: mcr.microsoft.com/mssql/server:2022-latest
environment:
# Environment variables for MSSQL configuration
ACCEPT_EULA: 'Y'
MSSQL_SA_PASSWORD: ${SQL_SA_PASSWORD}
MSSQL_DATA_DIR: /var/opt/mssql/data
MSSQL_PID: 'Developer'
MSSQL_TCP_PORT: ${SQL_PORT}
ports:
# Exposes MSSQL on port 1433
- "1433:1433"
# Mounts directories to persist MSSQL data, logs, and secrets
volumes:
- ./sql/data:/var/opt/mssql/data
- ./sql/log:/var/opt/mssql/log
- ./sql/secrets:/var/opt/mssql/secrets
init-db:
image: mcr.microsoft.com/mssql-tools
depends_on:
# Ensures init-db starts after MSSQL is ready
- mssql
environment:
MSSQL_SA_PASSWORD: ${SQL_SA_PASSWORD}
volumes:
# Mounts SQL scripts for database initialization
- ./sql/gate-master.sql:/var/opt/mssql/scripts/gate-master.sql
- ./sql/init-data.sql:/var/opt/mssql/scripts/init-data.sql
# Executes SQL scripts after a delay to ensure MSSQL is ready
entrypoint: /bin/bash -c "sleep 60s && /opt/mssql-tools/bin/sqlcmd -S mssql-db -U SA -P ${SQL_SA_PASSWORD} -d master -i /var/opt/mssql/scripts/gate-master.sql && /opt/mssql-tools/bin/sqlcmd -S mssql-db -U SA -P ${SQL_SA_PASSWORD} -d master -i /var/opt/mssql/scripts/init-data.sql"
# Defines a named volume to persist PostgreSQL data
volumes:
postgres_data:
driver: local