@@ -69,21 +69,9 @@ services:
69
69
70
70
hatchet-create-db :
71
71
image : postgres:latest
72
- command : >
73
- sh -c "
74
- set -e
75
- echo 'Waiting for PostgreSQL to be ready...'
76
- while ! pg_isready -h hatchet-postgres -p 5432 -U ${HATCHET_POSTGRES_USER:-hatchet_user}; do
77
- sleep 1
78
- done
79
- echo 'PostgreSQL is ready, checking if database exists...'
80
- if ! PGPASSWORD=${HATCHET_POSTGRES_PASSWORD:-hatchet_password} psql -h hatchet-postgres -p 5432 -U ${HATCHET_POSTGRES_USER:-hatchet_user} -lqt | grep -qw ${HATCHET_POSTGRES_DBNAME:-hatchet}; then
81
- echo 'Database does not exist, creating it...'
82
- PGPASSWORD=${HATCHET_POSTGRES_PASSWORD:-hatchet_password} createdb -h hatchet-postgres -p 5432 -U ${HATCHET_POSTGRES_USER:-hatchet_user} -w ${HATCHET_POSTGRES_DBNAME:-hatchet}
83
- else
84
- echo 'Database already exists, skipping creation.'
85
- fi
86
- "
72
+ command : sh /scripts/create-hatchet-db.sh
73
+ volumes :
74
+ - ./scripts:/scripts
87
75
environment :
88
76
DATABASE_URL : " postgres://${HATCHET_POSTGRES_USER:-hatchet_user}:${HATCHET_POSTGRES_PASSWORD:-hatchet_password}@hatchet-postgres:5432/${HATCHET_POSTGRES_DBNAME:-hatchet}?sslmode=disable"
89
77
@@ -169,58 +157,9 @@ services:
169
157
170
158
setup-token :
171
159
image : ghcr.io/hatchet-dev/hatchet/hatchet-admin:v0.53.15
172
- command : >
173
- sh -c "
174
- set -e
175
- echo 'Starting token creation process...'
176
-
177
- # Attempt to create token and capture both stdout and stderr
178
- TOKEN_OUTPUT=$$(/hatchet/hatchet-admin token create --config /hatchet/config --tenant-id 707d0855-80ab-4e1f-a156-f1c4546cbf52 2>&1)
179
-
180
- # Extract the token (assuming it's the only part that looks like a JWT)
181
- TOKEN=$$(echo \"$$TOKEN_OUTPUT\" | grep -Eo 'eyJ[A-Za-z0-9_-]*\.eyJ[A-Za-z0-9_-]*\.[A-Za-z0-9_-]*')
182
-
183
- if [ -z \"$$TOKEN\" ]; then
184
- echo 'Error: Failed to extract token. Full command output:' >&2
185
- echo \"$$TOKEN_OUTPUT\" >&2
186
- exit 1
187
- fi
188
-
189
- echo \"$$TOKEN\" > /tmp/hatchet_api_key
190
- echo 'Token created and saved to /tmp/hatchet_api_key'
191
-
192
- # Copy token to final destination
193
- echo -n \"$$TOKEN\" > /hatchet_api_key/api_key.txt
194
- echo 'Token copied to /hatchet_api_key/api_key.txt'
195
-
196
- # Verify token was copied correctly
197
- if [ \"$$(cat /tmp/hatchet_api_key)\" != \"$(cat /hatchet_api_key/api_key.txt)\" ]; then
198
- echo 'Error: Token copy failed, files do not match' >&2
199
- echo 'Content of /tmp/hatchet_api_key:'
200
- cat /tmp/hatchet_api_key
201
- echo 'Content of /hatchet_api_key/api_key.txt:'
202
- cat /hatchet_api_key/api_key.txt
203
- exit 1
204
- fi
205
-
206
- echo 'Hatchet API key has been saved successfully'
207
- echo 'Token length:' $${#TOKEN}
208
- echo 'Token (first 20 chars):' $${TOKEN:0:20}
209
- echo 'Token structure:' $$(echo $$TOKEN | awk -F. '{print NF-1}') 'parts'
210
- # Check each part of the token
211
- for i in 1 2 3; do
212
- PART=$$(echo $$TOKEN | cut -d. -f$$i)
213
- echo 'Part' $$i 'length:' $${#PART}
214
- echo 'Part' $$i 'base64 check:' $$(echo $$PART | base64 -d >/dev/null 2>&1 && echo 'Valid' || echo 'Invalid')
215
- done
216
- # Final validation attempt
217
- if ! echo $$TOKEN | awk -F. '{print $$2}' | base64 -d 2>/dev/null | jq . >/dev/null 2>&1; then
218
- echo 'Warning: Token payload is not valid JSON when base64 decoded' >&2
219
- else
220
- echo 'Token payload appears to be valid JSON'
221
- fi
222
- "
160
+ command : sh /scripts/setup-token.sh
223
161
volumes :
162
+ - ./scripts:/scripts
224
163
- hatchet_certs:/hatchet/certs
225
164
- hatchet_config:/hatchet/config
226
165
- hatchet_api_key:/hatchet_api_key
@@ -252,13 +191,7 @@ services:
252
191
- " ${R2R_PORT:-7272}:${R2R_PORT:-7272}"
253
192
env_file :
254
193
- ./env/r2r.env
255
- command : >
256
- sh -c '
257
- if [ -z "$${HATCHET_CLIENT_TOKEN}" ]; then
258
- export HATCHET_CLIENT_TOKEN=$$(cat /hatchet_api_key/api_key.txt)
259
- fi
260
- exec uvicorn core.main.app_entry:app --host $${R2R_HOST} --port $${R2R_PORT}
261
- '
194
+ command : sh /scripts/start-r2r.sh
262
195
healthcheck :
263
196
test : ["CMD", "curl", "-f", "http://localhost:${R2R_PORT:-7272}/v3/health"]
264
197
interval : 6s
@@ -268,6 +201,7 @@ services:
268
201
volumes :
269
202
- ${R2R_CONFIG_PATH:-/}:${R2R_CONFIG_PATH:-/app/config}
270
203
- hatchet_api_key:/hatchet_api_key:ro
204
+ - ./scripts:/scripts
271
205
extra_hosts :
272
206
- host.docker.internal:host-gateway
273
207
depends_on :
0 commit comments