Skip to content

Commit

Permalink
Official mysql container (#503)
Browse files Browse the repository at this point in the history
* Refs #175, Refs #382 Use Docker volumes instead of data directories

* Ensure default values are used for mounted data directories as well

* Update container versions

* Remove unecessary data dirs

* Ensure mail uses a Docker volume

* Clean up docker-compose.yml

* Adjust project files: CHANGELOG, CONTRIBUTING and UPDATING

* Refs: #501 #448 Use Official MySQL, MariaDB and Percona images

* Ensure Docker Compose examples use Docker volumes

* Fix gitignore

* Bump version

* Update Changelog

* Update container versions

* Ensure mail uses a Docker volume

* Refs: #501 #448 Use Official MySQL, MariaDB and Percona images

* Ensure Docker Compose examples use Docker volumes

* Fix gitignore

* Bump version

* Update Changelog

* Fix Docker image update script

* Remove obsolete configuration directories

* Bump version date

* Fix fetching Memcached keys

* Show the usage of Docker volumes in intranet

* Be more verbose on connection tests
  • Loading branch information
cytopia authored Feb 12, 2019
1 parent 937e80a commit b8a7208
Show file tree
Hide file tree
Showing 33 changed files with 157 additions and 421 deletions.
Empty file removed .devilbox/etc/mariadb-10.3/.keepme
Empty file.
Empty file removed .devilbox/etc/mariadb-5.5/.keepme
Empty file.
Empty file removed .devilbox/etc/mysql-5.5/.keepme
Empty file.
Empty file removed .devilbox/etc/mysql-5.6/.keepme
Empty file.
Empty file removed .devilbox/etc/mysql-5.7/.keepme
Empty file.
Empty file removed .devilbox/etc/mysql-8.0/.keepme
Empty file.
10 changes: 0 additions & 10 deletions .devilbox/etc/mysql-8.0/charset.cnf

This file was deleted.

4 changes: 2 additions & 2 deletions .devilbox/www/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
putenv('RES_OPTIONS=retrans:1 retry:1 timeout:1 attempts:1');


$DEVILBOX_VERSION = 'v0.15';
$DEVILBOX_DATE = '2019-01-30';
$DEVILBOX_VERSION = 'v1.0.0-alpha1';
$DEVILBOX_DATE = '2019-02-11';
$DEVILBOX_API_PAGE = 'devilbox-api/status.json';

//
Expand Down
6 changes: 3 additions & 3 deletions .devilbox/www/htdocs/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -679,14 +679,14 @@
<?php if ($avail_mysql): ?>
<tr>
<th>mysql</th>
<td><?php echo loadClass('Helper')->getEnv('HOST_PATH_MYSQL_DATADIR').'/'.loadClass('Helper')->getEnv('MYSQL_SERVER'); ?></td>
<td>Docker volume</td>
<td>/var/lib/mysql</td>
</tr>
<?php endif; ?>
<?php if ($avail_pgsql): ?>
<tr>
<th>pgsql</th>
<td><?php echo loadClass('Helper')->getEnv('HOST_PATH_PGSQL_DATADIR').'/'.loadClass('Helper')->getEnv('PGSQL_SERVER'); ?></td>
<td>Docker volume</td>
<td>/var/lib/postgresql/data/pgdata</td>
</tr>
<?php endif; ?>
Expand All @@ -707,7 +707,7 @@
<?php if ($avail_mongo): ?>
<tr>
<th>mongo</th>
<td><?php echo loadClass('Helper')->getEnv('HOST_PATH_MONGO_DATADIR'); ?></td>
<td>Docker volume</td>
<td>/data/db</td>
</tr>
<?php endif; ?>
Expand Down
19 changes: 18 additions & 1 deletion .devilbox/www/include/lib/container/Memcd.php
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,25 @@ public function getKeys()
// Memcached >= 1.5
for ($i=0; $i<$cli_retries; $i++) {

// Get item number to trigger with stats cachedump
$output = array();
exec('printf "stats cachedump 1 0\nquit\n" | nc memcd 11211 | grep -E \'^ITEM\'', $output);
exec('printf "stats items\nquit\n" | nc memcd 11211 | grep -E \'items:[0-9]+:number\s[0-9]+\'', $output);
$num1 = 1;
$num2 = 0;
if (isset($output[0])) {
$matches = array();
preg_match('/items:([0-9]+):number\s([0-9]+)/', $output[0], $matches);
if (isset($matches[1])) {
$num1 = $matches[1];
}
if (isset($matches[2])) {
$num2 = $matches[2];
}
}

// Trigger stats cachedump on item number
$output = array();
exec('printf "stats cachedump '.$num1.' '.$num2.' \nquit\n" | nc memcd 11211 | grep -E \'^ITEM\'', $output);
foreach ($output as $line) {
$matches = array();
preg_match('/(^ITEM)\s*(.+?)\s*\[([0-9]+\s*b);\s*([0-9]+\s*s)\s*\]/', $line, $matches);
Expand Down
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,16 @@
/cfg/mysql-5.6/*.cnf
/cfg/mysql-5.7/*.cnf
/cfg/mysql-8.0/*.cnf
/cfg/mariadb-5/*.cnf
/cfg/mariadb-5.5/*.cnf
/cfg/mariadb-10.0/*.cnf
/cfg/mariadb-10.1/*.cnf
/cfg/mariadb-10.2/*.cnf
/cfg/mariadb-10.3/*.cnf
/cfg/mariadb-10.4/*.cnf
/cfg/percona-5.5/*.cnf
/cfg/percona-5.6/*.cnf
/cfg/percona-5.7/*.cnf
/cfg/percona-8.0/*.cnf

# Ignore custom PHP.ini configs
/cfg/php-ini-5.2/*.ini
Expand Down
16 changes: 14 additions & 2 deletions .tests/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -517,44 +517,56 @@ _logs:


_wait:
@printf "Waiting for container to be ready ";
@printf "Waiting for HTTP 200 ";
@# [HTTPD] Test for HTTP Status 200
@until curl -sS -o /dev/null -I -w "%{http_code}" localhost 2>/dev/null | grep -q '200'; do \
printf "."; \
sleep 1; \
done;
@printf "\n";

@# [PHP] Test for HTTP content
@printf "Waiting for Intranet to be ready ";
@until curl -sS localhost 2>/dev/null | grep -q 'dvlbox-ok'; do \
printf "."; \
sleep 1; \
done;
@printf "\n";

@# Add 20 more seconds for other services (e.g.: db) to initialize properly
@# Add 20 more seconds just to be sure
@printf "Waiting for initial setup ";
@for i in $$(seq 1 20); do \
printf "."; \
sleep 1; \
done;
@printf "\n";

@# [MongoDB] Test for MongoDB connection
@printf "Waiting for MongoDB connection to be ready ";
@until cd $(DEVILBOX_PATH) && docker-compose exec php mongofiles --host=mongo list >/dev/null 2>&2; do \
printf "."; \
sleep 1; \
done;
@printf "\n";

@# [MYSQL] Test for MySQL connection
@printf "Waiting for MySQL connection to be ready ";
@until cd $(DEVILBOX_PATH) && docker-compose exec php mysql --user=root --password='' --host=mysql -e 'show databases;' 2>&1 | grep -q mysql; do \
printf "."; \
sleep 1; \
done;
@printf "\n";

@# [PGSQL] Test for PGSQL connection
@printf "Waiting for PostgreSQL connection to be ready ";
@until cd $(DEVILBOX_PATH) && docker-compose exec php pg_isready --host=pgsql >/dev/null 2>&1; do \
printf "."; \
sleep 1; \
done;
@printf "\n";

@# Add 40 more seconds just to be sure
@printf "Waiting for additional warm-up time ";
@for i in $$(seq 1 40); do \
printf "."; \
sleep 1; \
Expand Down
3 changes: 3 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -142,9 +142,12 @@ env:
- S1=PHP V1=7.2 S2=MYSQL V2=mariadb-10.0
- S1=PHP V1=7.2 S2=MYSQL V2=mariadb-10.1
- S1=PHP V1=7.2 S2=MYSQL V2=mariadb-10.2
- S1=PHP V1=7.2 S2=MYSQL V2=mariadb-10.3
- S1=PHP V1=7.2 S2=MYSQL V2=mariadb-10.4
- S1=PHP V1=7.2 S2=MYSQL V2=percona-5.5
- S1=PHP V1=7.2 S2=MYSQL V2=percona-5.6
- S1=PHP V1=7.2 S2=MYSQL V2=percona-5.7
- S1=PHP V1=7.2 S2=MYSQL V2=percona-8.0
# PHP 7.2 vs PgSQL
- S1=PHP V1=7.2 S2=PGSQL V2=9.0
- S1=PHP V1=7.2 S2=PGSQL V2=9.1
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ major versions.
- Use Docker volumes instead of directory mounts for stateful data (MySQL, PgSQL and MongoDB)
- This fixes various mount issues on Windows: #175 #382
- This improves general performance
- Use Official MySQL, MariaDB and Percona Docker container


## v0.15.0 [unreleased]
Expand Down
File renamed without changes.
5 changes: 5 additions & 0 deletions cfg/mariadb-10.4/devilbox-custom.cnf-example
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[mysqld]
;key_buffer_size=16M

[mysqldump]
;quick
File renamed without changes.
5 changes: 5 additions & 0 deletions cfg/mariadb-5.5/devilbox-custom.cnf-example
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[mysqld]
;key_buffer_size=16M

[mysqldump]
;quick
File renamed without changes.
5 changes: 5 additions & 0 deletions cfg/percona-8.0/devilbox-custom.cnf-example
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[mysqld]
;key_buffer_size=16M

[mysqldump]
;quick
7 changes: 4 additions & 3 deletions compose/docker-compose.override.yml-all
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ services:
app_net:
ipv4_address: 172.16.238.210
volumes:
- ${HOST_PATH_RABBIT_DATADIR:-./data/rabbit}/${RABBIT_SERVER:-management}:/var/lib/rabbitmq
- devilbox-rabbit:/var/lib/rabbitmq
depends_on:
- bind
- php
Expand All @@ -60,7 +60,7 @@ services:
app_net:
ipv4_address: 172.16.238.220
volumes:
- data-solr:/opt/solr/server/solr/mycores
- devilbox-solr:/opt/solr/server/solr/mycores
entrypoint:
- docker-entrypoint.sh
- solr-precreate
Expand All @@ -71,4 +71,5 @@ services:
- httpd

volumes:
data-solr:
devilbox-rabbit:
devilbox-solr:
5 changes: 4 additions & 1 deletion compose/docker-compose.override.yml-rabbitmq
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,11 @@ services:
app_net:
ipv4_address: 172.16.238.210
volumes:
- ${HOST_PATH_RABBIT_DATADIR:-./data/rabbit}/${RABBIT_SERVER:-management}:/var/lib/rabbitmq
- devilbox-rabbit:/var/lib/rabbitmq
depends_on:
- bind
- php
- httpd

volumes:
devilbox-rabbit:
4 changes: 2 additions & 2 deletions compose/docker-compose.override.yml-solr
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ services:
app_net:
ipv4_address: 172.16.238.220
volumes:
- data-solr:/opt/solr/server/solr/mycores
- devilbox-solr:/opt/solr/server/solr/mycores
entrypoint:
- docker-entrypoint.sh
- solr-precreate
Expand All @@ -21,4 +21,4 @@ services:
- httpd

volumes:
data-solr:
devilbox-solr:
40 changes: 6 additions & 34 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -303,35 +303,12 @@ services:
# MySQL Database
# ------------------------------------------------------------
mysql:
image: cytopia/${MYSQL_SERVER}:latest
image: devilbox/mysql:${MYSQL_SERVER}
hostname: mysql

environment:

##
## Debug?
##
- DEBUG_COMPOSE_ENTRYPOINT

##
## Adjust timezone
##
- TIMEZONE

##
## Adjust Root password
##
- MYSQL_ROOT_PASSWORD

##
## Socket directory Path
##
- MYSQL_SOCKET_DIR=/tmp/mysql

##
## Runtime settings
##
- MYSQL_GENERAL_LOG=${MYSQL_GENERAL_LOG}
- MYSQL_ALLOW_EMPTY_PASSWORD=yes

ports:
# [local-machine:]local-port:docker-port
Expand All @@ -345,15 +322,8 @@ services:
# ---- Format: ----
# HOST-DIRECTORY : DOCKER-DIRECTORY

# Mount logs
- ${DEVILBOX_PATH}/log/${MYSQL_SERVER}:/var/log/mysql:rw${MOUNT_OPTIONS}

# Mount devilbox default overwrites
- ${DEVILBOX_PATH}/.devilbox/etc/${MYSQL_SERVER}:/etc/mysql/conf.d:ro${MOUNT_OPTIONS}

# Mount devilbox user-defined cnf files in order
# to overwrite the MySQL server configuration
- ${DEVILBOX_PATH}/cfg/${MYSQL_SERVER}:/etc/mysql/docker-default.d:ro${MOUNT_OPTIONS}
- ${DEVILBOX_PATH}/cfg/${MYSQL_SERVER}:/etc/mysql/conf.d:ro${MOUNT_OPTIONS}

# Mount MySQL Data directory
- devilbox-${MYSQL_SERVER}:/var/lib/mysql:rw${MOUNT_OPTIONS}
Expand Down Expand Up @@ -426,7 +396,7 @@ services:
# HOST-DIRECTORY : DOCKER-DIRECTORY

# Mount logs
- ${DEVILBOX_PATH}/log/redis-${REDIS_SERVER}:/var/log/redis:rw${MOUNT_OPTIONS}
- ${DEVILBOX_PATH}/log/redis-${REDIS_SERVER:-latest}:/var/log/redis:rw${MOUNT_OPTIONS}

depends_on:
- bind
Expand Down Expand Up @@ -526,9 +496,11 @@ volumes:
devilbox-mariadb-10.1:
devilbox-mariadb-10.2:
devilbox-mariadb-10.3:
devilbox-mariadb-10.4:
devilbox-percona-5.5:
devilbox-percona-5.6:
devilbox-percona-5.7:
devilbox-percona-8.0:

# ------------------------------------------------------------
# Postgres
Expand Down
Loading

0 comments on commit b8a7208

Please sign in to comment.