Files
group-2-threaded-project-pe…/docker-compose.dev.yml
Harkamal Randhawa a1be1a5688 Improve Docker healthcheck to validate schema initialization
- Check for 'users' table existence instead of just mysqladmin ping
- Ensures schema.sql has executed before marking as healthy
- Add 40s start_period for initial schema load
- Prevents Spring Boot from connecting to uninitialized database
2026-03-09 22:01:42 -06:00

26 lines
740 B
YAML

services:
db:
image: mysql:8.0
container_name: petshop-db
restart: always
environment:
MYSQL_ROOT_PASSWORD: root
MYSQL_DATABASE: Petstoredb
MYSQL_USER: petshop
MYSQL_PASSWORD: petshop
ports:
- "3306:3306"
volumes:
- db_data:/var/lib/mysql
- ./src/main/resources/schema.sql:/docker-entrypoint-initdb.d/01-schema.sql
- ./src/main/resources/data.sql:/docker-entrypoint-initdb.d/02-data.sql
healthcheck:
test: ["CMD", "mysql", "-uroot", "-proot", "-e", "SELECT COUNT(*) FROM information_schema.tables WHERE table_schema='Petstoredb' AND table_name='users';"]
interval: 10s
timeout: 5s
retries: 30
start_period: 40s
volumes:
db_data: