Skip to content

Commit 16fd757

Browse files
authored
fix: start the app only once MySQL is healthy (#23) (#25)
1 parent f1fe5df commit 16fd757

1 file changed

Lines changed: 11 additions & 2 deletions

File tree

‎docker-compose.yml‎

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,20 @@ services:
1717
- ./data/mysql/db:/var/lib/mysql
1818
# Map my.cnf file (to maintain persistency)
1919
- ./data/mysql/my.cnf:/etc/mysql/my.cnf
20+
# Healthy once MySql accepts TCP connections; the temporary server that runs during the
21+
# first initialization only listens on its socket, so it does not count as ready.
22+
healthcheck:
23+
test: ["CMD", "mysqladmin", "ping", "-h", "127.0.0.1", "--silent"]
24+
interval: 5s
25+
timeout: 5s
26+
retries: 30
27+
start_period: 60s
2028
# AnsibleForms application
2129
app:
22-
# Only start after MySql
30+
# Only start once MySql is ready to accept connections
2331
depends_on:
24-
- mysqldb
32+
mysqldb:
33+
condition: service_healthy
2534
image: ghcr.io/ansibleforms/ansibleforms:6
2635
container_name: af_app
2736
restart: unless-stopped

0 commit comments

Comments
 (0)