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

- Added geonetwork library #2113

Merged
merged 8 commits into from Jan 31, 2017

Conversation

Projects
None yet
5 participants
@doublebyte1
Contributor

doublebyte1 commented Sep 2, 2016

Adding library file for geonetwork, the catalog service for geospatial information.

The default image ships with an H2 database backend, and a variant is included which supports connecting to a postgresql instance.
This image also supports setting a custom data directory, which is recommended for production environments.

We will support all major and minor versions, from the latest branch.

geonetwork

Checklist for Review

NOTE: This checklist is intended for the use of the Official Images maintainers both to track the status of your PR and to help inform you and others of where we're at. As such, please leave the "checking" of items to the repository maintainers. If there is a point below for which you would like to provide additional information or note completion, please do so by commenting on the PR. Thanks! (and thanks for staying patient with us ❤️)

  • associated with or contacted upstream?
  • https://github.com/geonetwork
  • does it fit into one of the common categories? ("service", "language stack", "base distribution")
  • is it reasonably popular, or does it solve a particular use case well?
  • does a documentation PR exist? (should be reviewed and merged at roughly the same time so that we don't have an empty image page on the Hub for very long)
  • docker-library/docs#683
  • dockerization review for best practices and cache gotchas/improvements (ala the official review guidelines)?
  • 2+ dockerization review?
  • existing official images have been considered as a base? (ie, if foobar needs Node.js, has FROM node:... instead of grabbing node via other means been considered?)
  • FROM tomcat
  • if FROM scratch, tarballs only exist in a single commit within the associated history?
  • passes current tests? any simple new tests that might be appropriate to add? (https://github.com/docker-library/official-images/tree/master/test)

@tianon tianon added the new-image label Oct 5, 2016

@tianon

This comment has been minimized.

Show comment
Hide comment
@tianon

tianon Nov 2, 2016

Member

Apologies for the delay! 😞

My first question would be whether you've been in contact with GeoNetwork upstream to see if they're either interested in being involved, maintaining the image, providing their blessing for your ownership/maintainership of it, or would even rather there weren't an official image for GeoNetwork at all (which has happened before)? 🙏 😅

Member

tianon commented Nov 2, 2016

Apologies for the delay! 😞

My first question would be whether you've been in contact with GeoNetwork upstream to see if they're either interested in being involved, maintaining the image, providing their blessing for your ownership/maintainership of it, or would even rather there weren't an official image for GeoNetwork at all (which has happened before)? 🙏 😅

@doublebyte1

This comment has been minimized.

Show comment
Hide comment
@doublebyte1

doublebyte1 Nov 9, 2016

Contributor

Thanks for getting in touch @tianon . No one in the upstream geonetwork opposed to having this image, and actually two of the members are in GeoCat, so we are happy to maintain this image along with the software. I have now moved the docker code to the geonetwork official repository, to make it a bit more "official".
We are all looking forward to having this official geonetwork image! :-)

Contributor

doublebyte1 commented Nov 9, 2016

Thanks for getting in touch @tianon . No one in the upstream geonetwork opposed to having this image, and actually two of the members are in GeoCat, so we are happy to maintain this image along with the software. I have now moved the docker code to the geonetwork official repository, to make it a bit more "official".
We are all looking forward to having this official geonetwork image! :-)

@tianon

This comment has been minimized.

Show comment
Hide comment
@tianon

tianon Nov 23, 2016

Member

Thanks @doublebyte1; that's excellent! ❤️ ❤️

