Skip to content

Commit

Permalink
Added some files in order to get app running.
Browse files Browse the repository at this point in the history
The script container_files/bin/start.sh have a sleep 8000 because left configure apache and test it so we need a procees running in order to get container up and avoid restart always.
  • Loading branch information
villadalmine committed Sep 7, 2016
1 parent fe2446e commit e1bffa1
Show file tree
Hide file tree
Showing 7 changed files with 81 additions and 22 deletions.
13 changes: 4 additions & 9 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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 && \
Expand All @@ -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
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
3 changes: 2 additions & 1 deletion conf/common.env
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
MYSQL_DATABASE=grouper
MYSQL_USER=grouper_user
MYSQL_PASSWORD=3cf0ccc7d6b240390188367933c9cd90
MYSQL_PASSWORD=3cf0ccc7d6b240390188367933c9cd90
COMPOSE=true
2 changes: 1 addition & 1 deletion conf/grouper.env
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
VERSION=2.3.0
TOMCAT_VERSION=6.0.35
GROUPER_SYSTEM_PASSWORD=3cf0ccc7d6b240390188367933c9cd90
MYSQL_HOST=mariadb
MYSQL_HOST=mariadb
2 changes: 1 addition & 1 deletion conf/grouper.hibernate.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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#
hibernate.connection.password = #MYSQL_PASSWORD#
19 changes: 19 additions & 0 deletions container_files/bin/configure.sh
Original file line number Diff line number Diff line change
@@ -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
41 changes: 41 additions & 0 deletions container_files/bin/start.sh
Original file line number Diff line number Diff line change
@@ -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
23 changes: 13 additions & 10 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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

0 comments on commit e1bffa1

Please sign in to comment.