Skip to content

Commit

Permalink
Merge pull request #1 from geonetwork/master
Browse files Browse the repository at this point in the history
update parent
  • Loading branch information
anthieni authored Jan 25, 2018
2 parents 507a1d8 + 067c56d commit f431eec
Show file tree
Hide file tree
Showing 13 changed files with 249 additions and 3 deletions.
2 changes: 1 addition & 1 deletion 3.2.0/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ 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"
ENV JAVA_OPTS="-Djava.security.egd=file:/dev/./urandom -Djava.awt.headless=true -Xmx512M -Xss2M -XX:+UseConcMarkSweepGC"

#Environment variables
ENV GN_VERSION 3.2.0
Expand Down
2 changes: 1 addition & 1 deletion 3.2.1/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ 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 -server -Xms512m -Xmx2024m -XX:NewSize=512m -XX:MaxNewSize=1024m -XX:PermSize=512m -XX:MaxPermSize=1024m -XX:+UseConcMarkSweepGC"
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.2.1
Expand Down
24 changes: 24 additions & 0 deletions 3.2.2/Dockerfile
Original file line number Diff line number Diff line change
@@ -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 -server -Xms512m -Xmx2024m -XX:NewSize=512m -XX:MaxNewSize=1024m -XX:+UseConcMarkSweepGC"

#Environment variables
ENV GN_VERSION 3.2.2
ENV GN_DOWNLOAD_MD5 93b5279223503106ffeea3e9ca697805

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.2.2/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.2.2/postgres/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
FROM geonetwork:3.2.2

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"]
51 changes: 51 additions & 0 deletions 3.2.2/postgres/docker-entrypoint.sh
Original file line number Diff line number Diff line change
@@ -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 "$@"
17 changes: 17 additions & 0 deletions 3.2.2/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
24 changes: 24 additions & 0 deletions 3.4.0/Dockerfile
Original file line number Diff line number Diff line change
@@ -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 -server -Xms512m -Xmx2024m -XX:NewSize=512m -XX:MaxNewSize=1024m -XX:+UseConcMarkSweepGC"

#Environment variables
ENV GN_VERSION 3.4.0
ENV GN_DOWNLOAD_MD5 f7d274a5f49d5f0968b204d290308943

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.4.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.4.0/postgres/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
FROM geonetwork:3.4.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"]
51 changes: 51 additions & 0 deletions 3.4.0/postgres/docker-entrypoint.sh
Original file line number Diff line number Diff line change
@@ -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 "$@"
17 changes: 17 additions & 0 deletions 3.4.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
8 changes: 7 additions & 1 deletion generate-stackbrew-library.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,12 @@ set -eu

declare -A aliases=(
[3.0.5]='3.0'
[3.2.0]='3.2 latest'
[3.2.2]='3.2 latest'
)

# builds to exclude from tagging
dirExclude=([3.2.0],[3.2.1])

self="$(basename "$BASH_SOURCE")"
cd "$(dirname "$(readlink -f "$BASH_SOURCE")")"

Expand Down Expand Up @@ -49,6 +52,8 @@ join() {
}

for version in "${versions[@]}"; do
if ! (echo ${dirExclude[@]} | grep -w $version > /dev/null) ; then

commit="$(dirCommit "$version")"

fullVersion="$(git show "$commit":"$version/Dockerfile" | awk '$1 == "ENV" && $2 == "GN_VERSION" { print $3; exit }')"
Expand Down Expand Up @@ -80,4 +85,5 @@ for version in "${versions[@]}"; do
Directory: $version/$variant
EOE
done
fi
done

0 comments on commit f431eec

Please sign in to comment.