Commit d82ec101 authored by Daniel Seybold's avatar Daniel Seybold

fixed docker container and entrypoint to wait for mariadb

parent 52aee34f
Pipeline #9909 passed with stage
in 6 minutes and 57 seconds
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
FROM ubuntu:16.04 FROM ubuntu:16.04
# install operating system packages # install operating system packages
RUN apt-get update -y && apt-get install git curl gettext unzip wget software-properties-common python-software-properties dnsutils make -y && \ RUN apt-get update -y && apt-get install git curl gettext unzip wget software-properties-common python-software-properties dnsutils make mysql-client -y && \
apt-get upgrade -y apt-get upgrade -y
## add more packages, if necessary ## add more packages, if necessary
# install Java8 # install Java8
...@@ -25,7 +25,6 @@ RUN bpkg install cha87de/bashutil -g ...@@ -25,7 +25,6 @@ RUN bpkg install cha87de/bashutil -g
ADD config /etc/docker-config ADD config /etc/docker-config
ADD init /opt/docker-init ADD init /opt/docker-init
# install colosseum # install colosseum
RUN mkdir -p /opt/cloudiator && cp /opt/docker-init/colosseum-0.2.0-SNAPSHOT.zip /opt/cloudiator/colosseum-0.2.0-SNAPSHOT.zip RUN mkdir -p /opt/cloudiator && cp /opt/docker-init/colosseum-0.2.0-SNAPSHOT.zip /opt/cloudiator/colosseum-0.2.0-SNAPSHOT.zip
WORKDIR /opt/cloudiator WORKDIR /opt/cloudiator
...@@ -33,6 +32,9 @@ RUN unzip colosseum-0.2.0-SNAPSHOT.zip ...@@ -33,6 +32,9 @@ RUN unzip colosseum-0.2.0-SNAPSHOT.zip
RUN mkdir /opt/cloudiator/colosseum-0.2.0-SNAPSHOT/conf RUN mkdir /opt/cloudiator/colosseum-0.2.0-SNAPSHOT/conf
# expose ports
EXPOSE 9000
# start from init folder # start from init folder
WORKDIR /opt/docker-init WORKDIR /opt/docker-init
ENTRYPOINT ["./entrypoint"] ENTRYPOINT ["./entrypoint"]
\ No newline at end of file
...@@ -21,6 +21,14 @@ application.langs = "en" ...@@ -21,6 +21,14 @@ application.langs = "en"
# Default to Routes in the root package (and `conf/routes`) # Default to Routes in the root package (and `conf/routes`)
# application.router=my.application.Routes # application.router=my.application.Routes
# MariaDB configuration
# ~~~~
play.crypto.secret="fQpv4t89xfsMASn1QHXOv66FSqTH9R"
db.default.driver=org.mariadb.jdbc.Driver
db.default.url="mysql://$MYSQL_USER:$MYSQL_PW@$MYSQL_HOST/$MYSQL_DB"
colosseum.nodegroup="db-evaluator"
# Hibernate configuration # Hibernate configuration
# ~~~~ # ~~~~
jpa.default = defaultPersistenceUnit jpa.default = defaultPersistenceUnit
......
include application.conf
play.crypto.secret="fQpv4t89xfsMASn1QHXOv66FSqTH9R"
db.default.driver=org.mariadb.jdbc.Driver
db.default.url="mysql://$MYSQLUSER:$MYSQLPW@localhost/$MYSQLSB"
colosseum.nodegroup="db-evaluator"
\ No newline at end of file
...@@ -13,7 +13,7 @@ GLOBAL_VAR="xyz" ...@@ -13,7 +13,7 @@ GLOBAL_VAR="xyz"
# validate if all container variables are set # validate if all container variables are set
############################################################################## ##############################################################################
function validate(){ function validate(){
vars="MYSQLPW MYSQLUSER MYSQLDB" vars="MYSQL_PW MYSQL_USER MYSQL_DB MYSQL_HOST"
for var in $vars; do for var in $vars; do
if [[ $(env | awk -F "=" '{print $1}' | grep "^$var$") != "$var" ]]; then if [[ $(env | awk -F "=" '{print $1}' | grep "^$var$") != "$var" ]]; then
echo "$var not set but required." echo "$var not set but required."
...@@ -31,12 +31,12 @@ function validate(){ ...@@ -31,12 +31,12 @@ function validate(){
############################################################################## ##############################################################################
function writeConfigOptions(){ function writeConfigOptions(){
echo "write config options" echo "write config options"
export MYSQLPW=$MYSQLPW export MYSQL_PW=$MYSQL_PW
export MYSQLUSER=$MYSQLUSER export MYSQL_USER=$MYSQL_USER
export MYSQLDB=$MYSQLDB export MYSQL_DB=$MYSQL_DB
export MYSQL_HOST=$MYSQL_HOST
#cat /etc/docker-conf/configfile.conf.tmpl | envsubst > /etc/docker-conf/configfile.conf #cat /etc/docker-conf/configfile.conf.tmpl | envsubst > /etc/docker-conf/configfile.conf
cat /etc/docker-config/colosseum.conf | envsubst > /opt/cloudiator/colosseum-0.2.0-SNAPSHOT/conf/conf.conf cat /etc/docker-config/application.conf | envsubst > /opt/cloudiator/colosseum-0.2.0-SNAPSHOT/conf/application.conf
cp /etc/docker-config/application.conf /opt/cloudiator/colosseum-0.2.0-SNAPSHOT/conf/
cp /etc/docker-config/logback.xml /opt/cloudiator/colosseum-0.2.0-SNAPSHOT/conf/ cp /etc/docker-config/logback.xml /opt/cloudiator/colosseum-0.2.0-SNAPSHOT/conf/
} }
function init(){ function init(){
...@@ -47,6 +47,13 @@ function init(){ ...@@ -47,6 +47,13 @@ function init(){
writeConfigOptions writeConfigOptions
## post-config initialization ## post-config initialization
# check for MariaDB
retry 15 5 "cannot connect to database." checkDatabase
if [[ $? != 0 ]]; then
echo "cannot initialize db: waitForDatabase" >&2
return 1
fi
} }
############################################################################## ##############################################################################
...@@ -58,13 +65,18 @@ function start_ui(){ ...@@ -58,13 +65,18 @@ function start_ui(){
} }
function checkDatabase(){
echo "Checking MariaDB databases:"
mysql -u $MYSQL_USER --password=$MYSQL_PW -h $MYSQL_HOST -e "show databases"
}
function start_colosseum(){ function start_colosseum(){
# resolve public IP # resolve public IP
PUBLIC_IP=$(dig +short myip.opendns.com @resolver1.opendns.com) PUBLIC_IP=$(dig +short myip.opendns.com @resolver1.opendns.com)
echo "starting colosseum..." echo "starting colosseum..."
/opt/cloudiator/colosseum-0.2.0-SNAPSHOT/bin/colosseum -Dconfig.file=/opt/cloudiator/colosseum-0.2.0-SNAPSHOT/conf/config.conf -Dlca.client.config.registry=etcdregistry -Dlca.client.config.registry.etcd.hosts=${PUBLIC_IP} 2>&1 >> /var/log/colosseum.log /opt/cloudiator/colosseum-0.2.0-SNAPSHOT/bin/colosseum -Dconfig.file=/opt/cloudiator/colosseum-0.2.0-SNAPSHOT/conf/application.conf -Dlca.client.config.registry=etcdregistry -Dlca.client.config.registry.etcd.hosts=${PUBLIC_IP} 2>&1 >> /var/log/colosseum.log
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment