Skip to content

Commit

Permalink
Merge pull request #3 from elcoloo/master
Browse files Browse the repository at this point in the history
Actualizar fork
  • Loading branch information
anthieni authored Feb 22, 2018
2 parents f431eec + bd368dc commit 048e868
Show file tree
Hide file tree
Showing 6 changed files with 124 additions and 3 deletions.
24 changes: 24 additions & 0 deletions 3.4.1/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.1
ENV GN_DOWNLOAD_MD5 7fc1e3b86769f314618df4321cf95cbc

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

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.1/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.1/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
7 changes: 4 additions & 3 deletions generate-stackbrew-library.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@ set -eu

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

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

self="$(basename "$BASH_SOURCE")"
cd "$(dirname "$(readlink -f "$BASH_SOURCE")")"
Expand Down Expand Up @@ -76,7 +77,7 @@ for version in "${versions[@]}"; do
commit="$(dirCommit "$version/$variant")"

variantAliases=( "${versionAliases[@]/%/-$variant}" )
variantAliases=( "${variantAliases[@]//latest-/}" )
#variantAliases=( "${variantAliases[@]//latest-/}" )

echo
cat <<-EOE
Expand Down

0 comments on commit 048e868

Please sign in to comment.