@@ -35,7 +35,10 @@ services:
3535 LOGGING_CONFIG : /dspace/config/log4j2-container.xml
3636 image : " ${DOCKER_REGISTRY:-docker.io}/${DOCKER_OWNER:-4science}/dspace-cris:${DSPACE_VER:-dspace-cris-2024_02_x}-test"
3737 depends_on :
38- - dspacedb
38+ dspacedb :
39+ condition : service_healthy
40+ dspacesolr :
41+ condition : service_healthy
3942 networks :
4043 - dspacenet
4144 ports :
@@ -45,18 +48,37 @@ services:
4548 tty : true
4649 volumes :
4750 - assetstore:/dspace/assetstore
48- # Ensure that the database is ready BEFORE starting tomcat
49- # 1. While a TCP connection to dspacedb port 5432 is not available, continue to sleep
50- # 2. Then, run database migration to init database tables (including any out-of-order ignored migrations, if any)
51- # 3. Finally, start DSpace
51+ # Ensure that the database and Solr are ready BEFORE starting tomcat
52+ # 1. Wait for Solr HTTP endpoint to respond
53+ # 2. While a TCP connection to dspacedb port 5432 is not available, continue to sleep
54+ # 3. Then, run database migration to init database tables (including any out-of-order ignored migrations, if any)
55+ # 4. Finally, start DSpace
5256 entrypoint :
5357 - /bin/bash
5458 - ' -c'
5559 - |
60+ # Wait for the database to be reachable and healthy
61+ echo "Waiting for database..."
62+ until (echo > /dev/tcp/dspacedb/5432) >/dev/null 2>&1; do
63+ sleep 2
64+ done
65+ echo "Database is reachable"
66+ # Wait for Solr to be ready
67+ echo "Waiting for Solr..."
68+ until curl -s http://dspacesolr:8983/solr/ > /dev/null 2>&1; do
69+ sleep 2
70+ done
71+ echo "Solr is ready"
5672 /dspace/bin/dspace database repair
5773 /dspace/bin/dspace database migrate
5874 /dspace/bin/dspace database migrate ignored
5975 java -XX:+UseParallelGC -XX:MaxRAMPercentage=75 org.springframework.boot.loader.launch.JarLauncher
76+ healthcheck :
77+ test : ["CMD", "curl", "-f", "http://localhost:8080/server/actuator/health/"]
78+ interval : 30s
79+ timeout : 10s
80+ retries : 5
81+ start_period : 60s
6082 # DSpace database container
6183 # NOTE: This is customized to use our loadsql image, so that we are using a database with existing test data
6284 dspacedb :
@@ -80,6 +102,12 @@ services:
80102 volumes :
81103 # Keep Postgres data directory between reboots
82104 - pgdata:/pgdata
105+ healthcheck :
106+ test : ["CMD-SHELL", "pg_isready -U dspace"]
107+ interval : 15s
108+ timeout : 5s
109+ retries : 10
110+ start_period : 30s
83111 # DSpace Solr container
84112 dspacesolr :
85113 container_name : dspacesolr
@@ -118,6 +146,12 @@ services:
118146 precreate-core audit /opt/solr/server/solr/configsets/audit
119147 cp -r /opt/solr/server/solr/configsets/audit/* audit
120148 exec solr -f
149+ healthcheck :
150+ test : ["CMD", "curl", "-f", "http://localhost:8983/solr/"]
151+ interval : 15s
152+ timeout : 5s
153+ retries : 10
154+ start_period : 30s
121155volumes :
122156 assetstore :
123157 pgdata :
0 commit comments