Skip to content

Commit a08a941

Browse files
authored
Merge pull request #45 from yngwi/master
Version 0.3.0
2 parents aebd4a4 + a76c1ad commit a08a941

File tree

13 files changed

+350
-19
lines changed

13 files changed

+350
-19
lines changed

Dockerfile

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
ARG JAVA_VERSION=11
2-
3-
FROM adoptopenjdk/maven-openjdk${JAVA_VERSION}
1+
FROM openjdk:11.0.12
42
LABEL maintainer=“[email protected]
53

64
ARG APPLICATION_PORT=8080
@@ -35,11 +33,15 @@ ENV PROFILE=${PROFILE}
3533
ENV REDIS_PORT=${REDIS_PORT}
3634
ENV REDIS_URL=${REDIS_URL}
3735

38-
RUN curl -fsSL https://deb.nodesource.com/setup_15.x | bash -
36+
RUN curl -fsSL https://deb.nodesource.com/setup_17.x | bash -
3937
RUN apt-get install -y nodejs
4038
RUN npm install -g yarn
4139

40+
RUN cd /opt && curl -sSl http://mirror.vorboss.net/apache/maven/maven-3/3.8.3/binaries/apache-maven-3.8.3-bin.tar.gz | tar -xz
41+
ENV PATH "$PATH:/opt/apache-maven-3.8.3/bin"
42+
4243
EXPOSE ${APPLICATION_PORT}
4344
COPY ./ ./
4445
RUN mvn package -Dmaven.test.skip=true
46+
4547
ENTRYPOINT ["java","-jar","./target/nampi-backend.jar"]

Dockerfile.fuseki

Lines changed: 95 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,97 @@
1-
ARG FUSEKI_VERSION=latest
1+
# Licensed to the Apache Software Foundation (ASF) under one or more
2+
# contributor license agreements. See the NOTICE file distributed with
3+
# this work for additional information regarding copyright ownership.
4+
# The ASF licenses this file to You under the Apache License, Version 2.0
5+
# (the "License"); you may not use this file except in compliance with
6+
# the License. You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
215

3-
FROM stain/jena-fuseki:${FUSEKI_VERSION}
416

