Skip to content

Commit 645abb0

Browse files
committed
API should wait until db is ready
1 parent 07a8de7 commit 645abb0

File tree

2 files changed

+16
-14
lines changed

2 files changed

+16
-14
lines changed

docker-compose.yml

+11-9
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
12
name: dolos
23
version: "3.9"
34
services:
@@ -10,8 +11,8 @@ services:
1011
networks:
1112
- dolos
1213
healthcheck:
13-
start_period: 5s
14-
interval: 10s
14+
start_period: 2s
15+
interval: 5s
1516
test: healthcheck.sh --su-mysql --connect --innodb_initialized
1617
web:
1718
image: ghcr.io/dodona-edu/dolos-web
@@ -28,8 +29,8 @@ services:
2829
networks:
2930
- dolos
3031
healthcheck:
31-
start_period: 5s
32-
interval: 10s
32+
start_period: 2s
33+
interval: 5s
3334
test: curl --fail http://localhost:8080 || exit 1
3435
api:
3536
image: ghcr.io/dodona-edu/dolos-api
@@ -51,11 +52,12 @@ services:
5152
RAILS_LOG_TO_STDOUT: true
5253
SECRET_KEY_BASE_DUMMY: true
5354
depends_on:
54-
- worker
55+
db:
56+
condition: service_healthy
5557
networks:
5658
- dolos
5759
healthcheck:
58-
start_period: 5s
60+
start_period: 2s
5961
interval: 10s
6062
test: curl --fail http://localhost:3000/up || exit 1
6163
worker:
@@ -74,12 +76,12 @@ services:
7476
SECRET_KEY_BASE_DUMMY: true
7577
RAILS_LOG_TO_STDOUT: true
7678
depends_on:
77-
- db
79+
- api
7880
networks:
7981
- dolos
8082
healthcheck:
81-
start_period: 5s
82-
interval: 10s
83+
start_period: 2s
84+
interval: 5s
8385
test: ruby -e true || exit 1
8486
volumes:
8587
dolos-db-data:

test_compose.sh

+5-5
Original file line numberDiff line numberDiff line change
@@ -6,24 +6,24 @@ set -e
66
docker compose --progress quiet down
77
docker compose --progress quiet pull
88
docker pull ghcr.io/dodona-edu/dolos-cli:latest
9-
docker compose up # --wait --detach
9+
docker compose up --wait --detach
1010

1111
echo "Upload zipfile"
1212

13-
upload_response="$(
13+
report_url="$(
1414
curl -s --fail \
1515
--form "dataset[name]=Example" \
1616
--form "dataset[zipfile]=@./samples/javascript/simple-dataset.zip" \
17-
http://localhost:3000/reports
17+
http://localhost:3000/reports \
18+
| jq -r '.url'
1819
)"
1920

20-
report_url="$(echo "$upload_response" | jq -r '.url')"
2121

2222
echo "Polling $report_url until finished or failed"
2323

2424
while sleep 1; do
2525
report_json="$(curl -s --fail "$report_url")"
26-
report_status="$(echo "$report_json" | jq -r '.status')"
26+
report_status="$(echo -E "$report_json" | tee /dev/stderr | jq -r '.status')"
2727
echo "Status is '$report_status'"
2828
case "$report_status" in
2929
"queued" | "running")

0 commit comments

Comments
 (0)