Skip to content

Commit

Permalink
Release of GeoNetwork v3.10.0 (#39)
Browse files Browse the repository at this point in the history
  • Loading branch information
juanluisrp authored Jan 27, 2020
1 parent af81a4f commit 2e46c35
Show file tree
Hide file tree
Showing 5 changed files with 124 additions and 0 deletions.
24 changes: 24 additions & 0 deletions 3.10.0/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
FROM tomcat:8.5-jdk8

ENV GN_FILE geonetwork.war
ENV DATA_DIR=$CATALINA_HOME/webapps/geonetwork/WEB-INF/data
ENV JAVA_OPTS="-Djava.security.egd=file:/dev/./urandom -Djava.awt.headless=true -server -Xms512m -Xmx2024m -XX:NewSize=512m -XX:MaxNewSize=1024m -XX:+UseConcMarkSweepGC"

#Environment variables
ENV GN_VERSION 3.10.0
ENV GN_DOWNLOAD_MD5 86b18cd2ef60f11dd1dbe055054cee97

WORKDIR $CATALINA_HOME/webapps

RUN curl -fSL -o $GN_FILE \
https://sourceforge.net/projects/geonetwork/files/GeoNetwork_opensource/v${GN_VERSION}/geonetwork.war/download && \
echo "$GN_DOWNLOAD_MD5 *$GN_FILE" | md5sum -c && \
mkdir -p geonetwork && \
unzip -e $GN_FILE -d geonetwork && \
rm $GN_FILE

#Set geonetwork data dir
COPY ./docker-entrypoint.sh /entrypoint.sh
ENTRYPOINT ["/entrypoint.sh"]

CMD ["catalina.sh", "run"]
12 changes: 12 additions & 0 deletions 3.10.0/docker-entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/bash
set -e

if [ "$1" = 'catalina.sh' ]; then

mkdir -p "$DATA_DIR"

#Set geonetwork data dir
export CATALINA_OPTS="$CATALINA_OPTS -Dgeonetwork.dir=$DATA_DIR"
fi

exec "$@"
16 changes: 16 additions & 0 deletions 3.10.0/postgres/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
FROM geonetwork:3.10.0

RUN apt-get update && apt-get install -y postgresql-client && \
rm -rf /var/lib/apt/lists/*

#Set PostgreSQL as default GN DB
RUN sed -i -e 's#<import resource="../config-db/h2.xml"/>#<!--<import resource="../config-db/h2.xml"/> -->#g' $CATALINA_HOME/webapps/geonetwork/WEB-INF/config-node/srv.xml && \
sed -i -e 's#<!--<import resource="../config-db/postgres.xml"/>-->#<import resource="../config-db/postgres.xml"/>#g' $CATALINA_HOME/webapps/geonetwork/WEB-INF/config-node/srv.xml

COPY ./jdbc.properties $CATALINA_HOME/webapps/geonetwork/WEB-INF/config-db/jdbc.properties

#Initializing database & connection string for GN
COPY ./docker-entrypoint.sh /entrypoint.sh
ENTRYPOINT ["/entrypoint.sh"]

CMD ["catalina.sh", "run"]
55 changes: 55 additions & 0 deletions 3.10.0/postgres/docker-entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
#!/bin/bash
set -e

if [ "$1" = 'catalina.sh' ]; then


if [ ! -d "$DATA_DIR" ]; then
echo "$Data directory '$DATA_DIR' does not exist. Creating it..."
mkdir -p "$DATA_DIR"
fi

#Set geonetwork data dir
export CATALINA_OPTS="$CATALINA_OPTS -Dgeonetwork.dir=$DATA_DIR"

#Setting host (use $POSTGRES_DB_HOST if it's set, otherwise use "postgres")
db_host="${POSTGRES_DB_HOST:-postgres}"
echo "db host: $db_host"

#Setting port
db_port="${POSTGRES_DB_PORT:-5432}"
echo "db port: $db_port"

if [ -z "$POSTGRES_DB_USERNAME" ] || [ -z "$POSTGRES_DB_PASSWORD" ]; then
echo >&2 "you must set POSTGRES_DB_USERNAME and POSTGRES_DB_PASSWORD"
exit 1
fi

db_gn="${POSTGRES_DB_NAME:-geonetwork}"

#Create databases, if they do not exist yet (http://stackoverflow.com/a/36591842/433558)
echo "$db_host:$db_port:*:$POSTGRES_DB_USERNAME:$POSTGRES_DB_PASSWORD" > ~/.pgpass
chmod 0600 ~/.pgpass
if psql -h "$db_host" -U "$POSTGRES_DB_USERNAME" -p "$db_port" -tqc "SELECT 1 FROM pg_database WHERE datname = '$db_gn'" | grep -q 1; then
echo "Database '$db_gn' exists; skipping createdb"
elif psql -h "$db_host" -U "$POSTGRES_DB_USERNAME" -p "$db_port" -d "$db_gn" -tqc "SELECT 1 FROM pg_database WHERE datname = '$db_gn'" | grep -q 1;then
echo "Database '$db_gn' already exist; skipping database creation"
else
echo "Database '$db_gn' doesn't exist. Creating it..."
createdb -h "$db_host" -U "$POSTGRES_DB_USERNAME" -p "$db_port" -O "$POSTGRES_DB_USERNAME" "$db_gn"
fi
rm ~/.pgpass

#Write connection string for GN
sed -ri '/^jdbc[.](username|password|database|host|port)=/d' "$CATALINA_HOME"/webapps/geonetwork/WEB-INF/config-db/jdbc.properties
echo "jdbc.username=$POSTGRES_DB_USERNAME" >> "$CATALINA_HOME"/webapps/geonetwork/WEB-INF/config-db/jdbc.properties
echo "jdbc.password=$POSTGRES_DB_PASSWORD" >> "$CATALINA_HOME"/webapps/geonetwork/WEB-INF/config-db/jdbc.properties
echo "jdbc.database=$db_gn" >> "$CATALINA_HOME"/webapps/geonetwork/WEB-INF/config-db/jdbc.properties
echo "jdbc.host=$db_host" >> "$CATALINA_HOME"/webapps/geonetwork/WEB-INF/config-db/jdbc.properties
echo "jdbc.port=$db_port" >> "$CATALINA_HOME"/webapps/geonetwork/WEB-INF/config-db/jdbc.properties

#Fixing an hardcoded port on the connection string (bug fixed on development branch)
sed -i -e 's#5432#${jdbc.port}#g' $CATALINA_HOME/webapps/geonetwork/WEB-INF/config-db/postgres.xml
fi

exec "$@"
17 changes: 17 additions & 0 deletions 3.10.0/postgres/jdbc.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
jdbc.basic.removeAbandoned=true
jdbc.basic.removeAbandonedTimeout=120
jdbc.basic.logAbandoned=true
jdbc.basic.maxActive=33
jdbc.basic.maxIdle=${jdbc.basic.maxActive}
jdbc.basic.initialSize=${jdbc.basic.maxActive}
jdbc.basic.maxWait=200
jdbc.basic.testOnBorrow=true
jdbc.basic.timeBetweenEvictionRunsMillis=10000
jdbc.basic.minEvictableIdleTimeMillis=1800000
jdbc.basic.testWhileIdle=true
jdbc.basic.numTestsPerEvictionRun=3
jdbc.basic.poolPreparedStatements=true
jdbc.basic.maxOpenPreparedStatements=1200
jdbc.basic.validationQuery=SELECT 1
jdbc.basic.defaultReadOnly=false
jdbc.basic.defaultAutoCommit=false

0 comments on commit 2e46c35

Please sign in to comment.