Skip to content

Commit

Permalink
feat(support-services): use local gn4 image with dcat-ap
Browse files Browse the repository at this point in the history
  • Loading branch information
jahow committed Oct 18, 2024
1 parent 2ade901 commit 6488aad
Show file tree
Hide file tree
Showing 4 changed files with 109 additions and 1 deletion.
3 changes: 2 additions & 1 deletion support-services/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,8 @@ services:
- '5601:5601'

geonetwork:
image: geonetwork:${GEONETWORK_VERSION}
# image: geonetwork:${GEONETWORK_VERSION}
image: geonetwork-ui/geonetwork-dcat-ap:4.4.6
environment:
ES_HOST: elasticsearch
ES_PROTOCOL: http
Expand Down
62 changes: 62 additions & 0 deletions support-services/gn4/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
FROM alpine/git AS clone
WORKDIR /app
RUN git clone --recursive --depth=1 --shallow-submodules https://github.com/geonetwork/core-geonetwork.git
RUN git clone --recursive --depth=1 --shallow-submodules https://github.com/metadata101/dcat-ap.git


FROM maven:3.9-amazoncorretto-11 AS build

WORKDIR /app
COPY --from=clone /app/core-geonetwork /app
COPY --from=clone /app/dcat-ap /app/schemas/dcat-ap

# reference DCAT-AP plugin (see https://github.com/metadata101/dcat-ap)
RUN sed -i "s#</modules>#<module>dcat-ap</module></modules>#" \
/app/schemas/pom.xml
RUN sed -i 's#</dependencies>#<dependency><groupId>org.geonetwork-opensource.schemas</groupId><artifactId>gn-schema-dcat-ap</artifactId><version>${project.version}</version></dependency></dependencies>#' \
/app/web/pom.xml
RUN sed -i 's#</artifactItems>#<artifactItem><groupId>org.geonetwork-opensource.schemas</groupId><artifactId>gn-schema-dcat-ap</artifactId><type>zip</type><overWrite>false</overWrite><outputDirectory>${schema-plugins.dir}</outputDirectory></artifactItem></artifactItems>#' \
/app/web/pom.xml

RUN mvn install -DskipTests


FROM jetty:9-jdk11

ENV DATA_DIR /catalogue-data
ENV WEBAPP_CONTEXT_PATH /geonetwork
ENV GN_CONFIG_PROPERTIES -Dgeonetwork.dir=${DATA_DIR} \
-Dgeonetwork.formatter.dir=${DATA_DIR}/data/formatter \
-Dgeonetwork.schema.dir=/opt/geonetwork/WEB-INF/data/config/schema_plugins \
-Dgeonetwork.indexConfig.dir=/opt/geonetwork/WEB-INF/data/config/index

ENV JAVA_OPTS -Djava.security.egd=file:/dev/./urandom -Djava.awt.headless=true \
-Xms512M -Xss512M -Xmx2G -XX:+UseConcMarkSweepGC

USER root
RUN apt-get -y update && \
apt-get -y install --no-install-recommends \
unzip && \
rm -rf /var/lib/apt/lists/* && \
mkdir -p ${DATA_DIR} && \
chown -R jetty:jetty ${DATA_DIR} && \
mkdir -p /opt/geonetwork && \
chown -R jetty:jetty /opt/geonetwork

USER jetty

COPY --from=build /app/web/target/geonetwork.war /opt/geonetwork/

RUN cd /opt/geonetwork/ && \
unzip -q geonetwork.war && \
rm geonetwork.war

COPY jetty/geonetwork_context_template.xml /usr/local/share/geonetwork/geonetwork_context_template.xml
COPY ./docker-entrypoint.sh /geonetwork-entrypoint.sh

RUN java -jar /usr/local/jetty/start.jar --create-startd --add-module=http-forwarded

ENTRYPOINT ["/geonetwork-entrypoint.sh"]
CMD ["java","-jar","/usr/local/jetty/start.jar"]

VOLUME [ "${DATA_DIR}" ]
28 changes: 28 additions & 0 deletions support-services/gn4/docker-entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/bin/bash
set -e

export JAVA_OPTIONS="${JAVA_OPTS} ${GN_CONFIG_PROPERTIES}"

GN_BASE_DIR=/opt/geonetwork

if ! command -v -- "$1" >/dev/null 2>&1 ; then
set -- java -jar "$JETTY_HOME/start.jar" "$@"
fi

if [[ "$1" = jetty.sh ]] || [[ $(expr "$*" : 'java .*/start\.jar.*$') != 0 ]]; then
# Customize context path
if [ ! -f "{$JETTY_BASE}/webapps/geonetwork.xml" ]; then
echo "Using $WEBAPP_CONTEXT_PATH for deploying the application"
cp /usr/local/share/geonetwork/geonetwork_context_template.xml "${JETTY_BASE}/webapps/geonetwork.xml"
sed -i "s#GEONETWORK_CONTEXT_PATH#${WEBAPP_CONTEXT_PATH}#" "${JETTY_BASE}/webapps/geonetwork.xml"
fi

# Delegate on base image entrypoint to start jetty
exec /docker-entrypoint.sh "$@"
else
exec "$@"
fi

# set XSRF cookie path on "/"
RUN sed -i 's#<property name="cookieHttpOnly" value="false"/>#<property name="cookieHttpOnly" value="false"/><property name="cookiePath" value="/"/>#' \
${GN_BASE_DIR}/WEB-INF/config-security/config-security-core.xml
17 changes: 17 additions & 0 deletions support-services/gn4/jetty/geonetwork_context_template.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "http://www.eclipse.org/jetty/configure_9_3.dtd">

<Configure class="org.eclipse.jetty.webapp.WebAppContext">
<Set name="contextPath">GEONETWORK_CONTEXT_PATH</Set>
<Set name="war">/opt/geonetwork</Set>
<Get name="systemClasspathPattern">
<Call name="add"><Arg>-javax.mail.</Arg></Call>
</Get>
<Get name="serverClasspathPattern">
<Call name="add"><Arg>javax.mail.</Arg></Call>
</Get>
<Call name="setAttribute">
<Arg>org.eclipse.jetty.server.webapp.WebInfIncludeJarPattern</Arg>
<Arg>nomatches</Arg>
</Call>
</Configure>

0 comments on commit 6488aad

Please sign in to comment.