Skip to content
Snippets Groups Projects
Commit d2782d1c authored by Burhan Akbar's avatar Burhan Akbar
Browse files

Add healthcheck for MariaDB and wait condition for app

parent 62088847
Branches
No related tags found
No related merge requests found
......@@ -6,15 +6,23 @@ services:
container_name: mariadb
network_mode: "host" # Consider changing this to bridge networking later for better isolation
environment:
MYSQL_ROOT_PASSWORD: comsc
MYSQL_ROOT_PASSWORD: comsc # Ensure this is set
MYSQL_DATABASE: healthcare
volumes:
# Mount the directory containing 01_schema.sql and 02_data.sql
- ./src/main/resources:/docker-entrypoint-initdb.d
# --- BEGIN HEALTHCHECK ---
healthcheck:
test: ["CMD", "mariadb-admin", "ping", "-h", "localhost", "-u", "root", "-p${MYSQL_ROOT_PASSWORD}"]
interval: 10s
timeout: 5s
retries: 5
start_period: 30s # Give it 30s to initialize before starting checks
# --- END HEALTHCHECK ---
healthcare_01:
build:
context: .
context: . # Added context back
dockerfile: Dockerfile
container_name: healthcare_01
network_mode: "host"
......@@ -25,4 +33,7 @@ services:
- SPRING_DATASOURCE_USERNAME=root # You need to specify the username
- SPRING_DATASOURCE_PASSWORD=comsc
depends_on:
- mariadb # Make sure the app waits for the db
# --- MODIFIED depends_on ---
mariadb:
condition: service_healthy # Wait for the healthcheck to pass
# --- END MODIFIED depends_on ---
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment