Skip to content

Commit

Permalink
added docker for fiware and latest release
Browse files Browse the repository at this point in the history
  • Loading branch information
fabrizyo committed Sep 26, 2015
1 parent 1feb2d9 commit b31e1d9
Show file tree
Hide file tree
Showing 3 changed files with 132 additions and 0 deletions.
51 changes: 51 additions & 0 deletions docker/5.1-fiware-all-in-one/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
FROM java:7

ENV SPAGOBI_VERSION=All-in-One-SpagoBI-5.1-1feb2d97af
ENV SPAGOBI_URL=https://github.com/EngineeringSPA/SpagoBI/releases/download/fiware-v5.1-1feb2d97af/${SPAGOBI_VERSION}.zip
ENV SPAGOBI_SHA=d74dcac7341a488822e85f6dd0a4f6f641ad07c41b1d834d55dc9bcc353c6576
ENV SPAGOBI_MYSQL_SCRIPT_URL=https://github.com/EngineeringSPA/SpagoBI/releases/download/fiware-v5.1-1feb2d97af/MySQL.zip

RUN apt-get update && apt-get install -y wget coreutils unzip mysql-client

#download spagobi all in one and extract it
WORKDIR /home
RUN wget "${SPAGOBI_URL}" -O SpagoBI.zip && \
unzip SpagoBI.zip && \
mv ${SPAGOBI_VERSION} SpagoBI && \
rm SpagoBI.zip

#download mysql scripts
RUN wget "${SPAGOBI_MYSQL_SCRIPT_URL}" -O MySQL.zip && \
unzip MySQL.zip -d MySQL && \
rm MySQL.zip

ENV SPAGOBI_DIRECTORY /home/SpagoBI
ENV MYSQL_SCRIPT_DIRECTORY /home/MySQL
WORKDIR ${SPAGOBI_DIRECTORY}/bin

#make the script executable by bash (not only sh) and
#make spagobi running forever without exiting
RUN sed -i "s/bin\/sh/bin\/bash/" startup.sh && \
sed -i "s/EXECUTABLE\" start/EXECUTABLE\" run/" startup.sh

COPY ./entrypoint.sh ./
#make all scripts executable
RUN chmod +x *.sh

#safe copy of original conf files
RUN cp ${SPAGOBI_DIRECTORY}/conf/server.xml ${SPAGOBI_DIRECTORY}/conf/server.xml.bak && \
cp ${SPAGOBI_DIRECTORY}/webapps/SpagoBI/WEB-INF/classes/hibernate.cfg.xml ${SPAGOBI_DIRECTORY}/webapps/SpagoBI/WEB-INF/classes/hibernate.cfg.xml.bak && \
cp ${SPAGOBI_DIRECTORY}/webapps/SpagoBI/WEB-INF/classes/jbpm.hibernate.cfg.xml ${SPAGOBI_DIRECTORY}/webapps/SpagoBI/WEB-INF/classes/jbpm.hibernate.cfg.xml.bak && \
cp ${SPAGOBI_DIRECTORY}/webapps/SpagoBI/WEB-INF/classes/quartz.properties ${SPAGOBI_DIRECTORY}/webapps/SpagoBI/WEB-INF/classes/quartz.properties.bak

#where the data is stored in all in one run
VOLUME ${SPAGOBI_DIRECTORY}/database

EXPOSE 8080
#-d option is passed to run spagobi forever without exiting from container
ENTRYPOINT ["./entrypoint.sh"]
CMD ["./startup.sh"]




15 changes: 15 additions & 0 deletions docker/5.1-fiware-all-in-one/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
spagobi:
image: engineeringspa/spagobi:fiware
links:
- spagobidb:db
environment:
- WAIT_MYSQL=true

spagobidb:
image: mysql:5.5
environment:
- MYSQL_USER=spagobiuser
- MYSQL_PASSWORD=spagobipassword
- MYSQL_DATABASE=spagobidb
- MYSQL_ROOT_PASSWORD=spagobirootpassword

66 changes: 66 additions & 0 deletions docker/5.1-fiware-all-in-one/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
#!/bin/bash
set -e

#get the address of container
#example : default via 172.17.42.1 dev eth0 172.17.0.0/16 dev eth0 proto kernel scope link src 172.17.0.109
PUBLIC_ADDRESS=`ip route | grep src | awk '{print $9}'`

#replace the address of container inside server.xml
sed -i "s/http:\/\/.*:8080/http:\/\/${PUBLIC_ADDRESS}:8080/g" ${SPAGOBI_DIRECTORY}/conf/server.xml

