Skip to content

Commit

Permalink
fix(webapp): revert to hardcoded default for dirs in glassfish-web.xml
Browse files Browse the repository at this point in the history
…IQSS#9662

Payara does not support looking up variables in default values of a lookup.
As a consequence, we must return to the hardcoded "./docroot" and "./uploads"
and instead supply default values using two environment variables in the
applications' Dockerfile. This way they stay configurable from cmdline or
other sources of env vars.
  • Loading branch information
poikilotherm committed Aug 22, 2023
1 parent 72722e7 commit 431afed
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 7 deletions.
5 changes: 5 additions & 0 deletions src/main/docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ FROM $BASE_IMAGE
# See also https://download.eclipse.org/microprofile/microprofile-config-3.0/microprofile-config-spec-3.0.html#configprofile
ENV MP_CONFIG_PROFILE=ct

# Workaround to configure upload directories by default to useful place until we can have variable lookups in
# defaults for glassfish-web.xml and other places.
ENV DATAVERSE_FILES_UPLOADS="${STORAGE_DIR}/uploads"
ENV DATAVERSE_FILES_DOCROOT="${STORAGE_DIR}/docroot"

# Copy app and deps from assembly in proper layers
COPY --chown=payara:payara maven/deps ${DEPLOY_DIR}/dataverse/WEB-INF/lib/
COPY --chown=payara:payara maven/app ${DEPLOY_DIR}/dataverse/
Expand Down
4 changes: 2 additions & 2 deletions src/main/resources/META-INF/microprofile-config.properties
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ dataverse.build=
dataverse.files.directory=/tmp/dataverse
# The variables are replaced with the environment variables from our base image, but still easy to override
%ct.dataverse.files.directory=${STORAGE_DIR}
# NOTE: the following uses STORAGE_DIR for both containers and classic installations. By defaulting to
# "com.sun.aas.instanceRoot" if not present, it equals the hardcoded former default "." in glassfish-web.xml
# NOTE: The following uses STORAGE_DIR for both containers and classic installations. By defaulting to
# "com.sun.aas.instanceRoot" if not present, it equals the hardcoded default "." in glassfish-web.xml
# (which is relative to the domain root folder).
# Also, be aware that this props file cannot provide any value for lookups in glassfish-web.xml during servlet
# initialization, as this file will not have been read yet! The names and their values are in sync here and over
Expand Down
14 changes: 9 additions & 5 deletions src/main/webapp/WEB-INF/glassfish-web.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,17 @@
<parameter-encoding default-charset="UTF-8"/>
<!-- Find a list of properties here: https://docs.oracle.com/cd/E19798-01/821-1750/beayb/index.html -->
<!-- NOTE: relative paths given will be relative to com.sun.aas.instanceRoot (usually domain1 folder) -->
<property name="alternatedocroot_1" value="from=/guides/* dir=${MPCONFIG=dataverse.files.docroot:${ENV=STORAGE_DIR:.}/docroot}"/>
<property name="alternatedocroot_2" value="from=/dataexplore/* dir=${MPCONFIG=dataverse.files.docroot:${ENV=STORAGE_DIR:.}/docroot}"/>
<property name="alternatedocroot_logos" value="from=/logos/* dir=${MPCONFIG=dataverse.files.docroot:${ENV=STORAGE_DIR:.}/docroot}"/>
<property name="alternatedocroot_sitemap" value="from=/sitemap/* dir=${MPCONFIG=dataverse.files.docroot:${ENV=STORAGE_DIR:.}/docroot}"/>
<!-- NOTE: As we cannot use variables in defaults of ${MPCONFIG}, there is a workaround for containers necessary;
see src/main/docker/Dockerfile. Once Payara upstream fixes this, we can use STORAGE_DIR here. -->
<property name="alternatedocroot_1" value="from=/guides/* dir=${MPCONFIG=dataverse.files.docroot:./docroot}"/>
<property name="alternatedocroot_2" value="from=/dataexplore/* dir=${MPCONFIG=dataverse.files.docroot:./docroot}"/>
<property name="alternatedocroot_3" value="from=/logos/* dir=${MPCONFIG=dataverse.files.docroot:./docroot}"/>
<property name="alternatedocroot_4" value="from=/sitemap/* dir=${MPCONFIG=dataverse.files.docroot:./docroot}"/>
<!--
This folder is not only holding compiled JSP pages but also the place where file streams are stored
during uploads. As Dataverse does not use any JSP, there will only be uploads stored here.
-->
<property name="tempdir" value="${MPCONFIG=dataverse.files.uploads:${ENV=STORAGE_DIR:.}/uploads}"/>
<!-- NOTE: As we cannot use variables in defaults of ${MPCONFIG}, there is a workaround for containers necessary;
see src/main/docker/Dockerfile. Once Payara upstream fixes this, we can use STORAGE_DIR here. -->
<property name="tempdir" value="${MPCONFIG=dataverse.files.uploads:./uploads}"/>
</glassfish-web-app>

0 comments on commit 431afed

Please sign in to comment.