๐Ÿ“ฆ juspay / decision-engine

๐Ÿ“„ docker-compose.yaml ยท 283 lines
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
283services:
  open-router:
    image: ghcr.io/juspay/decision-engine:v1.2.1
    pull_policy: always
    platform: linux/amd64
    container_name: open-router
    restart: unless-stopped
    ports:
      - "8080:8080"
    depends_on:
      mysql:
        condition: service_healthy
      redis:
        condition: service_healthy
      groovy-runner:
        condition: service_healthy
      routing-config:
        condition: service_completed_successfully
    volumes:
      - ./config/docker-configuration.toml:/local/config/development.toml
    networks:
      - open-router-network
    environment:
      - GROOVY_RUNNER_HOST=host.docker.internal:8085

  open-router-local:
    build:
      context: .
      dockerfile: Dockerfile
      cache_from:
        - decision-engine-open-router-local:latest
      labels:
        - "com.docker.compose.watchfile=Dockerfile"
        - "com.docker.compose.watchfile=src/"
        - "com.docker.compose.watchfile=Cargo.toml"
        - "com.docker.compose.watchfile=Cargo.lock"
    image: decision-engine-open-router-local:latest
    platform: linux/amd64
    container_name: open-router
    restart: unless-stopped
    ports:
      - "8080:8080"
    depends_on:
      mysql:
        condition: service_healthy
      redis:
        condition: service_healthy
      groovy-runner-local:
        condition: service_healthy
      routing-config:
        condition: service_completed_successfully
    volumes:
      - ./config/docker-configuration.toml:/local/config/development.toml
    networks:
      - open-router-network
    environment:
      - GROOVY_RUNNER_HOST=host.docker.internal:8085

  open-router-local-pg:
    build:
      context: .
      dockerfile: Dockerfile.postgres
      cache_from:
        - decision-engine-open-router-local-pg:latest
      labels:
        - "com.docker.compose.watchfile=Dockerfile.postgres"
        - "com.docker.compose.watchfile=src/"
        - "com.docker.compose.watchfile=Cargo.toml"
        - "com.docker.compose.watchfile=Cargo.lock"
    image: decision-engine-open-router-local-pg:latest
    platform: linux/amd64
    container_name: open-router
    restart: unless-stopped
    ports:
      - "8080:8080"
      - "9094:9094"
    depends_on:
      postgresql:
        condition: service_healthy
      redis:
        condition: service_healthy
      groovy-runner-local:
        condition: service_healthy
    volumes:
      - ./config/docker-configuration.toml:/local/config/development.toml
    networks:
      - open-router-network
    environment:
      - GROOVY_RUNNER_HOST=host.docker.internal:8085

  open-router-pg:
    image: ghcr.io/juspay/decision-engine/postgres:v1.2.1
    pull_policy: always
    platform: linux/amd64
    container_name: open-router-pg 
    restart: unless-stopped
    ports:
      - "8080:8080"
      - "9094:9094"
    depends_on:
      db-migrator-postgres: 
        condition: service_completed_successfully
      groovy-runner-local: 
        condition: service_healthy
    volumes:
      - ./config/docker-configuration.toml:/local/config/development.toml
    networks:
      - open-router-network
    environment:
      - GROOVY_RUNNER_HOST=host.docker.internal:8085

  prometheus:
    image: prom/prometheus:latest
    networks:
      - open-router-network
    volumes:
      - ./config/prometheus.yaml:/etc/prometheus/prometheus.yml
    ports:
      - "9090:9090"
    restart: unless-stopped

  grafana:
    image: grafana/grafana:latest
    ports:
      - "3000:3000"
    networks:
      - open-router-network
    restart: unless-stopped
    environment:
      - GF_AUTH_ANONYMOUS_ORG_ROLE=Admin
      - GF_AUTH_ANONYMOUS_ENABLED=true
      - GF_AUTH_BASIC_ENABLED=false
    volumes:
      # - ./config/grafana.ini:/etc/grafana/grafana.ini
      - ./config/grafana-datasource.yaml:/etc/grafana/provisioning/datasources/datasource.yml

  groovy-runner:
    image: ghcr.io/juspay/open-router/groovy-runner:main
    pull_policy: always
    platform: linux/amd64
    container_name: groovy-runner
    restart: unless-stopped
    ports:
      - "8085:8085"
    networks:
      - open-router-network
    healthcheck:
      test: ["CMD", "curl", "-f", "http://localhost:8085/health"]
      interval: 5s
      timeout: 5s
      retries: 5
      start_period: 10s

  groovy-runner-local:
    build:
      context: .
      dockerfile: groovy.Dockerfile
      args:
        - BUILDKIT_INLINE_CACHE=1
      cache_from:
        - decision-engine-groovy-runner-local:latest
      labels:
        - "com.docker.compose.watchfile=groovy.Dockerfile"
        - "com.docker.compose.watchfile=src/Runner.groovy"
    platform: linux/amd64
    container_name: groovy-runner
    restart: unless-stopped
    ports:
      - "8085:8085"
    networks:
      - open-router-network
    healthcheck:
      test: ["CMD", "curl", "-f", "http://localhost:8085/health"]
      interval: 5s
      timeout: 5s
      retries: 5
      start_period: 10s

  mysql:
    image: mysql:8.0
    container_name: open-router-mysql
    restart: unless-stopped
    environment:
      - MYSQL_ROOT_PASSWORD=root
      - MYSQL_DATABASE=jdb
    volumes:
      - mysql-data:/var/lib/mysql
    ports:
      - "3306:3306"
    networks:
      - open-router-network
    healthcheck:
      test: ["CMD", "mysqladmin", "ping", "-h", "localhost", "-uroot", "-proot"]
      interval: 5s
      timeout: 10s
      retries: 10

  postgresql:  
    image: postgres:latest  
    container_name: open-router-postgres  
    restart: unless-stopped  
    environment:
      - POSTGRES_USER=db_user
      - POSTGRES_PASSWORD=db_pass
      - POSTGRES_DB=decision_engine_db
    volumes:  
      - postgres-data:/var/lib/postgresql/data  
    ports:  
      - "5432:5432"
    networks:
        - open-router-network
    healthcheck:
        test: ["CMD-SHELL", "pg_isready -d $${POSTGRES_DB} -U $${POSTGRES_USER}"]
        interval: 5s
        retries: 3
        start_period: 5s
        timeout: 5s

  redis:
    image: redis:7
    container_name: open-router-redis
    ports:
      - "6379:6379"
    networks:
      - open-router-network
    healthcheck:
      test: ["CMD-SHELL", "redis-cli ping | grep '^PONG$'"]
      interval: 5s
      retries: 5
      start_period: 5s
      timeout: 5s

  db-migrator:
    image: mysql:8.0
    container_name: db-migrator
    depends_on:
      mysql:
        condition: service_healthy
    volumes:
      - ./migrations:/app/migrations
    working_dir: /app
    entrypoint: ["/bin/sh", "-c", "for sql_file in $$(find /app/migrations -name 'up.sql' -type f | sort); do echo \"Running migration: $$sql_file\"; mysql -h mysql -uroot -proot jdb < \"$$sql_file\"; done"]
    networks:
      - open-router-network
  
  db-migrator-postgres:
    image: rust:latest
    container_name: db-migrator 
    depends_on:
      postgresql:
        condition: service_healthy
    environment:
      - PGPASSWORD=db_pass
      - DATABASE_URL=postgresql://db_user:db_pass@postgresql:5432/decision_engine_db
    volumes:
      - .:/app
    working_dir: /app
    command: "bash -c 'cargo install diesel_cli --no-default-features --features postgres && cargo install just && just migrate-pg'"
    networks:
      - open-router-network

  routing-config:
    image: python:3.10-slim
    container_name: routing-config
    depends_on:
      mysql:
        condition: service_healthy
    volumes:
      - ./routing-config:/app
    working_dir: /app
    command: bash run_setup.sh
    networks:
      - open-router-network

networks:
  open-router-network:
    driver: bridge

volumes:
  mysql-data:
  redis-data:
  postgres-data: