Skip to content

Commit

Permalink
make /data configurable
Browse files Browse the repository at this point in the history
  • Loading branch information
menzowindhouwer committed Sep 25, 2022
1 parent 918b8ca commit efdad0f
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 10 deletions.
3 changes: 2 additions & 1 deletion .env
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
FUSEKI="http://fuseki:3030"
SPARQL_ENDPOINT="${FUSEKI}/skosmos/sparql"
SPARQL_ENDPOINT="${FUSEKI}/skosmos/sparql"
DATA="/data"
1 change: 1 addition & 0 deletions docker-compose-portainer-template.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ services:
environment:
- FUSEKI=http://sd-fuseki:3030
- SPARQL_ENDPOINT=http://sd-fuseki:3030/skosmos/sparql
- DATA=/data
- VIRTUAL_HOST=skosmos.sd.di.huc.knaw.nl
- VIRTUAL_PORT=8080
networks:
Expand Down
5 changes: 3 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@ services:
context: .
dockerfile: Dockerfile
environment:
- FUSEKI=${FUSEKI}
- SPARQL_ENDPOINT=${SPARQL_ENDPOINT}
- FUSEKI=${FUSEKI:-http://fuseki:3030}
- SPARQL_ENDPOINT=${SPARQL_ENDPOINT:-${FUSEKI}/skosmos/sparql}
- DATA=${DATA:-/data}
networks:
- skosmos
ports:
Expand Down
14 changes: 7 additions & 7 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,35 +3,35 @@ set -x

sleep 30

if [ -f /data/config.ttl ];then
cp /data/config.ttl /tmp/config-docker-compose.ttl
if [ -f ${DATA}/config.ttl ];then
cp ${DATA}/config.ttl /tmp/config-docker-compose.ttl
else
cp /var/www/html/config-docker-compose.ttl /tmp/config-docker-compose.ttl
fi

LOADED=`ls /data/*.loaded | wc -l`
LOADED=`ls ${DATA}/*.loaded | wc -l`
if [ ${LOADED} -eq 0 ];then
curl -u admin:admin -XPOST --data "dbName=skosmos&dbType=tdb" -G ${FUSEKI}/\$/datasets
fi

PWD=`pwd`
cd /data
cd ${DATA}
for VOCAB in `ls *.ttl`; do
VOCAB=`basename ${VOCAB} .ttl`
if [ ! -f ${VOCAB}.loaded ]; then
echo "LOAD VOCAB[${VOCAB}] ..."
GRAPH=`grep sparqlGraph ${VOCAB}.config | sed 's|\s*skosmos:sparqlGraph <\s*||g' | sed 's|\s*>\s*||g'`
echo "... in GRAPH[${GRAPH}] ..."
if [ ! -f ${VOCAB}.ttl ]; then
echo "!ERROR: /data/${VOCAB}.ttl doesn't exist!"
echo "!ERROR: ${DATA}/${VOCAB}.ttl doesn't exist!"
exit 1
fi
curl -X PUT -H Content-Type:text/turtle -T ${VOCAB}.ttl -G ${FUSEKI}/skosmos/data --data-urlencode graph=${GRAPH}
touch /data/${VOCAB}.loaded
touch ${DATA}/${VOCAB}.loaded
echo "... DONE"
fi
done
cat /data/*.config >> /tmp/config-docker-compose.ttl
cat ${DATA}/*.config >> /tmp/config-docker-compose.ttl
cd ${PWD}

/usr/bin/envsubst < /tmp/config-docker-compose.ttl > /var/www/html/config.ttl
Expand Down

0 comments on commit efdad0f

Please sign in to comment.