#wait for MySql if it's a compose image
if [ -n "$WAIT_MYSQL" ]; then
while ! curl http://$DB_PORT_3306_TCP_ADDR:$DB_PORT_3306_TCP_PORT/
do
echo "$(date) - still trying to connect to mysql"
sleep 1
done
fi

if [ -n "$DB_ENV_MYSQL_DATABASE" ]; then
#copy the original files
cp ${SPAGOBI_DIRECTORY}/conf/server.xml.bak ${SPAGOBI_DIRECTORY}/conf/server.xml
cp ${SPAGOBI_DIRECTORY}/webapps/SpagoBI/WEB-INF/classes/hibernate.cfg.xml.bak ${SPAGOBI_DIRECTORY}/webapps/SpagoBI/WEB-INF/classes/hibernate.cfg.xml
cp ${SPAGOBI_DIRECTORY}/webapps/SpagoBI/WEB-INF/classes/jbpm.hibernate.cfg.xml.bak ${SPAGOBI_DIRECTORY}/webapps/SpagoBI/WEB-INF/classes/jbpm.hibernate.cfg.xml
cp ${SPAGOBI_DIRECTORY}/webapps/SpagoBI/WEB-INF/classes/quartz.properties.bak ${SPAGOBI_DIRECTORY}/webapps/SpagoBI/WEB-INF/classes/quartz.properties

# Get the database values from the relation.
DB_USER=$DB_ENV_MYSQL_USER
DB_DB=$DB_ENV_MYSQL_DATABASE
DB_PASS=$DB_ENV_MYSQL_PASSWORD
DB_HOST=$DB_PORT_3306_TCP_ADDR
DB_PORT=$DB_PORT_3306_TCP_PORT

#insert spago bi metadata into db if it doesn't exist
Result=`mysql -h${DB_HOST} -P${DB_PORT} -u${DB_USER} -p${DB_PASS} ${DB_DB} -e "SHOW TABLES LIKE '%SBI_%';"`
if [ -z "$Result" ]; then
mysql -h${DB_HOST} -P${DB_PORT} -u${DB_USER} -p${DB_PASS} ${DB_DB} --execute="source $MYSQL_SCRIPT_DIRECTORY/MySQL_create.sql"
mysql -h${DB_HOST} -P${DB_PORT} -u${DB_USER} -p${DB_PASS} ${DB_DB} --execute="source $MYSQL_SCRIPT_DIRECTORY/MySQL_create_quartz_schema.sql"
mysql -h${DB_HOST} -P${DB_PORT} -u${DB_USER} -p${DB_PASS} ${DB_DB} --execute="source $MYSQL_SCRIPT_DIRECTORY/MySQL_create_social.sql"
fi

#replace hsql with mysql
#replace in server.xml
old_driver='org\.hsqldb\.jdbcDriver'
new_driver='com\.mysql\.jdbc\.Driver'
sed -i "s|${old_driver}|${new_driver}|" ${SPAGOBI_DIRECTORY}/conf/server.xml
old_connection='jdbc:hsqldb:file:${catalina.base}/database/spagobi'
mysql_connection='jdbc:mysql://'${DB_HOST}':'${DB_PORT}'/'${DB_DB}
sed -i "s|${old_connection}|${mysql_connection}|" ${SPAGOBI_DIRECTORY}/conf/server.xml
old_username_password='username="sa" password=""'
new_username_password='username="'${DB_USER}'" password="'${DB_PASS}'"'
sed -i "s|${old_username_password}|${new_username_password}|" ${SPAGOBI_DIRECTORY}/conf/server.xml
#replace in properties files dialect
old_dialect='org\.hibernate\.dialect\.HSQLDialect'
new_dialect='org\.hibernate\.dialect\.MySQLDialect'
sed -i "s|${old_dialect}|${new_dialect}|" ${SPAGOBI_DIRECTORY}/webapps/SpagoBI/WEB-INF/classes/hibernate.cfg.xml
sed -i "s|${old_dialect}|${new_dialect}|" ${SPAGOBI_DIRECTORY}/webapps/SpagoBI/WEB-INF/classes/jbpm.hibernate.cfg.xml
#replace in properties files delegate
old_delegate='org\.quartz\.impl\.jdbcjobstore\.HSQLDBDelegate'
new_delegate='org\.quartz\.impl\.jdbcjobstore\.StdJDBCDelegate'
sed -i "s|${old_delegate}|${new_delegate}|" ${SPAGOBI_DIRECTORY}/webapps/SpagoBI/WEB-INF/classes/quartz.properties


fi

exec "$@"

0 comments on commit b31e1d9

Please sign in to comment.