Skip to content

Commit

Permalink
locally building docker container with 'overlayed' war
Browse files Browse the repository at this point in the history
  • Loading branch information
cmangeat committed Oct 24, 2024
1 parent 2e3fa52 commit 7d93974
Show file tree
Hide file tree
Showing 8 changed files with 295 additions and 3 deletions.
6 changes: 3 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -70,13 +70,13 @@
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.2.0</version>
<--! higher than 4.4.6 -->
<!-- higher than 4.4.6 -->
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>3.3.0</version>
<--! higher than 4.4.6 -->
<!-- higher than 4.4.6 -->
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
Expand Down Expand Up @@ -109,7 +109,7 @@

<modules>
<module>core-geonetwork</module>
<!-- <module>web</module> -->
<module>web</module>
<module>release</module>
</modules>

Expand Down
44 changes: 44 additions & 0 deletions release/docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
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 \
curl \
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
ENV GN_FILE geonetwork.war
ENV GN_VERSION 4.4.6
ENV GN_DOWNLOAD_MD5 ad596d3348872506c78daa05edb14782

COPY geonetwork-4.4.6-0-swiss-custom.zip /opt/geonetwork/geonetwork-4.4.6-0-swiss-custom.zip
RUN cd /opt/geonetwork/ && \
unzip -q geonetwork-4.4.6-0-swiss-custom.zip && \
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}" ]
25 changes: 25 additions & 0 deletions release/docker/docker-entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/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 release/docker/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>
78 changes: 78 additions & 0 deletions release/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>swiss-experiment</groupId>
<artifactId>geonetwork</artifactId>
<version>4.4.6-0</version>
</parent>

<artifactId>release</artifactId>
<packaging>pom</packaging>

<name>GeoNetwork ${project.version} ${customer} Release</name>
<description>
Release packaging including installation notes and appropriate open source licenses.
</description>

<dependencies>
<!-- war includes prebuilt geonetwork jars -->
<dependency>
<groupId>swiss-experiment</groupId>
<artifactId>web</artifactId>
<version>${project.version}</version>
<type>war</type>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>3.3.1</version>
<executions>
<execution>
<id>copy-resources</id>
<phase>validate</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>${basedir}/target/docker</outputDirectory>
<resources>
<resource>
<directory>docker</directory>
<filtering>false</filtering>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<executions>
<execution>
<id>bundle</id>
<phase>package</phase>
<goals><goal>single</goal></goals>
<configuration>
<recompressZippedFiles>false</recompressZippedFiles>
<descriptors>
<descriptor>src/assembly/bundle.xml</descriptor>
</descriptors>
<appendAssemblyId>false</appendAssemblyId>
<outputDirectory>${project.build.directory}/docker</outputDirectory>
<finalName>geonetwork-${project.version}-${customer.bundle}</finalName>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>

</project>

49 changes: 49 additions & 0 deletions release/src/assembly/bundle.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<assembly>
<id>geonetwork</id>
<formats>
<format>zip</format>
</formats>
<includeBaseDirectory>false</includeBaseDirectory>
<fileSets>
<!-- plugin folder -->
<fileSet>
<directory>../web/target</directory>
<outputDirectory></outputDirectory>
<includes>
<include>*.war</include>
</includes>
</fileSet>
</fileSets>
<files>
<file>
<source>toto.txt</source>
<outputDirectory></outputDirectory>
<destName>toto.txt</destName>
</file>
</files>
<!--
<dependencySets>
<dependencySet>
<includes>
<include>*:web:war</include>
</includes>
</dependencySet>
</dependencySets>-->
<!--moduleSets>
<moduleSet>
<useAllReactorProjects>true</useAllReactorProjects>
<includes>
<include>hnap-experiment:web</include>
</includes>
<sources>
<includeModuleDirectory>false</includeModuleDirectory>
<fileSets>
<fileSet>
<outputDirectory>sources/${module.artifactId}</outputDirectory>
</fileSet>
</fileSets>
</sources>
</moduleSet>
</moduleSets-->
</assembly>

1 change: 1 addition & 0 deletions release/toto.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
;-)
78 changes: 78 additions & 0 deletions web/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>swiss-experiment</groupId>
<artifactId>geonetwork</artifactId>
<version>4.4.6-0</version>
</parent>

<artifactId>web</artifactId>
<packaging>war</packaging>

<name>GeoNetwork Web Application for ${customer}</name>
<description>
Web application using maven war overlay functionality to reuse
geonetwork war and hnap schema plugin for ${customer}.
</description>

<properties>
<build.webapp.resources>${project.build.directory}/webapp</build.webapp.resources>
<jetty.env>jetty-env.xml</jetty.env>
</properties>

<dependencies>
<!-- war includes prebuilt geonetwork jars -->
<dependency>
<groupId>org.geonetwork-opensource</groupId>
<artifactId>web-app</artifactId>
<version>${project.version}</version>
<type>war</type>
<scope>runtime</scope>
</dependency>
</dependencies>

<build>
<finalName>geonetwork</finalName>
<plugins>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<configuration>
<overlays>
<overlay>
<groupId>org.geonetwork-opensource</groupId>
<artifactId>web-app</artifactId>
</overlay>
</overlays>
</configuration>
</plugin>

<plugin>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<version>${jetty.version}</version>
<configuration>
<contextXml>${basedir}/jetty-context.xml</contextXml>
<webApp>
<contextPath>/geonetwork</contextPath>
<jettyEnvXml>${jetty.env}</jettyEnvXml>
</webApp>
</configuration>
<!--<dependencies>
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<version>1.3.174</version>
</dependency>
</dependencies>-->
</plugin>
</plugins>

</build>

</project>

0 comments on commit 7d93974

Please sign in to comment.