@@ -99,10 +99,50 @@ services:
9999 restart : unless-stopped
100100 environment :
101101 ADMIN_PASSWORD : ${FUSEKI_ADMIN_PASSWORD}
102+ healthcheck :
103+ test : ["CMD", "wget", "-qO-", "http://localhost:3030/$/ping"]
104+ interval : 5s
105+ timeout : 5s
106+ retries : 10
102107 networks :
103108 - internal
104109 - proxy-net
105110
111+ fuseki-init :
112+ image : curlimages/curl:8.12.1
113+ container_name : fuseki-init
114+ restart : " no"
115+ depends_on :
116+ fuseki :
117+ condition : service_healthy
118+ environment :
119+ FUSEKI_ADMIN_PASSWORD : ${FUSEKI_ADMIN_PASSWORD}
120+ volumes :
121+ - ./fuseki/seed:/seed:ro
122+ entrypoint : ["/bin/sh", "-c"]
123+ command :
124+ - |
125+ DATASETS=$$(curl -sf -u "admin:$$FUSEKI_ADMIN_PASSWORD" "http://fuseki:3030/\$$/datasets")
126+ for f in /seed/*.ttl; do
127+ ds=$$(basename "$$f" .ttl)
128+ if echo "$$DATASETS" | grep -q "\"/$${ds}\""; then
129+ echo "Dataset $$ds already exists, skipping."
130+ else
131+ echo "Creating dataset $$ds..."
132+ curl -sf -u "admin:$$FUSEKI_ADMIN_PASSWORD" -X POST \
133+ "http://fuseki:3030/\$$/datasets" \
134+ -d "dbName=$$ds&dbType=tdb2"
135+ echo "Loading data into $$ds..."
136+ curl -sf -u "admin:$$FUSEKI_ADMIN_PASSWORD" -X POST \
137+ "http://fuseki:3030/$$ds/data" \
138+ -H "Content-Type: text/turtle" \
139+ --data-binary "@$$f" && echo "Loaded $$f into $$ds" || echo "FAIL: could not load $$f"
140+ fi
141+ done
142+ echo "Fuseki init complete."
143+ networks :
144+ - internal
145+
106146 metabase :
107147 image : *metabase-version
108148 container_name : metabase
0 commit comments