Looking through the Dockerization at a rough glance, I've got the following notes so far:

  1. RUN apt-get update && apt-get install -y postgresql-client should include && rm -rf /var/lib/apt/lists/* to delete the list files apt-get update downloaded

  2. that entrypoint script is going to need some modification for https://github.com/docker-library/official-images/blob/20311d4ee3ecf4f832e405089f06ce83dd1972e5/README.md#consistency (it would probably make sense to move catalina.sh run into CMD, copied from tomcat; CMD ["catalina.sh", "run"], and then end your entrypoint with exec "$@" and use an if to guard the additional behavior against being run against something that isn't catalina.sh)

  3. ENV BASE_DIR is the same value as ENV CATALINA_HOME from the tomcat image, isn't it? Any particular reason it needs to be redefined?

  4. does the geonetwork application need to be both in .war and extracted formats as the image does now, or could the .war file be removed after extraction?

  5. the base image already does EXPOSE 8080, so that's redundant 😄 👍

I'm happy to send a PR for any/all of this if that'd make it easier to understand/discuss or if that'd help get it implemented. 👍

Member

tianon commented Nov 23, 2016

Thanks @doublebyte1; that's excellent! ❤️ ❤️

Looking through the Dockerization at a rough glance, I've got the following notes so far:

  1. RUN apt-get update && apt-get install -y postgresql-client should include && rm -rf /var/lib/apt/lists/* to delete the list files apt-get update downloaded

  2. that entrypoint script is going to need some modification for https://github.com/docker-library/official-images/blob/20311d4ee3ecf4f832e405089f06ce83dd1972e5/README.md#consistency (it would probably make sense to move catalina.sh run into CMD, copied from tomcat; CMD ["catalina.sh", "run"], and then end your entrypoint with exec "$@" and use an if to guard the additional behavior against being run against something that isn't catalina.sh)

  3. ENV BASE_DIR is the same value as ENV CATALINA_HOME from the tomcat image, isn't it? Any particular reason it needs to be redefined?

  4. does the geonetwork application need to be both in .war and extracted formats as the image does now, or could the .war file be removed after extraction?

  5. the base image already does EXPOSE 8080, so that's redundant 😄 👍

I'm happy to send a PR for any/all of this if that'd make it easier to understand/discuss or if that'd help get it implemented. 👍

@doublebyte1

This comment has been minimized.

Show comment
Hide comment
@doublebyte1

doublebyte1 Nov 24, 2016

Contributor

Thanks for your useful comments @tianon ! ❤️
Hopefully I addressed them all on my latest commit.

Contributor

doublebyte1 commented Nov 24, 2016

Thanks for your useful comments @tianon ! ❤️
Hopefully I addressed them all on my latest commit.

@tianon

This comment has been minimized.

Show comment
Hide comment
@tianon

tianon Nov 30, 2016

Member

I've created a PR over in geonetwork/docker-geonetwork#1 with some further suggestions (I figured a PR would be easier to discuss around). 👍

Member

tianon commented Nov 30, 2016

I've created a PR over in geonetwork/docker-geonetwork#1 with some further suggestions (I figured a PR would be easier to discuss around). 👍

@doublebyte1

This comment has been minimized.

Show comment
Hide comment
@doublebyte1

doublebyte1 Dec 2, 2016

Contributor

@tianon : I have just merged your commit 👍

Contributor

doublebyte1 commented Dec 2, 2016

@tianon : I have just merged your commit 👍

@tianon tianon requested a review from yosifkit Jan 30, 2017

@yosifkit

This comment has been minimized.

Show comment
Hide comment
@yosifkit

yosifkit Jan 31, 2017

Member

Sorry for the slow reply. 😞

Looked at master branch and it all seems fine to me. I think we just need the library/geonetwork file to be updated in this PR with the new commit references.

On a side note, you may want to combine the RUN sed lines in the postgres Dockerfiles; they edit the same file so it technically duplicates the file for each layer. Not pressing, just something to be aware of and improve in the future to keep the official-images as great examples of Dockerfile best practices.

Member

yosifkit commented Jan 31, 2017

Sorry for the slow reply. 😞

Looked at master branch and it all seems fine to me. I think we just need the library/geonetwork file to be updated in this PR with the new commit references.

On a side note, you may want to combine the RUN sed lines in the postgres Dockerfiles; they edit the same file so it technically duplicates the file for each layer. Not pressing, just something to be aware of and improve in the future to keep the official-images as great examples of Dockerfile best practices.

Show outdated Hide outdated library/geonetwork Outdated
@yosifkit

This comment has been minimized.

Show comment
Hide comment
@yosifkit

yosifkit Jan 31, 2017

Member
diff --git a/geonetwork_3.0-postgres/Dockerfile b/geonetwork_3.0-postgres/Dockerfile
new file mode 100644
index 0000000..10580fd
--- /dev/null
+++ b/geonetwork_3.0-postgres/Dockerfile
@@ -0,0 +1,16 @@
+FROM geonetwork:3.0.5
+
+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"]
diff --git a/geonetwork_3.0-postgres/docker-entrypoint.sh b/geonetwork_3.0-postgres/docker-entrypoint.sh
new file mode 100755
index 0000000..8aba177
--- /dev/null
+++ b/geonetwork_3.0-postgres/docker-entrypoint.sh
@@ -0,0 +1,51 @@
+#!/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"
+
+	#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_admin="admin"
+	db_gn="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
+	for db_name in "$db_admin" "$db_gn"; do
+		if psql -h "$db_host" -U "$POSTGRES_DB_USERNAME" -p "$db_port" -tqc "SELECT 1 FROM pg_database WHERE datname = '$db_name'" | grep -q 1; then
+			echo "database '$db_name' exists; skipping createdb"
+		else
+			createdb -h "$db_host" -U "$POSTGRES_DB_USERNAME" -p "$db_port" -O "$POSTGRES_DB_USERNAME" "$db_name"
+		fi
+	done
+	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 "$@"
diff --git a/geonetwork_3.0-postgres/jdbc.properties b/geonetwork_3.0-postgres/jdbc.properties
new file mode 100644
index 0000000..00a8ba1
--- /dev/null
+++ b/geonetwork_3.0-postgres/jdbc.properties
@@ -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
diff --git a/geonetwork_3.0/Dockerfile b/geonetwork_3.0/Dockerfile
new file mode 100644
index 0000000..46b9fda
--- /dev/null
+++ b/geonetwork_3.0/Dockerfile
@@ -0,0 +1,24 @@
+FROM tomcat:8.0-jre7
+
+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 -Xmx512M -Xss2M -XX:MaxPermSize=512m -XX:+UseConcMarkSweepGC"
+
+#Environment variables
+ENV GN_VERSION 3.0.5
+ENV GN_DOWNLOAD_MD5 1e77c39de4ad156cc9b3c2b033cab359
+
+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"]
diff --git a/geonetwork_3.0/docker-entrypoint.sh b/geonetwork_3.0/docker-entrypoint.sh
new file mode 100755
index 0000000..39f5ba6
--- /dev/null
+++ b/geonetwork_3.0/docker-entrypoint.sh
@@ -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 "$@"
diff --git a/geonetwork_latest/Dockerfile b/geonetwork_latest/Dockerfile
new file mode 100644
index 0000000..3a94850
--- /dev/null
+++ b/geonetwork_latest/Dockerfile
@@ -0,0 +1,24 @@
+FROM tomcat:8.0-jre8
+
+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 -Xmx512M -Xss2M -XX:MaxPermSize=512m -XX:+UseConcMarkSweepGC"
+
+#Environment variables
+ENV GN_VERSION 3.2.0
+ENV GN_DOWNLOAD_MD5 87a84ffb3fbbd662d595c08e1a7fdff2
+
+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"]
diff --git a/geonetwork_latest/docker-entrypoint.sh b/geonetwork_latest/docker-entrypoint.sh
new file mode 100755
index 0000000..39f5ba6
--- /dev/null
+++ b/geonetwork_latest/docker-entrypoint.sh
@@ -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 "$@"
diff --git a/geonetwork_postgres/Dockerfile b/geonetwork_postgres/Dockerfile
new file mode 100644
index 0000000..f756469
--- /dev/null
+++ b/geonetwork_postgres/Dockerfile
@@ -0,0 +1,16 @@
+FROM geonetwork:3.2.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"]
diff --git a/geonetwork_postgres/docker-entrypoint.sh b/geonetwork_postgres/docker-entrypoint.sh
new file mode 100755
index 0000000..8aba177
--- /dev/null
+++ b/geonetwork_postgres/docker-entrypoint.sh
@@ -0,0 +1,51 @@
+#!/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"
+
+	#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_admin="admin"
+	db_gn="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
+	for db_name in "$db_admin" "$db_gn"; do
+		if psql -h "$db_host" -U "$POSTGRES_DB_USERNAME" -p "$db_port" -tqc "SELECT 1 FROM pg_database WHERE datname = '$db_name'" | grep -q 1; then
+			echo "database '$db_name' exists; skipping createdb"
+		else
+			createdb -h "$db_host" -U "$POSTGRES_DB_USERNAME" -p "$db_port" -O "$POSTGRES_DB_USERNAME" "$db_name"
+		fi
+	done
+	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 "$@"
diff --git a/geonetwork_postgres/jdbc.properties b/geonetwork_postgres/jdbc.properties
new file mode 100644
index 0000000..00a8ba1
--- /dev/null
+++ b/geonetwork_postgres/jdbc.properties
@@ -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
Member

yosifkit commented Jan 31, 2017

diff --git a/geonetwork_3.0-postgres/Dockerfile b/geonetwork_3.0-postgres/Dockerfile
new file mode 100644
index 0000000..10580fd
--- /dev/null
+++ b/geonetwork_3.0-postgres/Dockerfile
@@ -0,0 +1,16 @@
+FROM geonetwork:3.0.5
+
+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"]
diff --git a/geonetwork_3.0-postgres/docker-entrypoint.sh b/geonetwork_3.0-postgres/docker-entrypoint.sh
new file mode 100755
index 0000000..8aba177
--- /dev/null
+++ b/geonetwork_3.0-postgres/docker-entrypoint.sh
@@ -0,0 +1,51 @@
+#!/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"
+
+	#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_admin="admin"
+	db_gn="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
+	for db_name in "$db_admin" "$db_gn"; do
+		if psql -h "$db_host" -U "$POSTGRES_DB_USERNAME" -p "$db_port" -tqc "SELECT 1 FROM pg_database WHERE datname = '$db_name'" | grep -q 1; then
+			echo "database '$db_name' exists; skipping createdb"
+		else
+			createdb -h "$db_host" -U "$POSTGRES_DB_USERNAME" -p "$db_port" -O "$POSTGRES_DB_USERNAME" "$db_name"
+		fi
+	done
+	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 "$@"
diff --git a/geonetwork_3.0-postgres/jdbc.properties b/geonetwork_3.0-postgres/jdbc.properties
new file mode 100644
index 0000000..00a8ba1
--- /dev/null
+++ b/geonetwork_3.0-postgres/jdbc.properties
@@ -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
diff --git a/geonetwork_3.0/Dockerfile b/geonetwork_3.0/Dockerfile
new file mode 100644
index 0000000..46b9fda
--- /dev/null
+++ b/geonetwork_3.0/Dockerfile
@@ -0,0 +1,24 @@
+FROM tomcat:8.0-jre7
+
+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 -Xmx512M -Xss2M -XX:MaxPermSize=512m -XX:+UseConcMarkSweepGC"
+
+#Environment variables
+ENV GN_VERSION 3.0.5
+ENV GN_DOWNLOAD_MD5 1e77c39de4ad156cc9b3c2b033cab359
+
+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"]
diff --git a/geonetwork_3.0/docker-entrypoint.sh b/geonetwork_3.0/docker-entrypoint.sh
new file mode 100755
index 0000000..39f5ba6
--- /dev/null
+++ b/geonetwork_3.0/docker-entrypoint.sh
@@ -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 "$@"
diff --git a/geonetwork_latest/Dockerfile b/geonetwork_latest/Dockerfile
new file mode 100644
index 0000000..3a94850
--- /dev/null
+++ b/geonetwork_latest/Dockerfile
@@ -0,0 +1,24 @@
+FROM tomcat:8.0-jre8
+
+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 -Xmx512M -Xss2M -XX:MaxPermSize=512m -XX:+UseConcMarkSweepGC"
+
+#Environment variables
+ENV GN_VERSION 3.2.0
+ENV GN_DOWNLOAD_MD5 87a84ffb3fbbd662d595c08e1a7fdff2
+
+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"]
diff --git a/geonetwork_latest/docker-entrypoint.sh b/geonetwork_latest/docker-entrypoint.sh
new file mode 100755
index 0000000..39f5ba6
--- /dev/null
+++ b/geonetwork_latest/docker-entrypoint.sh
@@ -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 "$@"
diff --git a/geonetwork_postgres/Dockerfile b/geonetwork_postgres/Dockerfile
new file mode 100644
index 0000000..f756469
--- /dev/null
+++ b/geonetwork_postgres/Dockerfile
@@ -0,0 +1,16 @@
+FROM geonetwork:3.2.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"]
diff --git a/geonetwork_postgres/docker-entrypoint.sh b/geonetwork_postgres/docker-entrypoint.sh
new file mode 100755
index 0000000..8aba177
--- /dev/null
+++ b/geonetwork_postgres/docker-entrypoint.sh
@@ -0,0 +1,51 @@
+#!/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"
+
+	#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_admin="admin"
+	db_gn="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
+	for db_name in "$db_admin" "$db_gn"; do
+		if psql -h "$db_host" -U "$POSTGRES_DB_USERNAME" -p "$db_port" -tqc "SELECT 1 FROM pg_database WHERE datname = '$db_name'" | grep -q 1; then
+			echo "database '$db_name' exists; skipping createdb"
+		else
+			createdb -h "$db_host" -U "$POSTGRES_DB_USERNAME" -p "$db_port" -O "$POSTGRES_DB_USERNAME" "$db_name"
+		fi
+	done
+	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 "$@"
diff --git a/geonetwork_postgres/jdbc.properties b/geonetwork_postgres/jdbc.properties
new file mode 100644
index 0000000..00a8ba1
--- /dev/null
+++ b/geonetwork_postgres/jdbc.properties
@@ -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
@yosifkit

This comment has been minimized.

Show comment
Hide comment
@yosifkit

yosifkit Jan 31, 2017

Member

Build test of #2113; 96b9ccb (geonetwork):

$ bashbrew build geonetwork:3.0.5
Building bashbrew/cache:19622ec90779de2fa26d56b2e13ea9e6939dd45a630c1da424f26f72953fb78f (geonetwork:3.0.5)
Tagging geonetwork:3.0.5
Tagging geonetwork:3.0

$ test/run.sh geonetwork:3.0.5
testing geonetwork:3.0.5
	'utc' [1/4]...passed
	'cve-2014--shellshock' [2/4]...passed
	'no-hard-coded-passwords' [3/4]...passed
	'override-cmd' [4/4]...passed


$ bashbrew build geonetwork:3.0.5-postgres
Building bashbrew/cache:9bf90ac0f6f1f5bf57d88bfe01191ecb52c9c5f07faf6ba9c65e7b7038970832 (geonetwork:3.0.5-postgres)
Tagging geonetwork:3.0.5-postgres
Tagging geonetwork:3.0-postgres

$ test/run.sh geonetwork:3.0.5-postgres
testing geonetwork:3.0.5-postgres
	'utc' [1/4]...passed
	'cve-2014--shellshock' [2/4]...passed
	'no-hard-coded-passwords' [3/4]...passed
	'override-cmd' [4/4]...passed


$ bashbrew build geonetwork:3.2.0
Building bashbrew/cache:8361b49022dc84758c8a86a9ab1f510834c800d671d142c9bcdbd90f7ede4af2 (geonetwork:3.2.0)
Tagging geonetwork:3.2.0
Tagging geonetwork:3.2
Tagging geonetwork:latest

$ test/run.sh geonetwork:3.2.0
testing geonetwork:3.2.0
	'utc' [1/4]...passed
	'cve-2014--shellshock' [2/4]...passed
	'no-hard-coded-passwords' [3/4]...passed
	'override-cmd' [4/4]...passed


$ bashbrew build geonetwork:3.2.0-postgres
Building bashbrew/cache:0393c9c03e5efcd14be023ec229d5dc11c436ec878e6e7ed8020ff4b0db5af3a (geonetwork:3.2.0-postgres)
Tagging geonetwork:3.2.0-postgres
Tagging geonetwork:3.2-postgres
Tagging geonetwork:postgres

$ test/run.sh geonetwork:3.2.0-postgres
testing geonetwork:3.2.0-postgres
	'utc' [1/4]...passed
	'cve-2014--shellshock' [2/4]...passed
	'no-hard-coded-passwords' [3/4]...passed
	'override-cmd' [4/4]...passed
Member

yosifkit commented Jan 31, 2017

Build test of #2113; 96b9ccb (geonetwork):

$ bashbrew build geonetwork:3.0.5
Building bashbrew/cache:19622ec90779de2fa26d56b2e13ea9e6939dd45a630c1da424f26f72953fb78f (geonetwork:3.0.5)
Tagging geonetwork:3.0.5
Tagging geonetwork:3.0

$ test/run.sh geonetwork:3.0.5
testing geonetwork:3.0.5
	'utc' [1/4]...passed
	'cve-2014--shellshock' [2/4]...passed
	'no-hard-coded-passwords' [3/4]...passed
	'override-cmd' [4/4]...passed


$ bashbrew build geonetwork:3.0.5-postgres
Building bashbrew/cache:9bf90ac0f6f1f5bf57d88bfe01191ecb52c9c5f07faf6ba9c65e7b7038970832 (geonetwork:3.0.5-postgres)
Tagging geonetwork:3.0.5-postgres
Tagging geonetwork:3.0-postgres

$ test/run.sh geonetwork:3.0.5-postgres
testing geonetwork:3.0.5-postgres
	'utc' [1/4]...passed
	'cve-2014--shellshock' [2/4]...passed
	'no-hard-coded-passwords' [3/4]...passed
	'override-cmd' [4/4]...passed


$ bashbrew build geonetwork:3.2.0
Building bashbrew/cache:8361b49022dc84758c8a86a9ab1f510834c800d671d142c9bcdbd90f7ede4af2 (geonetwork:3.2.0)
Tagging geonetwork:3.2.0
Tagging geonetwork:3.2
Tagging geonetwork:latest

$ test/run.sh geonetwork:3.2.0
testing geonetwork:3.2.0
	'utc' [1/4]...passed
	'cve-2014--shellshock' [2/4]...passed
	'no-hard-coded-passwords' [3/4]...passed
	'override-cmd' [4/4]...passed


$ bashbrew build geonetwork:3.2.0-postgres
Building bashbrew/cache:0393c9c03e5efcd14be023ec229d5dc11c436ec878e6e7ed8020ff4b0db5af3a (geonetwork:3.2.0-postgres)
Tagging geonetwork:3.2.0-postgres
Tagging geonetwork:3.2-postgres
Tagging geonetwork:postgres

$ test/run.sh geonetwork:3.2.0-postgres
testing geonetwork:3.2.0-postgres
	'utc' [1/4]...passed
	'cve-2014--shellshock' [2/4]...passed
	'no-hard-coded-passwords' [3/4]...passed
	'override-cmd' [4/4]...passed
@tianon

tianon approved these changes Jan 31, 2017

@yosifkit yosifkit merged commit a371603 into docker-library:master Jan 31, 2017

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details
@doublebyte1

This comment has been minimized.

Show comment
Hide comment
@doublebyte1

doublebyte1 Feb 1, 2017

Contributor

@yosifkit @tianon the logo of geonetwork does not show up associated to the image in the official repositories! :-( Do you have any idea why?

Contributor

doublebyte1 commented Feb 1, 2017

@yosifkit @tianon the logo of geonetwork does not show up associated to the image in the official repositories! :-( Do you have any idea why?

@yosifkit

This comment has been minimized.

Show comment
Hide comment
@yosifkit

yosifkit Feb 1, 2017

Member

If you are talking about the icon that shows up when searching on the Docker Hub, we unfortunately have no control over them.

Ping @toli, can you look into the Docker Hub icons for the Geonetwork repo? (Should I be pinging anyone else here?) Thanks!

Member

yosifkit commented Feb 1, 2017

If you are talking about the icon that shows up when searching on the Docker Hub, we unfortunately have no control over them.

Ping @toli, can you look into the Docker Hub icons for the Geonetwork repo? (Should I be pinging anyone else here?) Thanks!

@toli

This comment has been minimized.

Show comment
Hide comment
@toli

toli Feb 1, 2017

@doublebyte1 - the logos are handled in the Hub UI itself.
Can you provide me with the location of the logos you want, and i'll file the right ticket with the Hub/Cloud people?

toli commented Feb 1, 2017

@doublebyte1 - the logos are handled in the Hub UI itself.
Can you provide me with the location of the logos you want, and i'll file the right ticket with the Hub/Cloud people?

@doublebyte1

This comment has been minimized.

Show comment
Hide comment
@doublebyte1

doublebyte1 Feb 1, 2017

Contributor

@toli that would be awesome! This would be the logo file :-) Many thnx!!

Contributor

doublebyte1 commented Feb 1, 2017

@toli that would be awesome! This would be the logo file :-) Many thnx!!

@toli

This comment has been minimized.

Show comment
Hide comment
@toli

toli Feb 1, 2017

Filed an internal issue, will try to get it through but no promises on timing.
Thanks for the link to the logo.

toli commented Feb 1, 2017

Filed an internal issue, will try to get it through but no promises on timing.
Thanks for the link to the logo.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment