Skip to content

Grouper fix #2

Merged
8 commits merged into from
Sep 8, 2016
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ LABEL ImageOS=centos7
LABEL Version=$version
ENV VERSION=$version
ENV TOMCAT_VERSION="6.0.35"

ENV WAIT_TIME=60

LABEL Build docker build --rm --tag $maintainer/$imagename .
Expand All @@ -30,15 +29,20 @@ RUN mkdir -p /opt/grouper/$VERSION \
java-1.8.0-openjdk \
java-1.8.0-openjdk-devel \
MariaDB-client \
supervisor \
mlocate \
&& yum clean all

# The installer creates a HSQL DB which we ignore later

RUN mkdir -p /var/log/supervisor
RUN mv /etc/supervisord.conf /etc/supervisord.conf.old
COPY container_files/conf/supervisord.conf /etc
WORKDIR /opt/grouper/$version
RUN java -cp :grouperInstaller.jar edu.internet2.middleware.grouperInstaller.GrouperInstaller

VOLUME /opt/grouper/2.3.0/apache-tomcat-$TOMCAT_VERSION/logs

EXPOSE 8080 8009 8005

CMD ["/opt/bin/start.sh"]
CMD ["/usr/bin/supervisord"]
#CMD ["/opt/bin/start.sh"]
12 changes: 6 additions & 6 deletions container_files/bin/check.sh
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
#!/bin/bash

log="/tmp/grouper.log"

log="/tmp/grouper-check.log"
date >> $log
echo "Installing schema" >> $log
cd /opt/grouper/2.3.0/grouper.apiBinary-2.3.0 && GROUPER_HOME=/opt/grouper/2.3.0/grouper.apiBinary-2.3.0 bin/gsh.sh -registry -drop -runscript -noprompt
cd /opt/grouper/2.3.0/grouper.apiBinary-2.3.0 && GROUPER_HOME=/opt/grouper/2.3.0/grouper.apiBinary-2.3.0 bin/gsh.sh -registry -drop -runscript -noprompt >> $log

echo "Preparing subjects" >> $log
cd /opt/grouper/2.3.0/grouper.apiBinary-2.3.0 && GROUPER_HOME=/opt/grouper/2.3.0/grouper.apiBinary-2.3.0 bin/gsh.sh -registry -runsqlfile /opt/grouper/2.3.0/subjects.sql -noprompt
cd /opt/grouper/2.3.0/grouper.apiBinary-2.3.0 && GROUPER_HOME=/opt/grouper/2.3.0/grouper.apiBinary-2.3.0 bin/gsh.sh -registry -runsqlfile /opt/grouper/2.3.0/subjects.sql -noprompt >> $log

echo "Adding Quickstart data" >> $log
cd /opt/grouper/2.3.0/grouper.apiBinary-2.3.0 && GROUPER_HOME=/opt/grouper/2.3.0/grouper.apiBinary-2.3.0 bin/gsh.sh -xmlimportold GrouperSystem /opt/grouper/2.3.0/quickstart.xml -noprompt
cd /opt/grouper/2.3.0/grouper.apiBinary-2.3.0 && GROUPER_HOME=/opt/grouper/2.3.0/grouper.apiBinary-2.3.0 bin/gsh.sh -xmlimportold GrouperSystem /opt/grouper/2.3.0/quickstart.xml -noprompt >> $log

echo "Checking" >> $log
cd /opt/grouper/2.3.0/grouper.apiBinary-2.3.0 && GROUPER_HOME=/opt/grouper/2.3.0/grouper.apiBinary-2.3.0 bin/gsh.sh -registry -check >> $log
cd /opt/grouper/2.3.0/grouper.apiBinary-2.3.0 && GROUPER_HOME=/opt/grouper/2.3.0/grouper.apiBinary-2.3.0 bin/gsh.sh -registry -check >> $log
12 changes: 9 additions & 3 deletions container_files/bin/cleanup.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
#!/bin/bash

log="/tmp/grouper.log"

rm -f /tmp/firsttimerunning >> $log
log="/tmp/grouper-cleanup.log"
date >> $log
if [ -z ${COMPOSE+x} ];then
echo "Not composed so not waiting for MariaDB and first time running was ok: " >> $log
rm -f /tmp/firsttimerunning >> $log
else
echo "Composed with MariaDB, running completed" >> $log
rm -f /tmp/firsttimerunning >> $log
fi
6 changes: 3 additions & 3 deletions container_files/bin/configure.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/bash

log="/tmp/grouper.log"

log="/tmp/grouper-configure.log"
date >> $log
#sed -i "s|#GROUPER_SYSTEM_PASSWORD#|$GROUPER_SYSTEM_PASSWORD|g" /opt/etc/grouper.installer.properties >> $log

# Long-lived configuration values, these are symlinked into place
Expand All @@ -24,4 +24,4 @@ sed -i "s|#MYSQL_DATABASE#|$MYSQL_DATABASE|g" /opt/etc/grouper.properties >> $lo

