diff --git a/Dockerfile b/Dockerfile index 406af43..a905a81 100644 --- a/Dockerfile +++ b/Dockerfile @@ -8,15 +8,9 @@ LABEL Version=$version ENV VERSION=$version ENV TOMCAT_VERSION="6.0.35" -ENV MYSQL_DATABASE=grouper -ENV MYSQL_USER=grouper_user -ENV MYSQL_PASSWORD=3cf0ccc7d6b240390188367933c9cd90 - -ENV GROUPER_SYSTEM_PASSWORD=3cf0ccc7d6b240390188367933c9cd90 -ENV MYSQL_HOST=mariadb - -ADD ./container_files /root +ADD ./container_files /opt/ COPY conf/grouper.hibernate.properties /opt/grouper/$version +COPY conf/grouper.installer.properties /opt/grouper/$version RUN rm /opt/grouper/2.3.0/grouper.apiBinary-2.3.0/conf/grouper.hibernate.properties && \ ln -s /opt/grouper/$version/grouper.hibernate.properties /opt/grouper/2.3.0/grouper.apiBinary-2.3.0/conf/grouper.hibernate.properties && \ @@ -25,4 +19,5 @@ RUN rm /opt/grouper/2.3.0/grouper.apiBinary-2.3.0/conf/grouper.hibernate.propert rm /opt/grouper/2.3.0/grouper.ui-2.3.0/dist/grouper/WEB-INF/classes/grouper.hibernate.properties && \ ln -s /opt/grouper/$version/grouper.hibernate.properties /opt/grouper/2.3.0/grouper.ui-2.3.0/dist/grouper/WEB-INF/classes/grouper.hibernate.properties -VOLUME /opt/grouper/2.3.0/apache-tomcat-$TOMCAT_VERSION/logs \ No newline at end of file +RUN ls /root && ls -l /tmp && cat /opt/grouper/$version/grouper.hibernate.properties && cat /opt/grouper/$version/grouper.installer.properties +VOLUME /opt/grouper/$version/apache-tomcat-$TOMCAT_VERSION/logs diff --git a/conf/common.env b/conf/common.env index 8f03076..19863d2 100644 --- a/conf/common.env +++ b/conf/common.env @@ -1,3 +1,4 @@ MYSQL_DATABASE=grouper MYSQL_USER=grouper_user -MYSQL_PASSWORD=3cf0ccc7d6b240390188367933c9cd90 \ No newline at end of file +MYSQL_PASSWORD=3cf0ccc7d6b240390188367933c9cd90 +COMPOSE=true diff --git a/conf/grouper.env b/conf/grouper.env index ed9bb0c..5f4e2e0 100644 --- a/conf/grouper.env +++ b/conf/grouper.env @@ -1,4 +1,4 @@ VERSION=2.3.0 TOMCAT_VERSION=6.0.35 GROUPER_SYSTEM_PASSWORD=3cf0ccc7d6b240390188367933c9cd90 -MYSQL_HOST=mariadb \ No newline at end of file +MYSQL_HOST=mariadb diff --git a/conf/grouper.hibernate.properties b/conf/grouper.hibernate.properties index 016cb1d..693eb66 100644 --- a/conf/grouper.hibernate.properties +++ b/conf/grouper.hibernate.properties @@ -42,4 +42,4 @@ hibernate.connection.username = #MYSQL_USER# # If you are using an empty password, depending upon your version of # Java and Ant you may need to specify a password of "". # Note: you can keep passwords external and encrypted: https://bugs.internet2.edu/jira/browse/GRP-122 -hibernate.connection.password = #MYSQL_USER# \ No newline at end of file +hibernate.connection.password = #MYSQL_PASSWORD# diff --git a/container_files/bin/configure.sh b/container_files/bin/configure.sh new file mode 100755 index 0000000..4ba2731 --- /dev/null +++ b/container_files/bin/configure.sh @@ -0,0 +1,19 @@ +#!/bin/bash +log="/tmp/grouper-configure.log" +date >> $log +sed -i "s|#GROUPER_SYSTEM_PASSWORD#|$GROUPER_SYSTEM_PASSWORD|g" /opt/grouper/2.3.0/grouper.installer.properties + +sed -i "s|#MYSQL_HOST#|$MYSQL_HOST|g" /opt/grouper/2.3.0/grouper.hibernate.properties +sed -i "s|#MYSQL_HOST#|$MYSQL_HOST|g" /opt/grouper/2.3.0/grouper.installer.properties + +sed -i "s|#MYSQL_USER#|$MYSQL_USER|g" /opt/grouper/2.3.0/grouper.hibernate.properties +sed -i "s|#MYSQL_USER#|$MYSQL_USER|g" /opt/grouper/2.3.0/grouper.installer.properties + +sed -i "s|#MYSQL_PASSWORD#|$MYSQL_PASSWORD|g" /opt/grouper/2.3.0/grouper.hibernate.properties +sed -i "s|#MYSQL_PASSWORD#|$MYSQL_PASSWORD|g" /opt/grouper/2.3.0/grouper.installer.properties + +sed -i "s|#MYSQL_DATABASE#|$MYSQL_DATABASE|g" /opt/grouper/2.3.0/grouper.hibernate.properties +sed -i "s|#MYSQL_DATABASE#|$MYSQL_DATABASE|g" /opt/grouper/2.3.0/grouper.installer.properties + +cat /opt/grouper/2.3.0/grouper.hibernate.properties > $log +cat /opt/grouper/2.3.0/grouper.installer.properties > $log diff --git a/container_files/bin/start.sh b/container_files/bin/start.sh new file mode 100755 index 0000000..5eb9390 --- /dev/null +++ b/container_files/bin/start.sh @@ -0,0 +1,41 @@ +#!/bin/bash + +log="/tmp/start-starting.log" +date >> $log +if [ -z ${COMPOSE+x} ] +then + echo "Not composed so not waiting for MariaDB: " > $log + /opt/bin/main.sh + laststatus="$?" + echo "Not composed status: $laststatus" + if [ "$laststatus" != "0" ]; then + echo "Not composed non-zero exit status: $laststatus" >> $log + echo "Not composed non-zero exit status: $laststatus" + exit 1 + else + echo "Grouper was configured" + sleep 8000 + fi +else + echo "Composed so waiting for MariaDB: " > $log + 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" + sleep 800000 + fi +fi diff --git a/docker-compose.yml b/docker-compose.yml index 44b2ad0..4afe5b5 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -5,26 +5,25 @@ services: image: bigfleet/mariadb container_name: mariadb hostname: mariadb - networks: - - i2network ports: - "3306:3306" cap_add: - ALL - NET_ADMIN - SYS_ADMIN + networks: + - i2network volumes: - - ./mysql:/var/lib/mysqlmounted + - grouper_mysql:/var/lib/mysqlmounted + restart: always env_file: - - conf/common.env - - conf/db.env + - conf/common.env + - conf/db.env grouper: image: my/grouper container_name: grouper hostname: grouper - depends_on: - - db networks: - i2network ports: @@ -35,12 +34,16 @@ services: - NET_ADMIN - SYS_ADMIN volumes: - - logs:/opt/grouper/2.3.0/apache-tomcat-6.0.35/logs + - ./logs:/opt/grouper/2.3.0/apache-tomcat-6.0.35/logs env_file: - - conf/common.env - - conf/grouper.env + - conf/common.env + - conf/grouper.env + restart: always networks: i2network: driver: bridge +volumes: + grouper_mysql: + driver: local