5-
RUN apt-get update; \
6-
apt-get install -y --no-install-recommends procps
17+
FROM openjdk:11-jre-slim-buster
18+
MAINTAINER Stian Soiland-Reyes <[email protected]>
19+
20+
ENV LANG C.UTF-8
21+
RUN set -eux; \
22+
apt-get update; \
23+
apt-get install -y --no-install-recommends \
24+
bash curl ca-certificates findutils coreutils gettext pwgen procps tini \
25+
; \
26+
rm -rf /var/lib/apt/lists/*
27+
28+
29+
# Update below according to https://jena.apache.org/download/
30+
# and checksum for apache-jena-fuseki-4.x.x.tar.gz.sha512
31+
ENV FUSEKI_SHA512 359f8f99c8fa5968c1bdddcc39214db86da822804e3dd5fa182b86daff2d121a85b2102cffec853d9a80ceca7dea8ef65ef875919d653984af9bd297bc740167
32+
ENV FUSEKI_VERSION 4.2.0
33+
# No need for https due to sha512 checksums below
34+
ENV ASF_MIRROR http://www.apache.org/dyn/mirrors/mirrors.cgi?action=download&filename=
35+
ENV ASF_ARCHIVE http://archive.apache.org/dist/
36+
37+
LABEL org.opencontainers.image.url https://github.com/stain/jena-docker/tree/master/jena-fuseki
38+
LABEL org.opencontainers.image.source https://github.com/stain/jena-docker/
39+
LABEL org.opencontainers.image.documentation https://jena.apache.org/documentation/fuseki2/
40+
LABEL org.opencontainers.image.title "Apache Jena Fuseki"
41+
LABEL org.opencontainers.image.description "Fuseki is a SPARQL 1.1 server with a web interface, backed by the Apache Jena TDB RDF triple store."
42+
LABEL org.opencontainers.image.version ${FUSEKI_VERSION}
43+
LABEL org.opencontainers.image.licenses "(Apache-2.0 AND (GPL-2.0 WITH Classpath-exception-2.0) AND GPL-3.0)"
44+
LABEL org.opencontainers.image.authors "Apache Jena Fuseki by https://jena.apache.org/; this image by https://orcid.org/0000-0001-9842-9718"
45+
46+
# Config and data
47+
ENV FUSEKI_BASE /fuseki
48+
49+
50+
# Installation folder
51+
ENV FUSEKI_HOME /jena-fuseki
52+
53+
WORKDIR /tmp
54+
# published sha512 checksum
55+
RUN echo "$FUSEKI_SHA512 fuseki.tar.gz" > fuseki.tar.gz.sha512
56+
# Download/check/unpack/move in one go (to reduce image size)
57+
RUN (curl --location --silent --show-error --fail --retry-connrefused --retry 3 --output fuseki.tar.gz ${ASF_MIRROR}jena/binaries/apache-jena-fuseki-$FUSEKI_VERSION.tar.gz || \
58+
curl --fail --silent --show-error --retry-connrefused --retry 3 --output fuseki.tar.gz $ASF_ARCHIVE/jena/binaries/apache-jena-fuseki-$FUSEKI_VERSION.tar.gz) && \
59+
sha512sum -c fuseki.tar.gz.sha512 && \
60+
tar zxf fuseki.tar.gz && \
61+
mv apache-jena-fuseki* $FUSEKI_HOME && \
62+
rm fuseki.tar.gz* && \
63+
cd $FUSEKI_HOME && rm -rf fuseki.war && chmod 755 fuseki-server
64+
65+
# Test the install by testing it's ping resource. 20s sleep because Docker Hub.
66+
RUN $FUSEKI_HOME/fuseki-server & \
67+
sleep 20 && \
68+
curl -sS --fail 'http://localhost:3030/$/ping'
69+
70+
# No need to kill Fuseki as our shell will exit after curl
71+
72+
# As "localhost" is often inaccessible within Docker container,
73+
# we'll enable basic-auth with a random admin password
74+
# (which we'll generate on start-up)
75+
COPY shiro.ini $FUSEKI_HOME/shiro.ini
76+
COPY fuseki-entrypoint.sh /docker-entrypoint.sh
77+
RUN chmod 755 /docker-entrypoint.sh
78+
79+
80+
COPY load.sh $FUSEKI_HOME/
81+
COPY tdbloader $FUSEKI_HOME/
82+
COPY tdbloader2 $FUSEKI_HOME/
83+
RUN chmod 755 $FUSEKI_HOME/load.sh $FUSEKI_HOME/tdbloader $FUSEKI_HOME/tdbloader2
84+
#VOLUME /staging
85+
86+
87+
# Where we start our server from
88+
WORKDIR $FUSEKI_HOME
89+
90+
# Make sure we start with empty /fuseki
91+
RUN rm -rf $FUSEKI_BASE
92+
VOLUME $FUSEKI_BASE
93+
94+
EXPOSE 3030
95+
ENTRYPOINT ["/usr/bin/tini", "--", "/docker-entrypoint.sh"]
96+
CMD ["/jena-fuseki/fuseki-server"]
97+

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ A number of command line parameters are available to configure the application.
3939
| Parameter | Mandatory | Default Value | Example | Description |
4040
| ------------------------- | --------- | ------------------------------------------- | ------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------- |
4141
| APPLICATION_PORT | | 8080 | | The port the application will run on |
42-
| CORE_OWL_URL | | https://purl.org/nampi/owl/core | | The location of the NAMPI-Core ontology |
42+
| CORE_OWL_URL | | http://purl.org/nampi/owl/core | | The location of the NAMPI-Core ontology |
4343
| DATA_BASE_URL | | The URL used in the current Servlet Request | https://example.com/nampi/data | The URL to use when creating internal links or new database individuals. When omitted, the current servlet request is used |
4444
| DATA_URL | \* | | http://localhost:3030/data | The URL to the data dataset where the original data will be stored |
4545
| DEFAULT_LIMIT | | 20 | | The default result number to return when requesting from a collection endpoint like '/persons |
@@ -74,7 +74,7 @@ The application can be run as a standalone Docker container connected to pre-exi
7474
Example:
7575

7676
```
77-
docker build --build-arg DATA_BASE_URL=https://example.com/nampi/data --build-arg KEYCLOAK_FRONTEND_URL=http://localhost:8080/auth --build-arg KEYCLOAK_REALM=nampi --build-arg KEYCLOAK_RESOURCE=nampi-client --build-arg KEYCLOAK_URL=http://example.com/keycloak/auth --build-arg LOGGING_LEVEL=TRACE --build-arg OTHER_OWL_URLS=https://purl.org/nampi/owl/monastic-life --build-arg REDIS_PORT=6379 --build-arg REDIS_URL=http://example.com/redis --build-arg INF_CACHE_URL=http://example.com/fuseki/inf-cache --build-arg DATA_URL=http://example.com/fuseki/data .
77+
docker build --build-arg DATA_BASE_URL=https://example.com/nampi/data --build-arg KEYCLOAK_FRONTEND_URL=http://localhost:8080/auth --build-arg KEYCLOAK_REALM=nampi --build-arg KEYCLOAK_RESOURCE=nampi-client --build-arg KEYCLOAK_URL=http://example.com/keycloak/auth --build-arg LOGGING_LEVEL=TRACE --build-arg OTHER_OWL_URLS=http://purl.org/nampi/owl/monastic-life --build-arg REDIS_PORT=6379 --build-arg REDIS_URL=http://example.com/redis --build-arg INF_CACHE_URL=http://example.com/fuseki/inf-cache --build-arg DATA_URL=http://example.com/fuseki/data .
7878
```
7979

8080
## Deploying with `docker-compose`
@@ -93,7 +93,7 @@ KEYCLOAK_PASSWORD=[keycloak password]
9393
KEYCLOAK_PG_PASSWORD=[keycloak pg password]
9494
KEYCLOAK_REALM=nampi
9595
KEYCLOAK_RESOURCE=nampi-client
96-
OTHER_OWL_URLS=https://purl.org/nampi/owl/monastic-life
96+
OTHER_OWL_URLS=http://purl.org/nampi/owl/monastic-life
9797
```
9898

9999
To directly expose the containers (for example to use the Fuseki and Keycloak admin interfaces) to the web, the following docker-compose.override.yml file can be used as a starting point:

docker-compose.yml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,6 @@ services:
2323
build:
2424
context: .
2525
dockerfile: Dockerfile.fuseki
26-
args:
27-
FUSEKI_VERSION: 4.0.0
2826
restart: always
2927
volumes:
3028
- fuseki_data:/fuseki
@@ -57,12 +55,11 @@ services:
5755
dockerfile: Dockerfile
5856
args:
5957
APPLICATION_PORT: ${APPLICATION_PORT:-8080}
60-
CORE_OWL_URL: https://purl.org/nampi/owl/core
58+
CORE_OWL_URL: http://purl.org/nampi/owl/core
6159
DATA_BASE_URL: ${DATA_BASE_URL}
6260
DATA_URL: http://fuseki:3030/data
6361
DEFAULT_LIMIT: ${DEFAULT_LIMIT:-20}
6462
INF_CACHE_URL: http://fuseki:3030/inf_cache
65-
JAVA_VERSION: 11
6663
KEYCLOAK_RDF_ID_ATTRIBUTE: ${KEYCLOAK_RDF_ID_ATTRIBUTE:-rdf-id}
6764
KEYCLOAK_REALM: ${KEYCLOAK_REALM}
6865
KEYCLOAK_RESOURCE: ${KEYCLOAK_RESOURCE}

fuseki-entrypoint.sh

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
#!/bin/bash
2+
# Licensed to the Apache Software Foundation (ASF) under one or more
3+
# contributor license agreements. See the NOTICE file distributed with
4+
# this work for additional information regarding copyright ownership.
5+
# The ASF licenses this file to You under the Apache License, Version 2.0
6+
# (the "License"); you may not use this file except in compliance with
7+
# the License. You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
17+
set -e
18+
19+
if [ ! -f "$FUSEKI_BASE/shiro.ini" ] ; then
20+
# First time
21+
echo "###################################"
22+
echo "Initializing Apache Jena Fuseki"
23+
echo ""
24+
cp "$FUSEKI_HOME/shiro.ini" "$FUSEKI_BASE/shiro.ini"
25+
if [ -z "$ADMIN_PASSWORD" ] ; then
26+
ADMIN_PASSWORD=$(pwgen -s 15)
27+
echo "Randomly generated admin password:"
28+
echo ""
29+
echo "admin=$ADMIN_PASSWORD"
30+
fi
31+
echo ""
32+
echo "###################################"
33+
fi
34+
35+
if [ -d "/fuseki-extra" ] && [ ! -d "$FUSEKI_BASE/extra" ] ; then
36+
ln -s "/fuseki-extra" "$FUSEKI_BASE/extra"
37+
fi
38+
39+
# $ADMIN_PASSWORD only modifies if ${ADMIN_PASSWORD}
40+
# is in shiro.ini
41+
if [ -n "$ADMIN_PASSWORD" ] ; then
42+
export ADMIN_PASSWORD
43+
envsubst '${ADMIN_PASSWORD}' < "$FUSEKI_BASE/shiro.ini" > "$FUSEKI_BASE/shiro.ini.$$" && \
44+
mv "$FUSEKI_BASE/shiro.ini.$$" "$FUSEKI_BASE/shiro.ini"
45+
unset ADMIN_PASSWORD # Don't keep it in memory
46+
export ADMIN_PASSWORD
47+
fi
48+
49+
# fork
50+
exec "$@" &
51+
52+
TDB_VERSION=''
53+
if [ ! -z ${TDB+x} ] && [ "${TDB}" = "2" ] ; then
54+
TDB_VERSION='tdb2'
55+
else
56+
TDB_VERSION='tdb'
57+
fi
58+
59+
# Wait until server is up
60+
while [[ $(curl -I http://localhost:3030 2>/dev/null | head -n 1 | cut -d$' ' -f2) != '200' ]]; do
61+
sleep 1s
62+
done
63+
64+
# Convert env to datasets
65+
printenv | egrep "^FUSEKI_DATASET_" | while read env_var
66+
do
67+
dataset=$(echo $env_var | egrep -o "=.*$" | sed 's/^=//g')
68+
curl -s 'http://localhost:3030/$/datasets'\
69+
-H "Authorization: Basic $(echo -n admin:${ADMIN_PASSWORD} | base64)" \
70+
-H 'Content-Type: application/x-www-form-urlencoded; charset=UTF-8'\
71+
--data "dbName=${dataset}&dbType=${TDB_VERSION}"
72+
done
73+
74+
# rejoin our exec
75+
wait

load.sh

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
#!/bin/bash
2+
# Licensed to the Apache Software Foundation (ASF) under one or more
3+
# contributor license agreements. See the NOTICE file distributed with
4+
# this work for additional information regarding copyright ownership.
5+
# The ASF licenses this file to You under the Apache License, Version 2.0
6+
# (the "License"); you may not use this file except in compliance with
7+
# the License. You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
17+
extensions="rdf ttl owl nt nquads"
18+
PATTERNS=""
19+
for e in $extensions ; do
20+
PATTERNS="$PATTERNS *.$e *.$e.gz"
21+
done
22+
23+
if [ $# -eq 0 ] ; then
24+
echo "$0 [DB] [PATTERN ...]"
25+
echo "Load one or more RDF files into Jena Fuseki TDB database DB."
26+
echo ""
27+
echo "Current directory is assumed to be /staging"
28+
echo ""
29+
echo 'PATTERNs can be a filename or a shell glob pattern like *ttl'
30+
echo ""
31+
echo "If no PATTERN are given, the default patterns are searched:"
32+
echo "$PATTERNS"
33+
echo ""
34+
echo "Set the environment variable TDBLOADER_OPTS for any additional"
35+
echo "options to pass to tdbloader, e.g. --graph=https://example.org/graph#name
36+
exit 0
37+
fi
38+
39+
cd /staging 2>/dev/null || echo "/staging not found" >&2
40+
echo "Current directory:" $(pwd)
41+
42+
DB=$1
43+
shift
44+
45+
if [ $# -eq 0 ] ; then
46+
patterns="$PATTERNS"
47+
else
48+
patterns="$@"
49+
fi
50+
51+
files=""
52+
for f in $patterns; do
53+
if [ -f $f ] ; then
54+
files="$files $f"
55+
else
56+
if [ $# -gt 0 ] ; then
57+
# User-specified file/pattern missing
58+
echo "WARNING: Not found: $f" >&2
59+
fi
60+
fi
61+
done
62+
63+
if [ "$files" == "" ] ; then
64+
echo "No files found for: " >&2
65+
echo "$patterns" >&2
66+
exit 1
67+
fi
68+
69+
echo "#########"
70+
echo "Loading to Fuseki TDB database $DB:"
71+
echo ""
72+
echo $files
73+
echo "#########"
74+
75+
exec $FUSEKI_HOME/tdbloader $TDBLOADER_OPTS --loc=$FUSEKI_BASE/databases/$DB $files

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
</parent>
1010
<groupId>eu.nampi</groupId>
1111
<artifactId>backend</artifactId>
12-
<version>0.2.12</version>
12+
<version>0.3.0</version>
1313
<name>nampi-backend</name>
1414
<description>The NAMPI backend</description>
1515

shiro.ini

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
# Licensed to the Apache Software Foundation (ASF) under one or more
2+
# contributor license agreements. See the NOTICE file distributed with
3+
# this work for additional information regarding copyright ownership.
4+
# The ASF licenses this file to You under the Apache License, Version 2.0
5+
# (the "License"); you may not use this file except in compliance with
6+
# the License. You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
16+
[main]
17+
# Development
18+
ssl.enabled = false
19+
20+
plainMatcher=org.apache.shiro.authc.credential.SimpleCredentialsMatcher
21+
#iniRealm=org.apache.shiro.realm.text.IniRealm
22+
iniRealm.credentialsMatcher = $plainMatcher
23+
24+
#localhost=org.apache.jena.fuseki.authz.LocalhostFilter
25+
26+
[users]
27+
# Implicitly adds "iniRealm = org.apache.shiro.realm.text.IniRealm"
28+
# The admin password will be replaced by value of ADMIN_PASSWORD
29+
# variable by docker-entrypoint.sh on FIRST start up.
30+
admin=${ADMIN_PASSWORD}
31+
32+
[roles]
33+
34+
[urls]
35+
## Control functions open to anyone
36+
/$/status = anon
37+
/$/ping = anon
38+
39+
## and the rest are restricted
40+
/$/** = authcBasic,user[admin]
41+
42+
## Sparql update is restricted
43+
/*/update/** = authcBasic,user[admin]
44+
45+
46+
## If you want simple, basic authentication user/password
47+
## on the operations,
48+
## 1 - set a password in [users]
49+
## 2 - change the line above to:
50+
## /$/** = authcBasic,user[admin]
51+
## and set a better
52+
53+
## or to allow any access.
54+
##/$/** = anon
55+
56+
# Everything else
57+
/**=anon

0 commit comments

Comments
 (0)