cat /opt/etc/grouper.hibernate.properties >> $log

cat /opt/etc/grouper.properties >> $log
cat /opt/etc/grouper.properties >> $log
3 changes: 1 addition & 2 deletions container_files/bin/main.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash -x

log="/tmp/start.log"
log="/tmp/start-main.log"

echo "Starting Container: " > $log
date >> $log
Expand All @@ -20,5 +20,4 @@ else
echo "Grouper container has run." >> $log
echo "If there are problems, docker rm this container and try again." >> $log
fi

exit 0
21 changes: 18 additions & 3 deletions container_files/bin/start.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/bash

log="/tmp/start.log"

log="/tmp/start-starting.log"
date >> $log
if [ -z ${COMPOSE+x} ]
then
echo "Not composed so not waiting for MariaDB: " > $log
Expand All @@ -13,18 +13,33 @@ then
echo "Not composed non-zero exit status: $laststatus"
exit 1
else
echo "Grouper was configured"
echo "Starting apache"
exit 0
#/usr/local/bin/httpd-shib-foreground
fi
else
echo "Composed so waiting for MariaDB: " > $log
/opt/wait-for-it/wait-for-it.sh $MYSQL_HOST:3306 -t $WAIT_TIME --strict -- /opt/bin/main.sh
echo "Testing connectivy to database before continue with install"
mysql -u $MYSQL_USER -p$MYSQL_PASSWORD -h "$MYSQL_HOST" -e "use grouper; show tables;"
laststatus="$?"
while [ "$laststatus" != "0" ]; do
mysql -u $MYSQL_USER -p$MYSQL_PASSWORD -h "$MYSQL_HOST" -e "use grouper; show tables;"
laststatus="$?"
sleep 5
echo "Trying to connect to mariadb container with $MYSQL_USER to database $MYSQL_DATABASE"
done
/opt/bin/main.sh
laststatus="$?"
echo "Composed status: $laststatus"
if [ "$laststatus" != "0" ]; then
echo "Composed non-zero exit status: $laststatus" >> $log
echo "Composed non-zero exit status: $laststatus"
exit 1
else
echo "Grouper was configured"
echo "Starting apache"
exit 0
#/usr/local/bin/httpd-shib-foreground
fi
fi
41 changes: 41 additions & 0 deletions container_files/conf/supervisord.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
[supervisord]
logfile=/var/log/supervisor/supervisord.log ; (main log file;default $CWD/supervisord.log)
logfile_maxbytes=50MB ; (max main logfile bytes b4 rotation;default 50MB)
logfile_backups=10 ; (num of main logfile rotation backups;default 10)
loglevel=info ; (log level;default info; others: debug,warn,trace)
pidfile=/var/run/supervisord.pid ; (supervisord pidfile;default supervisord.pid)
nodaemon=true ; (start in foreground if true;default false)
minfds=1024 ; (min. avail startup file descriptors;default 1024)
minprocs=200 ; (min. avail process descriptors;default 200)
;umask=022 ; (process file creation umask;default 022)
;user=chrism ; (default is current user, required if root)
;identifier=supervisor ; (supervisord identifier, default is 'supervisor')
;directory=/tmp ; (default is not to cd during start)
;nocleanup=true ; (don't clean up tempfiles at start;default false)
;childlogdir=/tmp ; ('AUTO' child log dir, default $TEMP)
;environment=KEY=value ; (key value pairs to add to environment)
;strip_ansi=false ; (strip ansi escape codes in logs; def. false)

; the below section must remain in the config file for RPC
; (supervisorctl/web interface) to work, additional interfaces may be
; added by defining them in separate rpcinterface: sections
[rpcinterface:supervisor]
supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface

[supervisorctl]
serverurl=unix:///var/run/supervisor/supervisor.sock ; use a unix:// URL for a unix socket
;serverurl=http://127.0.0.1:9001 ; use an http:// url to specify an inet socket
;username=chris ; should be same as http_username if set
;password=123 ; should be same as http_password if set
;prompt=mysupervisor ; cmd line prompt (default "supervisor")
;history_file=~/.sc_history ; use readline history if available


[program:configure]
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this mechanism start all three of these at the same time?

With the existing 'plan', start.sh would need to terminate before starting tomcat. Is there a way we can keep start.sh as the CMD entrypoint in the Dockerfile, remove the configure here, and start supervisord before cleanup in /opt/bin/main.sh?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes!! correct!! I figure out it today :).. but first issue with mariadb , then I will check how set an order :)

command=/bin/bash -c "exec /opt/bin/start.sh"

[program:apache]
command=/bin/bash -c "exec /usr/local/bin/httpd-shib-foreground"

[program:tomcat]
command=/bin/bash -c "exec /opt/grouper/2.3.0/apache-tomcat-6.0.35/bin/catalina.sh run"