Skip to content

Commit

Permalink
Set password with envsubst to support slash in ADMIN_PASSWORD
Browse files Browse the repository at this point in the history
this fixes #32

Also note that VOLUME /fuseki is now ensured to be empty on first start,
its population from Dockerfile test seems to be a change in later Docker
versions.

Note that it is no longer possible to override the admin password on
second start after shiro.ini exists.
  • Loading branch information
stain committed May 25, 2021
1 parent ec9ebef commit 7c4b9f2
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
6 changes: 5 additions & 1 deletion jena-fuseki/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ LABEL org.opencontainers.image.licenses "(Apache-2.0 AND (GPL-2.0 WITH Classpath
LABEL org.opencontainers.image.authors "Apache Jena Fuseki by https://jena.apache.org/; this image by https://orcid.org/0000-0001-9842-9718"

# Config and data
VOLUME /fuseki
ENV FUSEKI_BASE /fuseki


Expand Down Expand Up @@ -87,6 +86,11 @@ RUN chmod 755 $FUSEKI_HOME/load.sh $FUSEKI_HOME/tdbloader $FUSEKI_HOME/tdbloader

# Where we start our server from
WORKDIR $FUSEKI_HOME

# Make sure we start with empty /fuseki
RUN rm -rf $FUSEKI_BASE
VOLUME $FUSEKI_BASE

EXPOSE 3030
ENTRYPOINT ["/usr/bin/tini", "--", "/docker-entrypoint.sh"]
CMD ["/jena-fuseki/fuseki-server"]
Expand Down
3 changes: 2 additions & 1 deletion jena-fuseki/docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ fi
# $ADMIN_PASSWORD only modifies if ${ADMIN_PASSWORD}
# is in shiro.ini
if [ -n "$ADMIN_PASSWORD" ] ; then
envsubst "$FUSEKI_BASE/shiro.ini" > "$FUSEKI_BASE/shiro.ini.$$" && \
export ADMIN_PASSWORD
envsubst '${ADMIN_PASSWORD}' < "$FUSEKI_BASE/shiro.ini" > "$FUSEKI_BASE/shiro.ini.$$" && \
mv "$FUSEKI_BASE/shiro.ini.$$" "$FUSEKI_BASE/shiro.ini"
unset ADMIN_PASSWORD # Don't keep it in memory
export ADMIN_PASSWORD
Expand Down
4 changes: 2 additions & 2 deletions jena-fuseki/shiro.ini
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@ ssl.enabled = false

plainMatcher=org.apache.shiro.authc.credential.SimpleCredentialsMatcher
#iniRealm=org.apache.shiro.realm.text.IniRealm
iniRealm.credentialsMatcher = org.apache.shiro.authc.credential.SimpleCredentialsMatcher
iniRealm.credentialsMatcher = $plainMatcher

#localhost=org.apache.jena.fuseki.authz.LocalhostFilter

[users]
# Implicitly adds "iniRealm = org.apache.shiro.realm.text.IniRealm"
# The admin password will be replaced by value of ADMIN_PASSWORD
# variable by docker-entrypoint.sh on FIRST start up.
admin=${ADMIN_PASSWORD:-pw123}
admin=${ADMIN_PASSWORD}

[roles]

Expand Down

0 comments on commit 7c4b9f2

Please sign in to comment.