Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Add a custom docker image for GeoNetwork 4 + DCAT-AP plugin #1021

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions .github/workflows/gn4-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Artifacts
run-name: 📦 Generate GN4 + DCAT-AP docker image

on: push

concurrency:
group: gn4-build-${{ github.ref }}
cancel-in-progress: true

jobs:
build-gn4-docker:
name: Build custom docker image for GeoNetwork 4
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ needs.checks.outputs.ref }} # use the PR head ref if applicable; otherwise keep default behaviour
persist-credentials: false
fetch-depth: 0

- name: Login to DockerHub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_PASSWORD }}

- name: Build GN4 docker image
working-directory: support-services/gn4
run: docker build . -t geonetwork/geonetwork-dcat-ap:latest

- name: Push GN4 docker image
run: docker push geonetwork/geonetwork-dcat-ap:latest
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/geonetwork-dcat-ap:latest
environment:
ES_HOST: elasticsearch
ES_PROTOCOL: http
Expand Down
65 changes: 65 additions & 0 deletions support-services/gn4/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
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 thesauri/place/* /opt/geonetwork/WEB-INF/data/config/codelist/external/thesauri/place/
COPY thesauri/theme/* /opt/geonetwork/WEB-INF/data/config/codelist/external/thesauri/theme/

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}" ]
24 changes: 24 additions & 0 deletions support-services/gn4/docker-entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/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
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>
Loading
Loading