Skip to content

Commit

Permalink
Merge pull request #3 from I-TECH-UW/pmanko-database-config-fix
Browse files Browse the repository at this point in the history
Database config fix
  • Loading branch information
pmanko authored Oct 25, 2022
2 parents 15fa78a + 269f645 commit b5c351e
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 8 deletions.
6 changes: 5 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@

FROM tomcat:8.5-jdk8-adoptopenjdk-hotspot

# Install MySQL client
RUN apt-get update && apt-get install -y git build-essential curl wget mysql-client

# Install dockerize
ENV DOCKERIZE_VERSION v0.2.0
RUN curl -L "https://github.com/jwilder/dockerize/releases/download/${DOCKERIZE_VERSION}/dockerize-linux-amd64-${DOCKERIZE_VERSION}.tar.gz" -o "/tmp/dockerize-linux-amd64-${DOCKERIZE_VERSION}.tar.gz" \
Expand Down Expand Up @@ -52,4 +55,5 @@ ADD openmrs-runtime.properties.tmpl "${CATALINA_HOME}/openmrs-runtime.properties
ADD setenv.sh.tmpl "${CATALINA_HOME}/bin/setenv.sh.tmpl"

# Run openmrs using dockerize
CMD ["dockerize","-template","/usr/local/tomcat/bin/setenv.sh.tmpl:/usr/local/tomcat/bin/setenv.sh","-template","/usr/local/tomcat/openmrs-runtime.properties.tmpl:/usr/local/tomcat/openmrs-runtime.properties","-wait","tcp://openmrs-mysql-db:3306","-timeout","200s","/root/cmd.sh", "run"]
ENTRYPOINT dockerize -template /usr/local/tomcat/bin/setenv.sh.tmpl:/usr/local/tomcat/bin/setenv.sh -template /usr/local/tomcat/openmrs-runtime.properties.tmpl:/usr/local/tomcat/openmrs-runtime.properties -wait tcp://$MYSQL_HOST:$MYSQL_PORT -timeout 200s /root/cmd.sh run

14 changes: 7 additions & 7 deletions cmd.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,29 +29,29 @@ else
cp /root/temp/modules/*.omod $OPENMRS_MODULES
echo "Modules copied."

DB=`mysql -u root -p${MYSQL_ROOT_PASSWORD} --skip-column-names -e "SHOW DATABASES LIKE '${OPENMRS_DATABASE}'"`
DB=`mysql --ssl-mode=DISABLED -u root -p${MYSQL_ROOT_PASSWORD} --skip-column-names -e "SHOW DATABASES LIKE '${OPENMRS_DATABASE}'"`
if [ "$DB" != "${OPENMRS_DATABASE}" ]; then
echo "# Init database for OpenMRS #"

mysql -u root -p${MYSQL_ROOT_PASSWORD} -e "CREATE DATABASE ${OPENMRS_DATABASE};"
mysql --ssl-mode=DISABLED -u root -p${MYSQL_ROOT_PASSWORD} -e "CREATE DATABASE ${OPENMRS_DATABASE};"

mysql -u root -p${MYSQL_ROOT_PASSWORD} -e "GRANT ALL ON openmrs.* to '${MYSQL_USER}'@'%' identified by '${MYSQL_PASSWORD}';"
mysql --ssl-mode=DISABLED -u root -p${MYSQL_ROOT_PASSWORD} -e "GRANT ALL ON openmrs.* to '${MYSQL_USER}'@'%' identified by '${MYSQL_PASSWORD}';"

echo "Create database openmrs from file < openmrs.sql"
mysql -u root -p${MYSQL_ROOT_PASSWORD} openmrs < openmrs.sql
mysql --ssl-mode=DISABLED -u root -p${MYSQL_ROOT_PASSWORD} openmrs < openmrs.sql

echo "Load concepts to openmrs database from file < concepts.sql"
mysql -u root -p${MYSQL_ROOT_PASSWORD} openmrs < concepts.sql
mysql --ssl-mode=DISABLED -u root -p${MYSQL_ROOT_PASSWORD} openmrs < concepts.sql

if [ $data_file -eq 1 ]; then
echo "Load data to openmrs database from file < shrdata.sql"
mysql -u root -p${MYSQL_ROOT_PASSWORD} openmrs < shrdata.sql
mysql --ssl-mode=DISABLED -u root -p${MYSQL_ROOT_PASSWORD} openmrs < shrdata.sql
else
echo "Add shrdata.sql file to this direcatory to load data into SHR database"
fi

echo "Update database openmrs with SHR configuration from file < openshr-configuration.sql"
mysql -u root -p${MYSQL_ROOT_PASSWORD} openmrs < openshr-configuration.sql
mysql --ssl-mode=DISABLED -u root -p${MYSQL_ROOT_PASSWORD} openmrs < openshr-configuration.sql

echo "Finish init database"
rm openmrs.sql
Expand Down
2 changes: 2 additions & 0 deletions setenv.sh.tmpl
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
export JAVA_OPTS="{{ default .Env.JAVA_OPTS "-Dfile.encoding=UTF-8 -server -Xms512m -Xmx1024m -XX:PermSize=512m -XX:MaxPermSize=1024m" }}"
export MYSQL_HOST={{ .Env.MYSQL_HOST }}
export MYSQL_PORT={{ .Env.MYSQL_PORT }}

0 comments on commit b5c351e

Please sign in to comment.