From 3facdfdde729b26a71767cd4b0d860c88320dd44 Mon Sep 17 00:00:00 2001 From: Adan Rehtla Date: Tue, 7 Apr 2020 10:35:25 +1000 Subject: [PATCH 1/4] Working PostgreSQL configuration --- Dockerfile | 14 +++- README.md | 68 ++++++++++++------ config/systemListeners.xml | 47 +++++++++++++ scripts/setup_postgresql.sh | 136 +++++++++++++++++++----------------- 4 files changed, 177 insertions(+), 88 deletions(-) create mode 100644 config/systemListeners.xml diff --git a/Dockerfile b/Dockerfile index 8e265be..d601f50 100644 --- a/Dockerfile +++ b/Dockerfile @@ -40,11 +40,23 @@ RUN rm ${PENTAHO_SERVER}/promptuser.sh # Disable daemon mode for Tomcat RUN sed -i -e 's/\(exec ".*"\) start/\1 run/' ${PENTAHO_SERVER}/tomcat/bin/startup.sh +# Update broken QRTZ SQL +RUN sed -i "s/connect quartz pentaho_user/connect quartz/g" ${PENTAHO_SERVER}/data/postgresql/create_quartz_postgresql.sql + # Copy scripts and fix permissions USER root COPY scripts ${PENTAHO_HOME}/scripts COPY config ${PENTAHO_HOME}/config -RUN chown -R pentaho:pentaho ${PENTAHO_HOME}/scripts && chmod -R +x ${PENTAHO_HOME}/scripts +RUN chown -R pentaho:pentaho ${PENTAHO_HOME}/scripts \ + && chmod -R +x ${PENTAHO_HOME}/scripts +RUN chown -R pentaho:pentaho ${PENTAHO_HOME}/config \ + && chmod -R +x ${PENTAHO_HOME}/config +RUN mkdir -p ${PENTAHO_SERVER}data/hsqldb \ + && chmod 775 -R ${PENTAHO_SERVER}/data/hsqldb \ + && chown pentaho:pentaho -R ${PENTAHO_SERVER}/data/hsqldb +RUN mkdir -p ${PENTAHO_SERVER}/pentaho-solutions/system/jackrabbit/repository \ + && chmod 775 -R ${PENTAHO_SERVER}/pentaho-solutions/system/jackrabbit/repository \ + && chown pentaho:pentaho -R ${PENTAHO_SERVER}/pentaho-solutions/system/jackrabbit/repository USER pentaho # Volumes: diff --git a/README.md b/README.md index 8b0402f..96fe488 100644 --- a/README.md +++ b/README.md @@ -20,31 +20,36 @@ It is based on some really splendid work done by [Wellington Marinho](https://github.com/wmarinho/docker-pentaho). ## Requirements + - [PostgreSQL](https://www.postgresql.org/) 9.4 - `postgres:9.4-alpine` worked nicely for me ## How to run - Start a PostgreSQL server -``` + +```Shell docker run -d -p 5432:5432 --name postgres postgres:9.4-alpine ``` - Run once for testing and auto-clean container -``` + +```Shell docker run --rm -it --link postgres:postgres \ -e PGHOST=postgres -e PGUSER=postgres -e PGPASSWORD= -p 8080:8080 ca0abinary/docker-pentaho ``` - Start in bash, prior to any scripts having executed, auto-clean (for debugging) -``` + +```Shell docker run --rm -it --link postgres:postgres \ -e PGHOST=postgres -e PGUSER=postgres -e PGPASSWORD= -p 8080:8080 \ --entrypoint bash ca0abinary/docker-pentaho ``` - Run as a service -``` + +```Shell docker run -d --link postgres:postgres \ -e PGHOST=postgres -e PGUSER=postgres -e PGPASSWORD= -p 8080:8080 \ ca0abinary/docker-pentaho @@ -61,8 +66,10 @@ keep it in a data container or volume map. - Jackrabbit stores files locally at `/opt/pentaho/server/pentaho-server/pentaho-solutions/system/jackrabbit/repository` Example: -``` + +```shell docker run --rm -it \ +-v ./config/systemListeners.xml:/opt/pentaho/server/pentaho-server/pentaho-solutions/system/systemListeners.xml \ -v /mnt/nfs-share/pentaho/hsqldb:/opt/pentaho/server/pentaho-server/data/hsqldb \ -v /mnt/nfs-share/pentaho/repository:/opt/pentaho/server/pentaho-server/pentaho-solutions/system/jackrabbit/repository \ -p 8080:8080 ca0abinary/docker-pentaho @@ -89,9 +96,33 @@ Default password is `password`. The simplest `docker-compose.yml` file would be: +```YAML +version: "3" +services: + + # Pentaho BI + pentaho: + container_name: pentaho + image: ca0abinary/docker-pentaho + ports: + - "8080:8080" + volumes: + - ./config/systemListeners.xml:/opt/pentaho/server/pentaho-server/pentaho-solutions/system/systemListeners.xml + - pentaho-hsqldb-data:/opt/pentaho/server/pentaho-server/data/hsqldb + - pentaho-jackrabbit-data:/opt/pentaho/server/pentaho-server/pentaho-solutions/system/jackrabbit/repository + +# Data volumes +volumes: + pentaho-hsqldb-data: + pentaho-jackrabbit-data: ``` + +When using PostgreSQL `docker-compose.yml` file would be: + +```YAML version: "3" services: + # Pentaho BI pentaho: container_name: pentaho @@ -101,10 +132,11 @@ services: ports: - "8080:8080" environment: - - HOST=pentaho-pg - - USER=pentaho - - PASSWORD=password + - PGHOST=pentaho-pg + - PGUSER=pentaho + - PGPASSWORD=password volumes: + - ./config/systemListeners.xml:/opt/pentaho/server/pentaho-server/pentaho-solutions/system/systemListeners.xml - pentaho-hsqldb-data:/opt/pentaho/server/pentaho-server/data/hsqldb - pentaho-jackrabbit-data:/opt/pentaho/server/pentaho-server/pentaho-solutions/system/jackrabbit/repository @@ -118,6 +150,11 @@ services: - PGDATA=/var/lib/postgresql/data/pgdata volumes: - pentaho-pg-data:/var/lib/postgresql/data/pgdata + healthcheck: + test: pg_isready -U pgadmin || exit 1 + interval: 30s + timeout: 10s + retries: 3 # Data volumes volumes: @@ -126,21 +163,8 @@ volumes: pentaho-pg-data: ``` -## Problems - -Quartz and Hibernate continue to live on the internal -[HyperSQL](http://hsqldb.org/) database as despite changing the settings to work -with PostgreSQL using the provided documentation I'm not having success. -(`java.sql.SQLException: No suitable driver`) - -The databases will be created in PostgreSQL, just not used. - -Please feel free to examine the `scripts/setup_postgresql.sh` and post a PR if -you can fix it! - ## See Also -- [Wellington -Marinho](https://github.com/wmarinho/docker-pentaho). +- [Wellington Marinho](https://github.com/wmarinho/docker-pentaho). - [Pentaho 7.0 Docker Image](https://github.com/ca0abinary/docker-pentaho). - [Pentaho 7.0 Documentation](https://help.pentaho.com/Documentation/7.0). diff --git a/config/systemListeners.xml b/config/systemListeners.xml new file mode 100644 index 0000000..d5144ad --- /dev/null +++ b/config/systemListeners.xml @@ -0,0 +1,47 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + 86400 + + + + false + + + + + + + + + \ No newline at end of file diff --git a/scripts/setup_postgresql.sh b/scripts/setup_postgresql.sh index 325edb9..fb263df 100644 --- a/scripts/setup_postgresql.sh +++ b/scripts/setup_postgresql.sh @@ -1,78 +1,84 @@ #!/bin/bash if [ "$RDS_HOSTNAME" ]; then - PGHOST="$RDS_HOSTNAME" - PGUSER="$RDS_USERNAME" - PGPASSWORD="$RDS_PASSWORD" - PGDATABASE="$RDS_DB_NAME" - PGPORT="$RDS_PORT" + PGHOST="$RDS_HOSTNAME" + PGUSER="$RDS_USERNAME" + PGPASSWORD="$RDS_PASSWORD" + PGDATABASE="$RDS_DB_NAME" + PGPORT="$RDS_PORT" fi if [ "$PGHOST" ]; then - if [ ! "$PGPORT" ]; then - PGPORT=5432 - fi - if [ ! "$PGDATABASE" ]; then - PGDATABASE=postgres - fi - if [ ! "$PGUSER" ]; then - PGUSER=pgadmin - fi - if [ ! "$PGPASSWORD" ]; then - PGPASSWORD=pgadmin. - - fi - export PGPASSWORD="$PGPASSWORD" - echo "Checking PostgreSQL connection ..." + if [ ! "$PGPORT" ]; then + PGPORT=5432 + fi + if [ ! "$PGDATABASE" ]; then + PGDATABASE=postgres + fi + if [ ! "$PGUSER" ]; then + PGUSER=pgadmin + fi + if [ ! "$PGPASSWORD" ]; then + PGPASSWORD=pgadmin. - nc -zv $PGHOST $PGPORT - - if [ "$?" -ne "0" ]; then - echo "PostgreSQL connection failed." - exit 0 - fi + fi + export PGPASSWORD="$PGPASSWORD" + echo "Checking PostgreSQL connection ..." - CHK_QUARTZ=`echo "$(psql -U $PGUSER -h $PGHOST -d $PGDATABASE -l | grep quartz | wc -l)"` - CHK_HIBERNATE=`echo "$(psql -U $PGUSER -h $PGHOST -d $PGDATABASE -l | grep hibernate | wc -l)"` - CHK_JCR=`echo "$(psql -U $PGUSER -h $PGHOST -d $PGDATABASE -l | grep jackrabbit | wc -l)"` + until psql -h "$PGHOST" -U "$PGUSER" -c '\q'; do + echo >&2 "PostgreSQL is unavailable - sleeping" + sleep 1 + done + sleep 2 - echo "quartz: $CHK_QUARTZ" - echo "hibernate: $CHK_HIBERNATE" - echo "jcr: $CHK_JCR" - - if [ "$CHK_JCR" -eq "0" ]; then - psql -U $PGUSER -h $PGHOST -d $PGDATABASE -f $PENTAHO_SERVER/data/postgresql/create_jcr_postgresql.sql - fi - if [ "$CHK_HIBERNATE" -eq "0" ]; then - psql -U $PGUSER -h $PGHOST -d $PGDATABASE -f $PENTAHO_SERVER/data/postgresql/create_repository_postgresql.sql - fi - if [ "$CHK_QUARTZ" -eq "0" ]; then - psql -U $PGUSER -h $PGHOST -d $PGDATABASE -f $PENTAHO_SERVER/data/postgresql/create_quartz_postgresql.sql + nc -zv $PGHOST $PGPORT - # Insert dummy table to fix "RUNSCRIPT" issue. - # http://forums.pentaho.com/showthread.php?153231-Pentaho-ce-5-Initialization-Exception - psql -U $PGUSER -h $PGHOST -d quartz -c 'CREATE TABLE "QRTZ" ( NAME VARCHAR(200) NOT NULL, PRIMARY KEY (NAME) );' - fi + if [ "$?" -ne "0" ]; then + echo "PostgreSQL connection failed." + exit 0 + fi - # Use postgresql for hibernate - if grep -q postgresql $PENTAHO_SERVER/pentaho-solutions/system/hibernate/hibernate-settings.xml; then - sed -i s/hsql/postgresql/g $PENTAHO_SERVER/pentaho-solutions/system/hibernate/hibernate-settings.xml - - sed -i s/localhost:5432/$PGHOST:$PGPORT/g $PENTAHO_SERVER/pentaho-solutions/system/hibernate/postgresql.hibernate.cfg.xml - - cp $PENTAHO_HOME/config/jdbc.properties $PENTAHO_SERVER/pentaho-solutions/system/simple-jndi/jdbc.properties - sed -i "s|postgresql://localhost:5432|postgresql://$PGHOST:$PGPORT|g" $PENTAHO_SERVER/pentaho-solutions/system/simple-jndi/jdbc.properties - fi + CHK_QUARTZ=$(echo "$(psql -U $PGUSER -h $PGHOST -d $PGDATABASE -l | grep quartz | wc -l)") + CHK_HIBERNATE=$(echo "$(psql -U $PGUSER -h $PGHOST -d $PGDATABASE -l | grep hibernate | wc -l)") + CHK_JCR=$(echo "$(psql -U $PGUSER -h $PGHOST -d $PGDATABASE -l | grep jackrabbit | wc -l)") - # Use postgreql for jackrabbit - #if grep -q postgresql://localhost:5432 $PENTAHO_SERVER/pentaho-solutions/system/jackrabbit/repository.xml; then - # cp $PENTAHO_HOME/config/repository.xml $PENTAHO_SERVER/pentaho-solutions/system/jackrabbit/repository.xml - # sed -i "s|postgresql://localhost:5432|postgresql://$PGHOST:$PGPORT|g" $PENTAHO_SERVER/pentaho-solutions/system/jackrabbit/repository.xml - #fi - - # Use postgresql for tomcat (quartz / hibernate) - if grep -q hsqldb $PENTAHO_SERVER/tomcat/webapps/pentaho/META-INF/context.xml; then - cp $PENTAHO_HOME/config/context.xml $PENTAHO_SERVER/tomcat/webapps/pentaho/META-INF/context.xml - sed -i "s|jdbc:postgresql://localhost:5432/|jdbc:postgresql://$PGHOST:$PGPORT/|g" $PENTAHO_SERVER/tomcat/webapps/pentaho/META-INF/context.xml - fi + echo "quartz: $CHK_QUARTZ" + echo "hibernate: $CHK_HIBERNATE" + echo "jcr: $CHK_JCR" + + if [ "$CHK_JCR" -eq "0" ]; then + psql -U $PGUSER -h $PGHOST -d $PGDATABASE -f $PENTAHO_SERVER/data/postgresql/create_jcr_postgresql.sql + fi + if [ "$CHK_HIBERNATE" -eq "0" ]; then + psql -U $PGUSER -h $PGHOST -d $PGDATABASE -f $PENTAHO_SERVER/data/postgresql/create_repository_postgresql.sql + fi + if [ "$CHK_QUARTZ" -eq "0" ]; then + psql -U $PGUSER -h $PGHOST -d $PGDATABASE -f $PENTAHO_SERVER/data/postgresql/create_quartz_postgresql.sql + + # Insert dummy table to fix "RUNSCRIPT" issue. + # http://forums.pentaho.com/showthread.php?153231-Pentaho-ce-5-Initialization-Exception + psql -U $PGUSER -h $PGHOST -d quartz -c 'CREATE TABLE "QRTZ" ( NAME VARCHAR(200) NOT NULL, PRIMARY KEY (NAME) );' + fi + + # Use postgresql for hibernate + if grep -q postgresql $PENTAHO_SERVER/pentaho-solutions/system/hibernate/hibernate-settings.xml; then + sed -i s/hsql/postgresql/g $PENTAHO_SERVER/pentaho-solutions/system/hibernate/hibernate-settings.xml + + sed -i s/localhost:5432/$PGHOST:$PGPORT/g $PENTAHO_SERVER/pentaho-solutions/system/hibernate/postgresql.hibernate.cfg.xml + + cp $PENTAHO_HOME/config/jdbc.properties $PENTAHO_SERVER/pentaho-solutions/system/simple-jndi/jdbc.properties + sed -i "s|postgresql://localhost:5432|postgresql://$PGHOST:$PGPORT|g" $PENTAHO_SERVER/pentaho-solutions/system/simple-jndi/jdbc.properties + fi + + # Use postgreql for jackrabbit + if grep -q postgresql://localhost:5432 $PENTAHO_SERVER/pentaho-solutions/system/jackrabbit/repository.xml; then + cp $PENTAHO_HOME/config/repository.xml $PENTAHO_SERVER/pentaho-solutions/system/jackrabbit/repository.xml + sed -i "s|postgresql://localhost:5432|postgresql://$PGHOST:$PGPORT|g" $PENTAHO_SERVER/pentaho-solutions/system/jackrabbit/repository.xml + fi + + # Use postgresql for tomcat (quartz / hibernate) + if grep -q hsqldb $PENTAHO_SERVER/tomcat/webapps/pentaho/META-INF/context.xml; then + cp $PENTAHO_HOME/config/context.xml $PENTAHO_SERVER/tomcat/webapps/pentaho/META-INF/context.xml + sed -i "s|jdbc:postgresql://localhost:5432/|jdbc:postgresql://$PGHOST:$PGPORT/|g" $PENTAHO_SERVER/tomcat/webapps/pentaho/META-INF/context.xml + fi fi From c9e982732d9ec02408281746e0f7241df74056b2 Mon Sep 17 00:00:00 2001 From: Adan Rehtla Date: Tue, 7 Apr 2020 10:44:45 +1000 Subject: [PATCH 2/4] Dockerfile cleanup --- Dockerfile | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/Dockerfile b/Dockerfile index d601f50..e8840ea 100644 --- a/Dockerfile +++ b/Dockerfile @@ -14,7 +14,10 @@ ENV CATALINA_OPTS="-Djava.awt.headless=true -Xms4096m -Xmx6144m -XX:MaxPermSize= RUN apk add --update wget unzip bash postgresql-client ttf-dejavu # Setup pentaho user -RUN mkdir -p ${PENTAHO_HOME}/server; mkdir ${PENTAHO_HOME}/.pentaho; adduser -D -s /bin/sh -h ${PENTAHO_HOME} pentaho; chown -R pentaho:pentaho ${PENTAHO_HOME} +RUN mkdir -p ${PENTAHO_HOME}/server && \ + mkdir ${PENTAHO_HOME}/.pentaho && \ + adduser -D -s /bin/sh -h ${PENTAHO_HOME} pentaho && \ + chown -R pentaho:pentaho ${PENTAHO_HOME} USER pentaho WORKDIR ${PENTAHO_HOME}/server @@ -47,16 +50,16 @@ RUN sed -i "s/connect quartz pentaho_user/connect quartz/g" ${PENTAHO_SERVER}/da USER root COPY scripts ${PENTAHO_HOME}/scripts COPY config ${PENTAHO_HOME}/config -RUN chown -R pentaho:pentaho ${PENTAHO_HOME}/scripts \ - && chmod -R +x ${PENTAHO_HOME}/scripts -RUN chown -R pentaho:pentaho ${PENTAHO_HOME}/config \ - && chmod -R +x ${PENTAHO_HOME}/config -RUN mkdir -p ${PENTAHO_SERVER}data/hsqldb \ - && chmod 775 -R ${PENTAHO_SERVER}/data/hsqldb \ - && chown pentaho:pentaho -R ${PENTAHO_SERVER}/data/hsqldb -RUN mkdir -p ${PENTAHO_SERVER}/pentaho-solutions/system/jackrabbit/repository \ - && chmod 775 -R ${PENTAHO_SERVER}/pentaho-solutions/system/jackrabbit/repository \ - && chown pentaho:pentaho -R ${PENTAHO_SERVER}/pentaho-solutions/system/jackrabbit/repository +RUN chown -R pentaho:pentaho ${PENTAHO_HOME}/scripts && \ + chmod -R +x ${PENTAHO_HOME}/scripts && \ + chown -R pentaho:pentaho ${PENTAHO_HOME}/config && \ + chmod -R +x ${PENTAHO_HOME}/config && \ + mkdir -p ${PENTAHO_SERVER}data/hsqldb && \ + chmod 775 -R ${PENTAHO_SERVER}/data/hsqldb && \ + chown pentaho:pentaho -R ${PENTAHO_SERVER}/data/hsqldb && \ + mkdir -p ${PENTAHO_SERVER}/pentaho-solutions/system/jackrabbit/repository && \ + chmod 775 -R ${PENTAHO_SERVER}/pentaho-solutions/system/jackrabbit/repository && \ + chown pentaho:pentaho -R ${PENTAHO_SERVER}/pentaho-solutions/system/jackrabbit/repository USER pentaho # Volumes: From 4ea9049f0497918443987f57a896d5bda4ff0e35 Mon Sep 17 00:00:00 2001 From: Adan Rehtla Date: Tue, 7 Apr 2020 10:48:06 +1000 Subject: [PATCH 3/4] Final tidy --- Dockerfile | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/Dockerfile b/Dockerfile index e8840ea..b4a0455 100644 --- a/Dockerfile +++ b/Dockerfile @@ -53,13 +53,12 @@ COPY config ${PENTAHO_HOME}/config RUN chown -R pentaho:pentaho ${PENTAHO_HOME}/scripts && \ chmod -R +x ${PENTAHO_HOME}/scripts && \ chown -R pentaho:pentaho ${PENTAHO_HOME}/config && \ - chmod -R +x ${PENTAHO_HOME}/config && \ mkdir -p ${PENTAHO_SERVER}data/hsqldb && \ - chmod 775 -R ${PENTAHO_SERVER}/data/hsqldb && \ - chown pentaho:pentaho -R ${PENTAHO_SERVER}/data/hsqldb && \ + chmod -R 775 ${PENTAHO_SERVER}/data/hsqldb && \ + chown -R pentaho:pentaho ${PENTAHO_SERVER}/data/hsqldb && \ mkdir -p ${PENTAHO_SERVER}/pentaho-solutions/system/jackrabbit/repository && \ - chmod 775 -R ${PENTAHO_SERVER}/pentaho-solutions/system/jackrabbit/repository && \ - chown pentaho:pentaho -R ${PENTAHO_SERVER}/pentaho-solutions/system/jackrabbit/repository + chmod -R 775 ${PENTAHO_SERVER}/pentaho-solutions/system/jackrabbit/repository && \ + chown -R pentaho:pentaho ${PENTAHO_SERVER}/pentaho-solutions/system/jackrabbit/repository USER pentaho # Volumes: From 07952d274cf6b96e4207475171d0e31ae8828b23 Mon Sep 17 00:00:00 2001 From: Adan Rehtla Date: Tue, 7 Apr 2020 12:12:01 +1000 Subject: [PATCH 4/4] Use https --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index b4a0455..c9173f5 100644 --- a/Dockerfile +++ b/Dockerfile @@ -22,7 +22,7 @@ USER pentaho WORKDIR ${PENTAHO_HOME}/server # Get Pentaho Server -RUN echo http://downloads.sourceforge.net/project/pentaho/Business%20Intelligence%20Server/${MAJOR_VERSION}/pentaho-server-ce-${MINOR_VERSION}.zip | xargs wget -qO- -O tmp.zip && \ +RUN echo https://downloads.sourceforge.net/project/pentaho/Business%20Intelligence%20Server/${MAJOR_VERSION}/pentaho-server-ce-${MINOR_VERSION}.zip | xargs wget -qO- -O tmp.zip && \ unzip -q tmp.zip -d ${PENTAHO_HOME}/server && \ rm -f tmp.zip