From 635ccea020a527c625e1deabd423334856651419 Mon Sep 17 00:00:00 2001 From: ivan Date: Thu, 26 Apr 2018 20:01:12 -0300 Subject: [PATCH] Use mysql port from env variable --- .../app/install/install-step-3-database.js | 2 +- server/Dockerfile | 4 ++ server/Makefile | 4 +- server/config.php | 22 +++++++--- server/index.php | 1 - tests/Gemfile.lock | 42 ------------------- tests/Makefile | 8 +++- tests/clean_db.sh | 4 +- tests/libs.rb | 5 ++- 9 files changed, 36 insertions(+), 56 deletions(-) delete mode 100644 tests/Gemfile.lock diff --git a/client/src/app/install/install-step-3-database.js b/client/src/app/install/install-step-3-database.js index 85240d3a..27b13c80 100644 --- a/client/src/app/install/install-step-3-database.js +++ b/client/src/app/install/install-step-3-database.js @@ -27,7 +27,7 @@ class InstallStep3Database extends React.Component { {this.renderMessage()}
- + diff --git a/server/Dockerfile b/server/Dockerfile index 90b5580b..1c385f5a 100644 --- a/server/Dockerfile +++ b/server/Dockerfile @@ -10,3 +10,7 @@ RUN apt-get update && \ RUN echo 'LISTEN 8080' >> /etc/apache2/apache2.conf RUN sed -i "1s/.*//" /etc/apache2/sites-enabled/000-default.conf RUN sed -i "5s/.*/Listen 8080/" /etc/apache2/ports.conf + +# ENVIRONMENT VARIABLES +ENV MYSQL_HOST 127.0.0.1 +ENV MYSQL_PORT 4040 diff --git a/server/Makefile b/server/Makefile index 6feeba34..214dc9ea 100644 --- a/server/Makefile +++ b/server/Makefile @@ -3,7 +3,7 @@ yellow=`tput setaf 3` reset=`tput sgr0` build: - @docker pull mysql + @docker pull mysql:5.6 @docker pull phpmyadmin/phpmyadmin @docker pull munkyboy/fakesmtp @docker build -t opensupports-srv . || echo "A${red}An error occurred${reset}" @@ -13,7 +13,7 @@ install: @docker exec -it opensupports-db bash -c "mysql -u root -e \"CREATE DATABASE IF NOT EXISTS development;\" " || echo "${red}Please execute 'make run' first${reset}" run: - @docker run -d --name opensupports-db -p 4040:3306 -e MYSQL_ALLOW_EMPTY_PASSWORD=yes -v $(PWD)/.dbdata/:/var/lib/mysql mysql + @docker run -d --name opensupports-db -p 4040:3306 -e MYSQL_ALLOW_EMPTY_PASSWORD=yes -v $(PWD)/.dbdata/:/var/lib/mysql mysql:5.6 @docker run -d --name opensupports-myadmin --link opensupports-db:db -p 6060:80 phpmyadmin/phpmyadmin @docker run -d --name opensupports-fakesmtp -p 7070:25 -v ${PWD}/.fakemail/:/var/mail munkyboy/fakesmtp @docker run -d --name opensupports-srv --net=host --rm -e LOG_STDOUT=true -e LOG_STDERR=true -e LOG_LEVEL=debug -v ${PWD}:/var/www/html opensupports-srv diff --git a/server/config.php b/server/config.php index a599d939..6a9016db 100644 --- a/server/config.php +++ b/server/config.php @@ -1,6 +1,18 @@ = 0.0.5, < 1.0.0) - http-cookie (1.0.3) - domain_name (~> 0.5) - mechanize (2.7.5) - domain_name (~> 0.5, >= 0.5.1) - http-cookie (~> 1.0) - mime-types (>= 1.17.2) - net-http-digest_auth (~> 1.1, >= 1.1.1) - net-http-persistent (~> 2.5, >= 2.5.2) - nokogiri (~> 1.6) - ntlm-http (~> 0.1, >= 0.1.1) - webrobots (>= 0.0.9, < 0.2) - mime-types (3.1) - mime-types-data (~> 3.2015) - mime-types-data (3.2016.0521) - mini_portile2 (2.1.0) - mysql (2.9.1) - net-http-digest_auth (1.4.1) - net-http-persistent (2.9.4) - nokogiri (1.6.8.1) - mini_portile2 (~> 2.1.0) - ntlm-http (0.1.1) - unf (0.1.4) - unf_ext - unf_ext (0.0.7.5) - webrobots (0.1.2) - -PLATFORMS - ruby - -DEPENDENCIES - bacon - mechanize - mysql - -BUNDLED WITH - 1.16.1 diff --git a/tests/Makefile b/tests/Makefile index 0bee6e8c..b30f4e1c 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -6,9 +6,15 @@ install: @gem install bundler @bundle install +run: export MYSQL_HOST=127.0.0.1 +run: export MYSQL_PORT=4040 run: ./run-tests.sh +clear: export MYSQL_HOST=127.0.0.1 +clear: export MYSQL_PORT=4040 clear: - ./clean_db.sh + ./clean_db.sh && \ + ./clean_db.sh && \ + ./clean_db.sh diff --git a/tests/clean_db.sh b/tests/clean_db.sh index 0738c4dd..33053f01 100755 --- a/tests/clean_db.sh +++ b/tests/clean_db.sh @@ -1,8 +1,8 @@ #!/bin/bash # DELETE ALL TABLES -TABLES=$(mysql --host 127.0.0.1 --port 4040 -u root development -e "SHOW TABLES IN development;" | awk '{ print $1}' | grep -v '^Tables') +TABLES=$(mysql --host ${MYSQL_HOST} --port ${MYSQL_PORT} -u root development -e "SHOW TABLES IN development;" | awk '{ print $1}' | grep -v '^Tables') for t in $TABLES do - mysql --host 127.0.0.1 --port 4040 -u root development -e "DROP TABLE $t" + mysql --host ${MYSQL_HOST} --port ${MYSQL_PORT} -u root development -e "DROP TABLE $t" done diff --git a/tests/libs.rb b/tests/libs.rb index b57df0fb..325438dc 100644 --- a/tests/libs.rb +++ b/tests/libs.rb @@ -21,10 +21,11 @@ end class Database def initialize() - mysqlHost = ENV['MYSQL_HOST'] || '127.0.0.1' + mysqlHost = ENV['MYSQL_HOST'] || 'localhost' + mysqlPort = ENV['MYSQL_PORT'] || '3306' mysqlUser = ENV['MYSQL_USER'] || 'root' mysqlPass = ENV['MYSQL_PASSWORD'] || '' - @connection = Mysql.new(mysqlHost, mysqlUser, mysqlPass, 'development', 4040) + @connection = Mysql.new(mysqlHost, mysqlUser, mysqlPass, 'development', mysqlPort.to_i) end def close()