diff --git a/.devilbox/www/config.php b/.devilbox/www/config.php
index 89330365..b2abf283 100644
--- a/.devilbox/www/config.php
+++ b/.devilbox/www/config.php
@@ -10,8 +10,8 @@ error_reporting(-1);
putenv('RES_OPTIONS=retrans:1 retry:1 timeout:1 attempts:1');
-$DEVILBOX_VERSION = 'v0.9';
-$DEVILBOX_DATE = '2017-05-20';
+$DEVILBOX_VERSION = 'v0.10';
+$DEVILBOX_DATE = '2017-05-26';
$DEVILBOX_API_PAGE = 'devilbox-api/status.json';
//
@@ -41,6 +41,7 @@ $MYSQL_HOST_NAME = 'mysql';
$PGSQL_HOST_NAME = 'pgsql';
$REDIS_HOST_NAME = 'redis';
$MEMCD_HOST_NAME = 'memcd';
+$MONGO_HOST_NAME = 'mongo';
//
@@ -132,6 +133,11 @@ function loadClass($class) {
$_LOADED_LIBS[$class] = \devilbox\Memcd::getInstance($GLOBALS['MEMCD_HOST_NAME']);
break;
+ case 'Mongo':
+ loadFile($class, $cnt_dir);
+ $_LOADED_LIBS[$class] = \devilbox\Mongo::getInstance($GLOBALS['MONGO_HOST_NAME']);
+ break;
+
// Get optional docker classes
default:
// Redis
diff --git a/.devilbox/www/htdocs/db_mongo.php b/.devilbox/www/htdocs/db_mongo.php
new file mode 100644
index 00000000..1fa6517b
--- /dev/null
+++ b/.devilbox/www/htdocs/db_mongo.php
@@ -0,0 +1,50 @@
+
+
+
+
+ getHead(); ?>
+
+
+
+ getNavbar(); ?>
+
+
+
+
MongoDB Databases
+
+
+
+
+
+
+ isAvailable()): ?>
+
MongoDB container is not running.
+
+
+
+
+ Name |
+ Size |
+ Empty |
+
+
+
+ getDatabases() as $db): ?>
+
+ |
+ MB |
+ |
+
+
+
+
+
+
+
+
+
+
+
+ getFooter(); ?>
+
+
diff --git a/.devilbox/www/htdocs/index.php b/.devilbox/www/htdocs/index.php
index 90fef793..ffb1616a 100644
--- a/.devilbox/www/htdocs/index.php
+++ b/.devilbox/www/htdocs/index.php
@@ -18,6 +18,7 @@ $avail_mysql = loadClass('Mysql')->isAvailable();
$avail_pgsql = loadClass('Pgsql')->isAvailable();
$avail_redis = loadClass('Redis')->isAvailable();
$avail_memcd = loadClass('Memcd')->isAvailable();
+$avail_mongo = loadClass('Mongo')->isAvailable();
/*************************************************************
@@ -150,6 +151,32 @@ if ($avail_memcd) {
);
}
+// ---- MONGO ----
+if ($avail_mongo) {
+ $host = $GLOBALS['MONGO_HOST_NAME'];
+ $succ = loadClass('Mongo')->canConnect($error, $host);
+ $connection['MongoDB'][$host] = array(
+ 'error' => $error,
+ 'host' => $host,
+ 'succ' => $succ
+ );
+ $host = loadClass('Mongo')->getIpAddress();
+ $succ = loadClass('Mongo')->canConnect($error, $host);
+ $connection['MongoDB'][$host] = array(
+ 'error' => $error,
+ 'host' => $host,
+ 'succ' => $succ
+ );
+ $host = '127.0.0.1';
+ $succ = loadClass('Mongo')->canConnect($error, $host);
+ $connection['MongoDB'][$host] = array(
+ 'error' => $error,
+ 'host' => $host,
+ 'succ' => $succ
+ );
+}
+
+
// ---- BIND (required)----
$host = $GLOBALS['DNS_HOST_NAME'];
$succ = loadClass('Dns')->canConnect($error, $host);
@@ -288,7 +315,7 @@ $HEALTH_PERCENT = 100 - ceil(100 * $HEALTH_FAILS / $HEALTH_TOTAL);
getCirle('memcd'); ?>
- getCirle('mongodb'); ?>
+ getCirle('mongo'); ?>
@@ -516,6 +543,13 @@ $HEALTH_PERCENT = 100 - ceil(100 * $HEALTH_FAILS / $HEALTH_TOTAL);
getIpAddress(); ?> |
+
+
+ mongo |
+ |
+ getIpAddress(); ?> |
+
+
bind |
@@ -585,6 +619,13 @@ $HEALTH_PERCENT = 100 - ceil(100 * $HEALTH_FAILS / $HEALTH_TOTAL);
11211 |
+
+
+ mongo |
+ getEnv('LOCAL_LISTEN_ADDR').loadClass('Helper')->getEnv('HOST_PORT_MONGO');?> |
+ 27017 |
+
+
bind |
@@ -656,6 +697,13 @@ $HEALTH_PERCENT = 100 - ceil(100 * $HEALTH_FAILS / $HEALTH_TOTAL);
- |
+
+
+ mongo |
+ getEnv('HOST_PATH_MONGO_DATADIR'); ?> |
+ /data/db |
+
+
bind |
@@ -724,6 +772,13 @@ $HEALTH_PERCENT = 100 - ceil(100 * $HEALTH_FAILS / $HEALTH_TOTAL);
- |
+
+
+ mongo |
+ - |
+ - |
+
+
bind |
@@ -792,6 +847,13 @@ $HEALTH_PERCENT = 100 - ceil(100 * $HEALTH_FAILS / $HEALTH_TOTAL);
/var/log/memcached |
+
+
+ mongo |
+ - |
+ - |
+
+
bind |
diff --git a/.devilbox/www/htdocs/info_mongo.php b/.devilbox/www/htdocs/info_mongo.php
new file mode 100644
index 00000000..942475f4
--- /dev/null
+++ b/.devilbox/www/htdocs/info_mongo.php
@@ -0,0 +1,48 @@
+
+
+
+
+ getHead(); ?>
+
+
+
+ getNavbar(); ?>
+
+
+
+
MongoDB Info
+
+
+
+
+
+
+ isAvailable()): ?>
+
MongoDB container is not running.
+
+
+
+
+ Variable |
+ Value |
+
+
+
+ getInfo() as $key => $val): ?>
+
+ |
+ |
+
+
+
+
+
+
+
+
+
+
+
+ getFooter(); ?>
+
+
diff --git a/.devilbox/www/include/lib/Html.php b/.devilbox/www/include/lib/Html.php
index 1914933a..ec18ff9d 100644
--- a/.devilbox/www/include/lib/Html.php
+++ b/.devilbox/www/include/lib/Html.php
@@ -34,6 +34,10 @@ class Html
'name' => 'PgSQL DB',
'path' => '/db_pgsql.php'
),
+ array(
+ 'name' => 'MongoDB DB',
+ 'path' => '/db_mongo.php'
+ ),
array(
'name' => 'Redis DB',
'path' => '/db_redis.php'
@@ -63,6 +67,10 @@ class Html
'name' => 'PgSQL Info',
'path' => '/info_pgsql.php'
),
+ array(
+ 'name' => 'MongoDB Info',
+ 'path' => '/info_mongo.php'
+ ),
array(
'name' => 'Redis Info',
'path' => '/info_redis.php'
@@ -271,6 +279,12 @@ HTML;
$available = loadClass('Memcd')->isAvailable();
$name = loadClass('Memcd')->getName();
break;
+ case 'mongo':
+ $class = 'bg-danger';
+ $version = loadClass('Mongo')->getVersion();
+ $available = loadClass('Mongo')->isAvailable();
+ $name = loadClass('Mongo')->getName();
+ break;
default:
$available = false;
$version = '';
diff --git a/.devilbox/www/include/lib/container/Mongo.php b/.devilbox/www/include/lib/container/Mongo.php
new file mode 100644
index 00000000..d7d9ca92
--- /dev/null
+++ b/.devilbox/www/include/lib/container/Mongo.php
@@ -0,0 +1,224 @@
+isAvailable()) {
+ return;
+ }
+
+
+ $mongo = new \MongoDB\Driver\Manager('mongodb://'.$hostname);
+
+ // MongoDB uses lazy loading of server list
+ // so just execute an arbitrary command in order
+ // to make it populate the server list
+ $command = new \MongoDB\Driver\Command(array('ping' => 1));
+
+ try {
+ $mongo->executeCommand('admin', $command);
+ } catch (\MongoDB\Driver\Exception\ConnectionTimeoutException $e) {
+ $this->_connect_error = $e;
+ $this->_connect_errno = 1;
+ return;
+ }
+
+ // retrieve server list
+ $servers = $mongo->getServers();
+
+ if (!isset($servers[0])) {
+ $this->_connect_error = 'Failed to connect to MongoDB host on '.$hostname.' (No host info available)';
+ $this->_connect_errno = 2;
+ return;
+ } else if ($servers[0]->getHost() != $hostname) {
+ $this->_connect_error = 'Failed to connect to MongoDB host on '.$hostname.' (servername does not match: '.$servers[0]->getHost().')';
+ $this->_connect_errno = 3;
+ return;
+ }
+ $this->_mongo = $mongo;
+ }
+
+
+
+
+ /*********************************************************************************
+ *
+ * Select functions
+ *
+ *********************************************************************************/
+
+
+ /**
+ * Execute MongoDB command and return iteratable
+ * @param array $command Command
+ * @return iteratable
+ */
+ private function command($command)
+ {
+ $cmd = new \MongoDB\Driver\Command($command);
+
+ if ($this->_mongo) {
+ try {
+ $cursor = $this->_mongo->executeCommand('admin', $cmd);
+ return $cursor->toArray();
+ } catch(\MongoDB\Driver\Exception $e) {
+ loadClass('Logger')->error($e->getMessage().'. Could not execute MongoDB command: '.print_r($command, true));
+ }
+ }
+
+ return array();
+ }
+
+
+ /**
+ * Get all MongoDB Databases.
+ * @return mixed[] Array of databases
+ */
+ public function getDatabases()
+ {
+ $databases = array();
+ $tmp = $this->command(array('listDatabases' => true));
+ if (isset($tmp[0])) {
+ foreach ($tmp[0]->databases as $db) {
+ $databases[] = array(
+ 'name' => $db->name,
+ 'size' => $db->sizeOnDisk,
+ 'empty' => $db->empty
+ );
+ }
+ }
+
+ return $databases;
+ }
+
+
+
+ public function getInfo()
+ {
+ $info = array();
+ $tmp = $this->command(array('serverStatus' => true));
+
+ if (isset($tmp[0])) {
+ $info = $tmp[0];
+ }
+ return $info;
+ }
+
+
+ /*********************************************************************************
+ *
+ * Interface required functions
+ *
+ *********************************************************************************/
+
+
+ private $_can_connect = array();
+ private $_can_connect_err = array();
+
+ private $_name = null;
+ private $_version = null;
+
+ public function canConnect(&$err, $hostname, $data = array())
+ {
+ $err = false;
+
+ // Return if already cached
+ if (isset($this->_can_connect[$hostname])) {
+ // Assume error for unset error message
+ $err = isset($this->_can_connect_err[$hostname]) ? $this->_can_connect_err[$hostname] : true;
+ return $this->_can_connect[$hostname];
+ }
+
+ $manager = new \MongoDB\Driver\Manager('mongodb://'.$hostname);
+
+ // MongoDB uses lazy loading of server list
+ // so just execute an arbitrary command in order
+ // to make it populate the server list
+ $command = new \MongoDB\Driver\Command(array('ping' => 1));
+ $manager->executeCommand('admin', $command);
+
+ // retrieve server list
+ $servers = $manager->getServers();
+
+ if (!isset($servers[0])) {
+ $err = 'Failed to connect to MongoDB host on '.$hostname.' (No host info available)';
+ $this->_can_connect[$hostname] = false;
+ } else if ($servers[0]->getHost() != $hostname) {
+ $err = 'Failed to connect to MongoDB host on '.$hostname.' (servername does not match: '.$servers[0]->getHost().')';
+ $this->_can_connect[$hostname] = false;
+ }
+ else {
+ $this->_can_connect[$hostname] = true;
+ }
+
+ $this->_can_connect_err[$hostname] = $err;
+ return $this->_can_connect[$hostname];
+ }
+
+
+ public function getName($default = 'MongoDB')
+ {
+ return $default;
+ }
+
+ public function getVersion()
+ {
+ // Return if already cached
+ if ($this->_version !== null) {
+ return $this->_version;
+ }
+
+ // Return empty if not available
+ if (!$this->isAvailable()) {
+ $this->_version = '';
+ return $this->_version;
+ }
+
+ if ($this->_mongo) {
+ $info = $this->getInfo();
+ if (!isset($info->version)) {
+ loadClass('Logger')->error('Could not get MongoDB version');
+ $this->_version = '';
+ } else {
+ $this->_version = $info->version;
+ }
+ }
+ return $this->_version;
+ }
+}
diff --git a/.tests/.lib.sh b/.tests/.lib.sh
index fe3b1d1f..833f9022 100644
--- a/.tests/.lib.sh
+++ b/.tests/.lib.sh
@@ -143,15 +143,6 @@ get_data_mounts() {
}
-###
-### Default enabled Docker Versions
-###
-get_enabled_versions() {
- grep -E '^[A-Z]+_SERVER=' "${DEVILBOX_PATH}/.env" | sed 's/_SERVER=/\t/g'
-
-}
-
-
################################################################################
#
@@ -234,17 +225,17 @@ enable_docker_php() {
#
################################################################################
-devilbox_start() {
+devilbox_configure() {
_srv1="${1}"
_ver1="${2}"
_srv2="${3}"
_ver2="${4}"
# Default values for remaining servers
- _def_php="php-fpm-7.0"
- _def_httpd="nginx-stable"
- _def_mysql="mariadb-10.0"
- _def_pgsql="9.6"
+ _def_php="${5}"
+ _def_httpd="${6}"
+ _def_mysql="${7}"
+ _def_pgsql="${8}"
# Specific enabled servers
_set_php=""
@@ -294,10 +285,6 @@ devilbox_start() {
_set_pgsql="${_def_pgsql}"
fi
-
- # Print Headline
- print_h1 "${_srv1}-${_ver1} vs ${_srv2}-${_ver2}"
-
# Adjust .env
comment_all_dockers
@@ -306,16 +293,46 @@ devilbox_start() {
enable_docker_httpd "${_set_httpd}"
enable_docker_mysql "${_set_mysql}"
enable_docker_pgsql "${_set_pgsql}"
+}
- # Run
- docker-compose up -d
+
+devilbox_configured_settings() {
+ grep -E '^[A-Z]+_SERVER=' "${DEVILBOX_PATH}/.env" | sed 's/_SERVER=/\t/g'
+}
+
+
+devilbox_pull() {
+ # Make sure to pull until success
+ ret=1
+ while [ "${ret}" != "0" ]; do
+ if ! docker-compose pull; then
+ ret=1
+ else
+ ret=0
+ fi
+ done
+}
+
+
+devilbox_start() {
+ # Make sure to start until success
+ ret=1
+ while [ "${ret}" != "0" ]; do
+ if ! docker-compose up -d; then
+ ret=1
+ # Stop it and try again
+ devilbox_stop
+ else
+ ret=0
+ fi
+ done
# Wait for http to return 200
printf "wait "
_max="90"
# shellcheck disable=SC2034
for i in $(seq 1 "${_max}"); do
- if [ "$( curl --connect-timeout 1 --max-time 1 -s -o /dev/null -w '%{http_code}' http://localhost/index.php )" = "200" ]; then
+ if [ "$( curl --connect-timeout 1 --max-time 1 -s -o /dev/null -w '%{http_code}' http://127.0.0.1/index.php )" = "200" ]; then
break;
fi
sleep 1
@@ -329,6 +346,25 @@ devilbox_start() {
}
+
+devilbox_print_actual_settings() {
+ VERSIONS="$( curl -q http://127.0.0.1/index.php 2>/dev/null | \
+ grep -E 'circles' | \
+ grep -oE '.*\(.*\)' | \
+ sed 's///g' | \
+ sed 's/<\/strong>.*(/\t/g' | \
+ sed 's/)//g' )"
+
+ IFS='
+'
+ for v in ${VERSIONS}; do
+ service="$( echo "${v}" | awk '{print $1}' )"
+ version="$( echo "${v}" | awk '{print $2}' )"
+ printf "%-15s%s\n" "${service}" "${version}"
+ done
+}
+
+
devilbox_stop() {
# Stop existing dockers
cd "${DEVILBOX_PATH}" || exit 1
@@ -346,178 +382,67 @@ devilbox_stop() {
done
}
-devilbox_show() {
- ###
- ### 1. Show Info
- ###
- print_h2 "Info"
- # Show wanted versions
- echo "[Wanted] .env settings"
- echo "------------------------------------------------------------"
- get_enabled_versions
+devilbox_print_errors() {
+ _url="${1}"
+
+ print_h2 "[ERROR] Curl"
+ curl -vv "${_url}" || true
echo
- # Get actual versions
- echo "[Actual] http://localhost settings"
- echo "------------------------------------------------------------"
- curl -q http://localhost/index.php 2>/dev/null | \
- grep -E 'circles' | \
- grep -oE '.*\(.*\)' | \
- sed 's///g' | \
- sed 's/<\/strong>.*(/\t/g' | \
- sed 's/)//g'
+ print_h2 "[ERROR] docker-compose ps"
+ docker-compose ps
echo
+
+ print_h2 "[ERROR] docker-compose logs"
+ docker-compose logs
+ echo
+
+ print_h2 "[ERROR] log files"
+ ls -lap log/
+ sudo find log -type f -exec sh -c 'echo "{}:\n-----------------"; cat "{}"; echo "\n\n"' \;
}
-
-
################################################################################
#
# T E S T T H E D E V I L B O X
#
################################################################################
-devilbox_test() {
- ###
- ### Variables
- ###
- _ret=0 # Final exit code
- _oks=17 # Require this many [OK]'s on the page
-
-
-
-
- ###
- ### 2. Test docker-compose
- ###
- print_h2 "docker-compose"
-
- echo "docker-compose ps"
- echo "------------------------------------------------------------"
- if _test_docker_compose >/dev/null 2>&1; then
- echo "[OK]: All running"
- else
- echo "[ERR]: Broken"
- _ret="$(( _ret + 1 ))"
- fi
-
-
- ###
- ### 3. Show Curl output
- ###
- print_h2 "3. Test status via curl"
-
- echo "Count [OK]'s on curl-ed url"
- echo "------------------------------------------------------------"
- if ! _cnt="$( _test_curled_oks "${_oks}" )"; then
- _ret="$(( _ret + 1 ))"
- echo "[ERR]: ${_cnt} / ${_oks} (Not all 'dvlbox-ok' found)"
- else
- echo "[OK]: ${_cnt} / ${_oks} (All 'dvlbox-ok' found)"
- fi
- echo
-
- echo "Count [ERR]'s on curl-ed url"
- echo "------------------------------------------------------------"
- if ! _cnt="$( _test_curled_err )"; then
- _ret="$(( _ret + 1 ))"
- echo "[ERR]: ${_cnt} / 0 (Found some 'dvlbox-err')"
- else
- echo "[OK]: ${_cnt} / 0 (No 'dvlbox-err' found)"
- fi
- echo
-
-
- ###
- ### Final return
- ###
- if [ "${_ret}" != "0" ]; then
- print_h2 "4. Error output"
- echo "Curl"
- echo "------------------------------------------------------------"
- curl -vv http://localhost/index.php || true
- echo
-
- echo "docker-compose ps"
- echo "------------------------------------------------------------"
- docker-compose ps
- echo
-
- echo "docker-compose logs"
- echo "------------------------------------------------------------"
- docker-compose logs
- echo
-
- echo "log files"
- echo "------------------------------------------------------------"
- ls -lap log/
- sudo find log -type f -exec sh -c 'echo "{}:\n-----------------"; cat "{}"; echo "\n\n"' \;
-
- return 1
- fi
-
- return 0
-}
-
-
-
-################################################################################
-#
-# T E S T I N G H E L P E R S
-#
-################################################################################
-
-###
-### Test against stopped containers
-###
-_test_docker_compose() {
+devilbox_test_compose() {
_broken="$( docker-compose ps | grep -c 'Exit' || true )"
_running="$( docker-compose ps | grep -c 'Up' || true )"
_total="$( docker-compose ps -q | grep -c '' || true )"
if [ "${_broken}" != "0" ]; then
+ echo "[ERR]: Broken: ${_broken} broken container"
return 1
fi
if [ "${_running}" != "${_total}" ]; then
+ echo "[ERR]: Broken: ${_running} / ${_total} container running"
return 1
fi
+ echo "[OK]: All running"
return 0
}
-###
-### Test [OK]'s found on website
-###
-_test_curled_oks() {
- _oks="${1}"
- _find_ok="dvlbox-ok"
+devilbox_test_url() {
+ # Variables
+ _url="${1}"
+ _pattern="${2}"
+ _number="${3}"
- _count="$( curl -q http://localhost/index.php 2>/dev/null | grep -c "${_find_ok}" || true )"
- echo "${_count}"
+ _count="$( curl -q "${_url}" 2>/dev/null | grep -c "${_pattern}" || true )"
- if [ "${_count}" != "${_oks}" ]; then
+ if [ "${_count}" != "${_number}" ]; then
+ echo "[ERR]: Found ${_count}/${_number} of '${_pattern}'"
return 1
- else
- return 0
- fi
-}
-
-###
-### Test [ERR]'s found on website
-###
-_test_curled_err() {
- _find_err="dvlbox-err"
-
- _count="$( curl -q http://localhost/index.php 2>/dev/null | grep -c "${_find_err}" || true )"
- echo "${_count}"
-
- if [ "${_count}" != "0" ]; then
- return 1
- else
- return 0
fi
+
+ echo "[OK]: Found ${_count}/${_number} of '${_pattern}'"
+ return 0
}
diff --git a/.tests/test_single.sh b/.tests/test_single.sh
index cb6a1dbd..4e00105d 100755
--- a/.tests/test_single.sh
+++ b/.tests/test_single.sh
@@ -58,6 +58,14 @@ set_host_port_httpd "80"
set_host_port_mysql "3306"
set_host_port_pgsql "5432"
+###
+### Default values for container
+###
+DEF_PHP="php-fpm-7.0"
+DEF_HTTPD="nginx-stable"
+DEF_MYSQL="mariadb-10.0"
+DEF_PGSQL="9.6"
+
################################################################################
@@ -66,7 +74,74 @@ set_host_port_pgsql "5432"
#
################################################################################
-devilbox_start "${DVL_SRV1}" "${DVL_VER1}" "${DVL_SRV2}" "${DVL_VER2}"
-devilbox_show
-devilbox_test
+###
+### Docker Host settings
+###
+print_h1 "Docker Host settings"
+
+print_h2 "Listening services"
+run "netstat -tulpn"
+
+print_h2 "Docker version"
+run "docker --version"
+run "docker-compose --version"
+
+
+
+###
+### Configure
+###
+print_h1 "Configuration: ${DVL_SRV1}-${DVL_VER1} vs ${DVL_SRV2}-${DVL_VER2}"
+
+print_h2 "Enabled settings in .env"
+devilbox_configure "${DVL_SRV1}" "${DVL_VER1}" "${DVL_SRV2}" "${DVL_VER2}" "${DEF_PHP}" "${DEF_HTTPD}" "${DEF_MYSQL}" "${DEF_PGSQL}"
+devilbox_configured_settings
+
+
+
+###
+### Download and run
+###
+print_h1 "Startup Devilbox"
+
+print_h2 "Download"
+devilbox_pull
+
+print_h2 "Run"
+devilbox_start
+
+print_h2 "Actual settings from index.php"
+devilbox_print_actual_settings
+
+
+
+###
+### Test
+###
+print_h1 "Testing"
+
+print_h2 "docker-compose"
+if ! devilbox_test_compose; then
+ devilbox_print_errors "http://127.0.0.1/index.php"
+ exit 1
+fi
+
+print_h2 "Testing 'dvlbox-ok': index.php"
+if ! devilbox_test_url "http://127.0.0.1/index.php" "dvlbox-ok" "20"; then
+ devilbox_print_errors "http://127.0.0.1/index.php"
+ exit 1
+fi
+
+print_h2 "Testing 'dvlbox-err': index.php"
+if ! devilbox_test_url "http://127.0.0.1/index.php" "dvlbox-err" "0"; then
+ devilbox_print_errors "http://127.0.0.1/index.php"
+ exit 1
+fi
+
+
+
+###
+### Stop
+###
+print_h1 "Shutdown and exit"
devilbox_stop
diff --git a/.travis.yml b/.travis.yml
index 3858bad8..b79dee7b 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -172,13 +172,12 @@ matrix:
###
before_install:
# Get newer docker version
- - sudo apt-get update
- - sudo apt-get -y -o Dpkg::Options::="--force-confnew" install docker-engine
+ - max=20; i=0; while [ $i -lt $max ]; do if sudo apt-get update; then break; else i=$((i+1)); fi done
+ - max=20; i=0; while [ $i -lt $max ]; do if sudo apt-get -y -o Dpkg::Options::="--force-confnew" install docker-engine; then break; else i=$((i+1)); fi done
# Get newer docker-compose version
- - sudo rm /usr/local/bin/docker-compose
- curl -L https://github.com/docker/compose/releases/download/1.13.0/docker-compose-`uname -s`-`uname -m` > docker-compose
- chmod +x docker-compose
- - sudo mv docker-compose /usr/local/bin
+ - sudo mv -f docker-compose /usr/local/bin
###
@@ -190,9 +189,14 @@ before_script:
- sudo /etc/init.d/mysql stop || true
- sudo /etc/init.d/postgresql stop || true
- sudo /etc/init.d/memcached stop || true
+ - sudo /etc/init.d/redis stop || true
+ - sudo /etc/init.d/mongodb stop || true
+
- sudo service mysql stop || true
- sudo service postgresql stop || true
- sudo service memcached stop || true
+ - sudo service redis stop || true
+ - sudo service mongodb stop || true
- netstat -tulpn
diff --git a/README.md b/README.md
index f1c89d8a..29b9aade 100644
--- a/README.md
+++ b/README.md
@@ -7,10 +7,10 @@
[Run-time Matrix](#run-time-matrix) |
[Intranet](#intranet-overview) |
[Screenshots](#screenshots) |
-[License](#license) |
[Contributing](#contributing) |
+[License](#license)
-![Devilbox](doc/img/devilbox-dash.png)
+![Devilbox](docs/img/devilbox-dash.png)
[![Build Status](https://travis-ci.org/cytopia/devilbox.svg?branch=master)](https://travis-ci.org/cytopia/devilbox) ![Tag](https://img.shields.io/github/tag/cytopia/devilbox.svg) [![type](https://img.shields.io/badge/type-Docker-orange.svg)](https://www.docker.com/) [![License](https://img.shields.io/badge/license-MIT-blue.svg)](https://opensource.org/licenses/MIT)
@@ -52,18 +52,18 @@ The above will start all containers, you can however also just start the contain
```shell
$ docker-compose up httpd php mysql redis
```
-![Devilbox](doc/img/devilbox-dash-01.png)
+![Devilbox](docs/img/devilbox-dash-01.png)
```shell
$ docker-compose up httpd php mysql pgsql redis memcd
```
-![Devilbox](doc/img/devilbox-dash-02.png)
+![Devilbox](docs/img/devilbox-dash-02.png)
```shell
$ docker-compose up httpd php pgsql memcd
```
-![Devilbox](doc/img/devilbox-dash-03.png)
+![Devilbox](docs/img/devilbox-dash-03.png)
### Run different versions
@@ -137,25 +137,25 @@ The devilbox has everything setup for you. The only thing you will have to insta
### Video Tutorials
-[![Devilbox setup and workflow](doc/img/devilbox_01-setup-and-workflow.png "devilbox - setup and workflow")](https://www.youtube.com/watch?v=reyZMyt2Zzo)
-[![Devilbox email catch-all](doc/img/devilbox_02-email-catch-all.png "devilbox - email catch-all")](https://www.youtube.com/watch?v=e-U-C5WhxGY)
+[![Devilbox setup and workflow](docs/img/devilbox_01-setup-and-workflow.png "devilbox - setup and workflow")](https://www.youtube.com/watch?v=reyZMyt2Zzo)
+[![Devilbox email catch-all](docs/img/devilbox_02-email-catch-all.png "devilbox - email catch-all")](https://www.youtube.com/watch?v=e-U-C5WhxGY)
### Documentation
-For setup, usage and examples see detailed **[Documentation](doc/README.md)**.
+For setup, usage and examples see detailed **[Documentation](docs/README.md)**.
| Documentaion | Description |
|---------------------------------------|-------------|
-| [Overview](doc/README.md) | General overview |
-| [Configuration](doc/Configuration.md) | How to configure the devilbox |
-| [Usage](doc/Usage.md) | How to use the devilbox |
-| [Updating](doc/Updating.md) | How to update |
-| [Info](doc/Info.md) | Technical information |
-| [PHP Projects](doc/PHP_Projects.md) | How to manage projects |
-| [Emails](doc/Emails.md) | How email catching works |
-| [Logs](doc/Logs.md) | How to view log files |
-| [Intranet](doc/Intranet.md) | The built-in intranet |
-| [FAQ](doc/FAQ.md) | Frequently asked questions |
+| [Overview](docs/README.md) | General overview |
+| [Configuration](docs/Configuration.md) | How to configure the devilbox |
+| [Usage](docs/Usage.md) | How to use the devilbox |
+| [Updating](docs/Updating.md) | How to update |
+| [Info](docs/Info.md) | Technical information |
+| [PHP Projects](docs/PHP_Projects.md) | How to manage projects |
+| [Emails](docs/Emails.md) | How email catching works |
+| [Logs](docs/Logs.md) | How to view log files |
+| [Intranet](docs/Intranet.md) | The built-in intranet |
+| [FAQ](docs/FAQ.md) | Frequently asked questions |
## Run-time Matrix
@@ -196,10 +196,11 @@ No need to install and configure different versions locally. Simply choose your
| Cassandra | CouchDB | Memcached | MongoDB | Redis |
|-----------|---------|-----------|---------|-------|
-| Cassandra 2.1 | CouchDB 1.6 | [![Travis CI](https://img.shields.io/travis/docker-library/memcached/master.svg)](https://travis-ci.org/docker-library/memcached/branches) Memcached latest | MongoDB 2.6 | [![Travis CI](https://img.shields.io/travis/docker-library/redis/master.svg)](https://travis-ci.org/docker-library/redis/branches) [Redis 2.8](https://github.com/docker-library/redis) |
-| Cassandra 2.2 | CouchDB 2.0 | | MongoDB 3.0 | [![Travis CI](https://img.shields.io/travis/docker-library/redis/master.svg)](https://travis-ci.org/docker-library/redis/branches) [Redis 3.0](https://github.com/docker-library/redis) |
-| Cassandra 3.0 | | | MongoDB 3.2 | [![Travis CI](https://img.shields.io/travis/docker-library/redis/master.svg)](https://travis-ci.org/docker-library/redis/branches) [Redis 3.2](https://github.com/docker-library/redis) |
-| | | | MongoDB 3.4 | |
+| Cassandra 2.1 | CouchDB 1.6 | [![Travis CI](https://travis-ci.org/docker-library/memcached.svg?branch=master)](https://travis-ci.org/docker-library/memcached) [latest](https://github.com/docker-library/memcached) | [![build Status](https://travis-ci.org/docker-library/mongo.svg?branch=master)](https://travis-ci.org/docker-library/mongo) [2.8](https://github.com/docker-library/mongo) | [![Travis CI](https://travis-ci.org/docker-library/redis.svg?branch=master)](https://travis-ci.org/docker-library/redis) [2.8](https://github.com/docker-library/redis) |
+| Cassandra 2.2 | CouchDB 2.0 | | [![build Status](https://travis-ci.org/docker-library/mongo.svg?branch=master)](https://travis-ci.org/docker-library/mongo) [3.0](https://github.com/docker-library/mongo) | [![Travis CI](https://travis-ci.org/docker-library/redis.svg?branch=master)](https://travis-ci.org/docker-library/redis) [3.0](https://github.com/docker-library/redis) |
+| Cassandra 3.0 | | | [![build Status](https://travis-ci.org/docker-library/mongo.svg?branch=master)](https://travis-ci.org/docker-library/mongo) [3.2](https://github.com/docker-library/mongo) | [![Travis CI](https://travis-ci.org/docker-library/redis.svg?branch=master)](https://travis-ci.org/docker-library/redis) [3.2](https://github.com/docker-library/redis) |
+| | | | [![build Status](https://travis-ci.org/docker-library/mongo.svg?branch=master)](https://travis-ci.org/docker-library/mongo) [3.4](https://github.com/docker-library/mongo) | |
+| | | | [![build Status](https://travis-ci.org/docker-library/mongo.svg?branch=master)](https://travis-ci.org/docker-library/mongo) [3.5](https://github.com/docker-library/mongo) | |
**Note:** Entries without links or without build-status are planned, but not yet available. See [ROADMAP](https://github.com/cytopia/devilbox/issues/23) for tasks and upcoming features.
@@ -253,7 +254,7 @@ The homepage shows you the status of your current configured setup.
* what other settings have been set
* did any errors occur?
-![Intranet Home](doc/img/01_intranet_home.png "Intranet Home")
+![Intranet Home](docs/img/01_intranet_home.png "Intranet Home")
### Virtual Host overview
@@ -265,30 +266,35 @@ Virtual Hosts are considered valid if the following requirements are met (on the
* `htdocs` folder/symlink exists in your project folder
* `/etc/hosts` has a valid DNS config for your host: `127.0.0.1 .` (alternatively the bundle BIND server can be attached to your host-computer).
-![Intranet vHost](doc/img/02_intranet_vhosts.png "Intranet Home")
+![Intranet vHost](docs/img/02_intranet_vhosts.png "Intranet Home")
### Database overview
Shows you all the databases that are loaded
-![Intranet DB](doc/img/03_intranet_databases.png "Intranet Home")
+![Intranet DB](docs/img/03_intranet_databases.png "Intranet Home")
### Email overview
Shows you all the emails that have been sent. No email will actually be sent outside, but they are all catched by one account and presented here.
-![Intranet Email](doc/img/04_intranet_emails.png "Intranet Home")
+![Intranet Email](docs/img/04_intranet_emails.png "Intranet Home")
+
+
+## Contributing
+
+Contributers are welcome in any way.
+
+First of all, if you like the project, please **do star it**. Starring is an important measurement to see the number of active users and better allows me to organize my time and effort I can put into this project.
+
+Secondly, please **do report all bugs**. This will not only help you get your problem fixed, but also help others as they might encounter the same.
+
+And last but not least, you can also get actively involved. **Do clone the project** and start improving whatever you think is useful. There is quite a lot todo and planned. If you like to contribute, view [CONTRIBUTING.md](CONTRIBUTING.md) and [ROADMAP](https://github.com/cytopia/devilbox/issues/23).
+
+Major contributors will be credited within the intranet and on the github page.
## License
[MIT License](LICENSE.md)
-
-
-## Contributing
-
-There is quite a lot todo and planned. If you like to contribute, view [CONTRIBUTING.md](CONTRIBUTING.md) and [ROADMAP](https://github.com/cytopia/devilbox/issues/23).
-
-Contributors will be credited within the intranet and on the github page.
-
diff --git a/docker-compose.yml b/docker-compose.yml
index 7c35c526..c1770476 100644
--- a/docker-compose.yml
+++ b/docker-compose.yml
@@ -31,12 +31,14 @@ services:
# Bind (DNS Server)
# ----------------------------------------
bind:
- image: cytopia/bind:latest
+ #image: cytopia/bind:latest
+ image: cytopia/bind:0.10
restart: always
ports:
# [local-machine:]local-port:docker-port
- "${LOCAL_LISTEN_ADDR}${HOST_PORT_BIND}:53"
- "${LOCAL_LISTEN_ADDR}${HOST_PORT_BIND}/udp:53/udp"
+
environment:
##
## Debug?
@@ -48,6 +50,7 @@ services:
##
- WILDCARD_DOMAIN=${TLD_SUFFIX:-loc}
- WILDCARD_ADDRESS=172.16.238.11
+ - BIND_DNS_RESOLVER=${BIND_DNS_RESOLVER:-8.8.8.8,8.8.4.4}
dns:
- 127.0.0.1
@@ -62,7 +65,7 @@ services:
# ----------------------------------------
php:
#image: cytopia/${PHP_SERVER:-php-fpm-7.0}:latest
- image: cytopia/${PHP_SERVER:-php-fpm-7.0}:0.9
+ image: cytopia/${PHP_SERVER:-php-fpm-7.0}:0.10
restart: always
# Manually build via `docker-compose build`
@@ -109,7 +112,7 @@ services:
##
## Enable 127.0.0.1 Port-forwarding
##
- - FORWARD_PORTS_TO_LOCALHOST=3306:mysql:3306,5432:pgsql:5432,6379:redis:6379,11211:memcd:11211
+ - FORWARD_PORTS_TO_LOCALHOST=3306:mysql:3306,5432:pgsql:5432,6379:redis:6379,11211:memcd:11211,27017:mongo:27017
##
## Additional variables to announce to intranet/php-container
@@ -122,10 +125,12 @@ services:
- HOST_PORT_PGSQL
- HOST_PORT_REDIS
- HOST_PORT_MEMCD
+ - HOST_PORT_MONGO
# Data dir paths
- HOST_PATH_HTTPD_DATADIR
- HOST_PATH_MYSQL_DATADIR
- HOST_PATH_PGSQL_DATADIR
+ - HOST_PATH_MONGO_DATADIR
# Database credentials
- PGSQL_ROOT_USER
- PGSQL_ROOT_PASSWORD
@@ -137,6 +142,7 @@ services:
- MYSQL_SERVER
- REDIS_SERVER
- MEMCD_SERVER
+ - MONGO_SERVER
networks:
app_net:
@@ -415,6 +421,33 @@ services:
- httpd
+ # ----------------------------------------
+ # Mongo
+ # ----------------------------------------
+ mongo:
+ image: mongo:${MONGO_SERVER:-latest}
+
+ ports:
+ # [local-machine:]local-port:docker-port
+ - "${LOCAL_LISTEN_ADDR}${HOST_PORT_MONGO}:27017"
+
+ networks:
+ app_net:
+ ipv4_address: 172.16.238.16
+
+ volumes:
+ # ---- Format: ----
+ # HOST-DIRECTORY : DOCKER-DIRECTORY
+
+ # Mount MySQL Data directory
+ - ${HOST_PATH_MONGO_DATADIR}:/data/db
+
+ depends_on:
+ - bind
+ - php
+ - httpd
+
+
################################################################################
# NETWORK
################################################################################
diff --git a/doc/Configuration.md b/docs/Configuration.md
similarity index 100%
rename from doc/Configuration.md
rename to docs/Configuration.md
diff --git a/doc/Emails.md b/docs/Emails.md
similarity index 100%
rename from doc/Emails.md
rename to docs/Emails.md
diff --git a/doc/FAQ.md b/docs/FAQ.md
similarity index 100%
rename from doc/FAQ.md
rename to docs/FAQ.md
diff --git a/doc/Info.md b/docs/Info.md
similarity index 85%
rename from doc/Info.md
rename to docs/Info.md
index a8c57dad..e589d6a4 100644
--- a/doc/Info.md
+++ b/docs/Info.md
@@ -32,6 +32,7 @@ It is best to use the hostnames and not to rely on the ip addresses as they migh
| PostgreSQL | pgsql | pgsql | 172.16.238.13 |
| Redis | redis | redis | 172.16.238.14 |
| Memcached | memcd | memcd | 172.16.238.15 |
+| MongoDB | mongo | mongo | 172.16.238.16 |
### Background
@@ -44,9 +45,10 @@ This is also the reason it does some more magic than actually required.
The PHP container is using [socat](https://linux.die.net/man/1/socat) to
1. forward the remote mysql port `3306` (on the mysql container) to its own `127.0.0.1:3306`
-2. forward the remote pgsql port `5432` (on the mysql container) to its own `127.0.0.1:5432`
-3. forward the remote redis port `6379` (on the mysql container) to its own `127.0.0.1:6379`
-3. forward the remote memcached port `11211` (on the memcd container) to its own `127.0.0.1:11211`
+2. forward the remote pgsql port `5432` (on the pgsql container) to its own `127.0.0.1:5432`
+3. forward the remote redis port `6379` (on the redis container) to its own `127.0.0.1:6379`
+4. forward the remote memcached port `11211` (on the memcd container) to its own `127.0.0.1:11211`
+5. forward the remote mongodb port `27017` (on the mongo container) to its own `127.0.0.1:27017`
#### Background - Docker Host
@@ -56,6 +58,7 @@ The docker host (your computer) does exactly the same as the `php` container.
2. container pgsql port `5432` is exposed to the host on port `127.0.0.1:5432`
3. container redis port `6379` is exposed to the host on port `127.0.0.1:6379`
3. container memcd port `11211` is exposed to the host on port `127.0.0.1:11211`
+3. container mongo port `27017` is exposed to the host on port `127.0.0.1:27017`
Also the database sockets from the container are mounted into the host.
diff --git a/doc/Intranet.md b/docs/Intranet.md
similarity index 100%
rename from doc/Intranet.md
rename to docs/Intranet.md
diff --git a/doc/Logs.md b/docs/Logs.md
similarity index 100%
rename from doc/Logs.md
rename to docs/Logs.md
diff --git a/doc/PHP_Projects.md b/docs/PHP_Projects.md
similarity index 100%
rename from doc/PHP_Projects.md
rename to docs/PHP_Projects.md
diff --git a/doc/README.md b/docs/README.md
similarity index 100%
rename from doc/README.md
rename to docs/README.md
diff --git a/doc/Updating.md b/docs/Updating.md
similarity index 100%
rename from doc/Updating.md
rename to docs/Updating.md
diff --git a/doc/Usage.md b/docs/Usage.md
similarity index 100%
rename from doc/Usage.md
rename to docs/Usage.md
diff --git a/doc/img/01_intranet_home.png b/docs/img/01_intranet_home.png
similarity index 100%
rename from doc/img/01_intranet_home.png
rename to docs/img/01_intranet_home.png
diff --git a/doc/img/02_intranet_vhosts.png b/docs/img/02_intranet_vhosts.png
similarity index 100%
rename from doc/img/02_intranet_vhosts.png
rename to docs/img/02_intranet_vhosts.png
diff --git a/doc/img/03_intranet_databases.png b/docs/img/03_intranet_databases.png
similarity index 100%
rename from doc/img/03_intranet_databases.png
rename to docs/img/03_intranet_databases.png
diff --git a/doc/img/04_intranet_emails.png b/docs/img/04_intranet_emails.png
similarity index 100%
rename from doc/img/04_intranet_emails.png
rename to docs/img/04_intranet_emails.png
diff --git a/doc/img/devilbox-dash-01.png b/docs/img/devilbox-dash-01.png
similarity index 100%
rename from doc/img/devilbox-dash-01.png
rename to docs/img/devilbox-dash-01.png
diff --git a/doc/img/devilbox-dash-02.png b/docs/img/devilbox-dash-02.png
similarity index 100%
rename from doc/img/devilbox-dash-02.png
rename to docs/img/devilbox-dash-02.png
diff --git a/doc/img/devilbox-dash-03.png b/docs/img/devilbox-dash-03.png
similarity index 100%
rename from doc/img/devilbox-dash-03.png
rename to docs/img/devilbox-dash-03.png
diff --git a/doc/img/devilbox-dash.png b/docs/img/devilbox-dash.png
similarity index 100%
rename from doc/img/devilbox-dash.png
rename to docs/img/devilbox-dash.png
diff --git a/doc/img/devilbox_01-setup-and-workflow.png b/docs/img/devilbox_01-setup-and-workflow.png
similarity index 100%
rename from doc/img/devilbox_01-setup-and-workflow.png
rename to docs/img/devilbox_01-setup-and-workflow.png
diff --git a/doc/img/devilbox_02-email-catch-all.png b/docs/img/devilbox_02-email-catch-all.png
similarity index 100%
rename from doc/img/devilbox_02-email-catch-all.png
rename to docs/img/devilbox_02-email-catch-all.png
diff --git a/doc/img/devilbox_player_480.png b/docs/img/devilbox_player_480.png
similarity index 100%
rename from doc/img/devilbox_player_480.png
rename to docs/img/devilbox_player_480.png
diff --git a/env-example b/env-example
index 527ea271..fce653c3 100644
--- a/env-example
+++ b/env-example
@@ -16,7 +16,7 @@
###
### 1: Yes
### 0: No
-DEBUG_COMPOSE_ENTRYPOINT=1
+DEBUG_COMPOSE_ENTRYPOINT=0
###
@@ -79,6 +79,24 @@ TLD_SUFFIX=loc
DNS_CHECK_TIMEOUT=1
+###
+### Set your user id and group id
+###
+### This should be changed to the value of your local
+### users uid and gid
+###
+### Type `id` on the terminal to find out your values
+###
+NEW_UID=1000
+NEW_GID=1000
+
+
+###
+### Timezone for all dockers and service config files
+###
+TIMEZONE=Europe/Berlin
+
+
################################################################################
###
@@ -139,8 +157,6 @@ PGSQL_SERVER=9.6
###
### 1.5 Choose Redis Server Image
-### (only for docker-compose.optional.yml)
-### $ docker-compose -f docker-compose.optional.yml up
###
#REDIS_SERVER=2.8
#REDIS_SERVER=3.0
@@ -148,9 +164,7 @@ REDIS_SERVER=3.2
###
-### 1.6 Choose Memcahced Server Image
-### (only for docker-compose.optional.yml)
-### $ docker-compose -f docker-compose.optional.yml up
+### 1.6 Choose Memcached Server Image
###
MEMCD_SERVER=1.4.21
#MEMCD_SERVER=1.4.22
@@ -171,6 +185,14 @@ MEMCD_SERVER=1.4.21
#MEMCD_SERVER=latest
+###
+### 1.7 Choose Mongo Server Image
+###
+#MONGO_SERVER=2.8
+#MONGO_SERVER=3.0
+#MONGO_SERVER=3.2
+MONGO_SERVER=3.4
+#MONGO_SERVER=3.5
@@ -220,29 +242,17 @@ HOST_PATH_MYSQL_DATADIR=./data/mysql
HOST_PATH_PGSQL_DATADIR=./data/pgsql
-
-################################################################################
###
-### 3. GENERAL DOCKER CONTAINER SETTINGS
+### Local filesystem path to mongodb datadir.
###
-################################################################################
-
+### This can be an existing mongodb data directory or empty.
+### If it already is a mongodb data directory with content,
+### it will be mounted into the docker and used.
###
-### Set your user id and group id
+### If this directory is empty, a new mongodb database will be
+### created.
###
-### This should be changed to the value of your local
-### users uid and gid
-###
-### Type `id` on the terminal to find out your values
-###
-NEW_UID=1000
-NEW_GID=1000
-
-
-###
-### Timezone for all dockers and service config files
-###
-TIMEZONE=Europe/Berlin
+HOST_PATH_MONGO_DATADIR=./data/mongo
@@ -342,7 +352,7 @@ HOST_PORT_PGSQL=5432
################################################################################
###
-### Expost Redis Port to Host
+### Expose Redis Port to Host
###
HOST_PORT_REDIS=6379
@@ -355,18 +365,38 @@ HOST_PORT_REDIS=6379
################################################################################
###
-### Expost Memcached Port to Host
+### Expose Memcached Port to Host
###
HOST_PORT_MEMCD=11211
+
################################################################################
###
-### 9. Bind Docker Settings
+### 9. MongoDB Docker Settings
###
################################################################################
###
-### Expost Bind Port to Host
+### Expose MongoDB Port to Host
+###
+HOST_PORT_MONGO=27017
+
+
+
+################################################################################
+###
+### 10. Bind Docker Settings
+###
+################################################################################
+
+###
+### Expose Bind Port to Host
###
HOST_PORT_BIND=53
+
+###
+### Add comma separated DNS server from which you want to receive DNS
+### You can also add DNS servers from your LAN (if any are available)
+###
+BIND_DNS_RESOLVER=8.8.8.8,8.8.4.4