Skip to content

Commit

Permalink
Merge branch 'hotfix-0.2.2' into stable
Browse files Browse the repository at this point in the history
  • Loading branch information
BertrandGouny committed Feb 23, 2015
2 parents e01bfc4 + 12dee8f commit 5cadf1d
Show file tree
Hide file tree
Showing 95 changed files with 177 additions and 118 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@
## 0.2.0 (release date: 2014-10-15)
- Change baseimage from 0.6.0 to 0.9.0
- Change docker command from docker.io to docker
- add changelog
- Add changelog
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
NAME = osixia/mariadb
VERSION = 0.2.1
VERSION = 0.2.2

.PHONY: all build test tag_latest release

Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ This can also be changed at the docker command line.

For example if you want to allow MariaDB root login from docker default network and localhost :

docker run -e ROOT_ALLOWED_NETWORKS=172.17.%.%,localhost,127.0.0.1,::1 \
docker run -e ROOT_ALLOWED_NETWORKS="['172.17.%.%', 'localhost', '127.0.0.1', '::1']" \
-d osixia/mariadb


Expand All @@ -51,10 +51,10 @@ This example will run a docker MariaDB container and execute an sql query from d

CONTAINER_ID=$(docker run -e ROOT_USER=JaxTeller \
-e ROOT_PWD=SonsOfAnarchy \
-e ROOT_ALLOWED_NETWORKS=172.17.%.%,localhost,127.0.0.1,::1 \
-e ROOT_ALLOWED_NETWORKS="['172.17.%.%', 'localhost', '127.0.0.1', '::1']" \
-d osixia/mariadb)

CONTAINER_IP=$(docker.io inspect -f "{{ .NetworkSettings.IPAddress }}" $CONTAINER_ID)
CONTAINER_IP=$(docker inspect -f "{{ .NetworkSettings.IPAddress }}" $CONTAINER_ID)

mysql -u JaxTeller -pSonsOfAnarchy -h $CONTAINER_IP -e "select user,host from mysql.user"

Expand Down Expand Up @@ -90,7 +90,7 @@ Required for uninitialized and initialized database :
- **ROOT_PWD**: The database root password. Defaults to `admin`

Required only for uninitialized database
- **ROOT_ALLOWED_NETWORKS**: root login will only be allowed from those networks. Defaults to `localhost,127.0.0.1,::1`
- **ROOT_ALLOWED_NETWORKS**: root login will only be allowed from those networks. Defaults to `['localhost', '127.0.0.1', '::1']`

## Manual build

Expand Down
39 changes: 19 additions & 20 deletions image/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,17 +1,9 @@
FROM osixia/baseimage:0.10.1
FROM osixia/baseimage:0.10.2
MAINTAINER Bertrand Gouny <[email protected]>

## Default configuration: can be overridden at the docker command line
# Required for uninitialized and initialized database
ENV ROOT_USER admin
ENV ROOT_PWD admin

# Required for uninitialized database
ENV ROOT_ALLOWED_NETWORKS localhost,127.0.0.1,::1

# MariaDB version
ENV MARIADB_MAJOR 10.0
ENV MARIADB_VERSION 10.0.15+maria-1~trusty
ENV MARIADB_VERSION 10.0.16+maria-1~trusty

# Set correct environment variables.
ENV HOME /root
Expand All @@ -24,25 +16,32 @@ CMD ["/sbin/my_init"]
RUN groupadd -r mysql && useradd -r -g mysql mysql

# Add MariaDB repository
RUN apt-key adv --recv-keys --keyserver hkp://keyserver.ubuntu.com:80 0xcbcb082a1bb943db
RUN echo "deb http://ftp.igh.cnrs.fr/pub/mariadb/repo/$MARIADB_MAJOR/ubuntu trusty main" > /etc/apt/sources.list.d/mariadb.list
RUN apt-key adv --recv-keys --keyserver hkp://keyserver.ubuntu.com:80 0xcbcb082a1bb943db \
&& echo "deb http://ftp.igh.cnrs.fr/pub/mariadb/repo/$MARIADB_MAJOR/ubuntu trusty main" > /etc/apt/sources.list.d/mariadb.list

# Install MariaDB and remove default db
# Install MariaDB , remove default db,
RUN apt-get -y update \
&& LC_ALL=C DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
mariadb-server=$MARIADB_VERSION \
&& rm -rf /var/lib/mysql \
&& mkdir /var/lib/mysql
&& mkdir /var/lib/mysql

# Expose MariaDB default port
EXPOSE 3306
# Add install script
ADD service/install.sh /tmp/install.sh

# Save this directory outside the container
VOLUME ["/var/lib/mysql"]
# Run install script and clean all
RUN ./tmp/install.sh && rm /tmp/install.sh \
&& apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*

# Add default env variables
ADD env.yml /etc/env.yml

# Add MariaDB container start config & daemon
ADD service/mariadb/container-start.sh /etc/my_init.d/mariadb
ADD service/mariadb/daemon.sh /etc/service/mariadb/run

# Clear out the local repository of retrieved package files
RUN apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
# Set MariaDB database directory in a data volume
VOLUME ["/var/lib/mysql"]

# Expose MariaDB default port
EXPOSE 3306
7 changes: 7 additions & 0 deletions image/env.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
ROOT_USER: admin
ROOT_PWD: admin

ROOT_ALLOWED_NETWORKS:
- localhost
- 127.0.0.1
- ::1
10 changes: 10 additions & 0 deletions image/service/install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/bash -e
# this script is run during the image build

# MariaDB config

# Allow remote connection
sed -ri 's/^(bind-address|skip-networking)/;\1/' /etc/mysql/my.cnf

# Disable local files loading
sed -i '/\[mysqld\]/a\local-infile=0' /etc/mysql/my.cnf
137 changes: 68 additions & 69 deletions image/service/mariadb/container-start.sh
Original file line number Diff line number Diff line change
@@ -1,88 +1,87 @@
#!/bin/bash
#!/bin/bash -e

# fix permissions and ownership of /var/lib/mysql
chown -R mysql:mysql /var/lib/mysql
chmod 700 /var/lib/mysql
FIRST_START_DONE="/etc/docker-mariadb-first-start-done"

# config sql queries
TEMP_FILE='/tmp/mysql-start.sql'
# container first start
if [ ! -e "$FIRST_START_DONE" ]; then

# The password for 'debian-sys-maint'@'localhost' is auto generated.
# The database inside of DATA_DIR may not have been generated with this password.
# So, we need to set this for our database to be portable.
# https://github.com/Painted-Fox/docker-mariadb/blob/master/scripts/first_run.sh
DB_MAINT_PASS=$(cat /etc/mysql/debian.cnf | grep -m 1 "password\s*=\s*"| sed 's/^password\s*=\s*//')
# fix permissions and ownership of /var/lib/mysql
chown -R mysql:mysql /var/lib/mysql
chmod 700 /var/lib/mysql

# database is uninitialized
if [ -z "$(ls -A /var/lib/mysql)" ]; then
# config sql queries
TEMP_FILE='/tmp/mysql-start.sql'

# Initializes the MySQL data directory and creates the system tables that it contains
mysql_install_db --datadir=/var/lib/mysql
# The password for 'debian-sys-maint'@'localhost' is auto generated.
# The database inside of DATA_DIR may not have been generated with this password.
# So, we need to set this for our database to be portable.
# https://github.com/Painted-Fox/docker-mariadb/blob/master/scripts/first_run.sh
DB_MAINT_PASS=$(cat /etc/mysql/debian.cnf | grep -m 1 "password\s*=\s*"| sed 's/^password\s*=\s*//')

# allow remote connection
sed -ri 's/^(bind-address|skip-networking)/;\1/' /etc/mysql/my.cnf
# database is uninitialized
if [ -z "$(ls -A /var/lib/mysql)" ]; then

# Disable local files loading
sed -i '/\[mysqld\]/a\local-infile=0' /etc/mysql/my.cnf
# initializes the MySQL data directory and creates the system tables that it contains
mysql_install_db --datadir=/var/lib/mysql

# Start MariaDB
service mysql start || true
# start MariaDB
service mysql start || true

# drop all user and test database
cat > "$TEMP_FILE" <<-EOSQL
DELETE FROM mysql.user ;
DROP DATABASE IF EXISTS test ;
# drop all user and test database
cat > "$TEMP_FILE" <<-EOSQL
DELETE FROM mysql.user ;
DROP DATABASE IF EXISTS test ;
EOSQL

# add root user on specified networks
IFS=', ' read -a networks <<< "$ROOT_ALLOWED_NETWORKS"
for network in "${networks[@]}"
do
echo "CREATE USER '$ROOT_USER'@'$network' IDENTIFIED BY '$ROOT_PWD' ;" >> "$TEMP_FILE"
echo "GRANT ALL ON *.* TO '$ROOT_USER'@'$network' WITH GRANT OPTION ;" >> "$TEMP_FILE"
done

echo "CREATE USER 'debian-sys-maint'@'localhost' IDENTIFIED BY '$DB_MAINT_PASS' ;" >> "$TEMP_FILE"
echo "GRANT ALL PRIVILEGES ON *.* TO 'debian-sys-maint'@'localhost' IDENTIFIED BY '$DB_MAINT_PASS' ;" >> "$TEMP_FILE"

# Flush privileges
echo 'FLUSH PRIVILEGES ;' >> "$TEMP_FILE"

# execute config queries
mysql -u root < $TEMP_FILE

# prevent socket error on stop
sleep 1

# Stop MariaDB
service mysql stop

# database is initialized
else

# Start MariaDB
service mysql start || true

# drop all user and test database
cat > "$TEMP_FILE" <<-EOSQL
DELETE FROM mysql.user where user = 'debian-sys-maint' ;
FLUSH PRIVILEGES ;
CREATE USER 'debian-sys-maint'@'localhost' IDENTIFIED BY '$DB_MAINT_PASS' ;
GRANT ALL PRIVILEGES ON *.* TO 'debian-sys-maint'@'localhost' IDENTIFIED BY '$DB_MAINT_PASS' ;
FLUSH PRIVILEGES ;
# add root user on specified networks
ROOT_ALLOWED_NETWORKS=($ROOT_ALLOWED_NETWORKS)
for network in "${ROOT_ALLOWED_NETWORKS[@]}"
do
echo "GRANT ALL PRIVILEGES ON *.* TO '$ROOT_USER'@'${!network}' IDENTIFIED BY '$ROOT_PWD' WITH GRANT OPTION ;" >> "$TEMP_FILE"
done

echo "GRANT ALL PRIVILEGES ON *.* TO 'debian-sys-maint'@'localhost' IDENTIFIED BY '$DB_MAINT_PASS' ;" >> "$TEMP_FILE"

# flush privileges
echo 'FLUSH PRIVILEGES ;' >> "$TEMP_FILE"

# execute config queries
mysql -u root < $TEMP_FILE

# prevent socket error on stop
sleep 1

# Stop MariaDB
service mysql stop

# database is initialized
else

# start MariaDB
service mysql start || true

# drop all user and test database
cat > "$TEMP_FILE" <<-EOSQL
DELETE FROM mysql.user where user = 'debian-sys-maint' ;
FLUSH PRIVILEGES ;
GRANT ALL PRIVILEGES ON *.* TO 'debian-sys-maint'@'localhost' IDENTIFIED BY '$DB_MAINT_PASS' ;
FLUSH PRIVILEGES ;
EOSQL

# execute config queries
mysql -u $ROOT_USER -p$ROOT_PWD < $TEMP_FILE
# execute config queries
mysql -u $ROOT_USER -p$ROOT_PWD < $TEMP_FILE

# prevent socket error on stop
sleep 1
# prevent socket error on stop
sleep 1

# Stop MariaDB
service mysql stop
# stop MariaDB
service mysql stop

fi
fi

rm $TEMP_FILE
rm $TEMP_FILE

touch $FIRST_START_DONE
fi

exit 0
8 changes: 2 additions & 6 deletions image/service/mariadb/daemon.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,2 @@
#!/bin/bash

# Exit immediately if a command exits with a non-zero status.
set -e

exec /usr/bin/mysqld_safe
#!/bin/bash -e
exec /usr/bin/mysqld_safe
Binary file modified test/database/aria_log.00000001
Binary file not shown.
Binary file modified test/database/aria_log_control
Binary file not shown.
Binary file modified test/database/ib_logfile0
Binary file not shown.
Binary file modified test/database/ibdata1
Binary file not shown.
Binary file modified test/database/mysql/columns_priv.MYI
Binary file not shown.
Binary file modified test/database/mysql/columns_priv.frm
Binary file not shown.
Binary file modified test/database/mysql/db.MYI
Binary file not shown.
Binary file modified test/database/mysql/db.frm
Binary file not shown.
Binary file modified test/database/mysql/event.MYI
Binary file not shown.
Binary file modified test/database/mysql/event.frm
Binary file not shown.
Binary file modified test/database/mysql/func.MYI
Binary file not shown.
Binary file modified test/database/mysql/func.frm
Binary file not shown.
Binary file modified test/database/mysql/help_category.frm
Binary file not shown.
Binary file modified test/database/mysql/help_topic.frm
Binary file not shown.
Binary file modified test/database/mysql/host.MYI
Binary file not shown.
Binary file modified test/database/mysql/host.frm
Binary file not shown.
Binary file modified test/database/mysql/innodb_index_stats.frm
Binary file not shown.
Binary file modified test/database/mysql/innodb_table_stats.frm
Binary file not shown.
Binary file modified test/database/mysql/plugin.MYI
Binary file not shown.
Binary file modified test/database/mysql/plugin.frm
Binary file not shown.
Binary file modified test/database/mysql/proc.MYI
Binary file not shown.
Binary file modified test/database/mysql/proc.frm
Binary file not shown.
Binary file modified test/database/mysql/procs_priv.MYI
Binary file not shown.
Binary file modified test/database/mysql/procs_priv.frm
Binary file not shown.
Binary file modified test/database/mysql/proxies_priv.MYI
Binary file not shown.
Binary file modified test/database/mysql/proxies_priv.frm
Binary file not shown.
Binary file modified test/database/mysql/servers.frm
Binary file not shown.
Binary file modified test/database/mysql/slow_log.frm
Binary file not shown.
Binary file modified test/database/mysql/tables_priv.MYI
Binary file not shown.
Binary file modified test/database/mysql/tables_priv.frm
Binary file not shown.
Binary file modified test/database/mysql/user.MYD
Binary file not shown.
Binary file modified test/database/mysql/user.MYI
Binary file not shown.
Binary file modified test/database/mysql/user.frm
Binary file not shown.
1 change: 1 addition & 0 deletions test/database/mysql_upgrade_info
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
10.0.15-MariaDB
Binary file removed test/database/performance_schema/accounts.frm
Binary file not shown.
Binary file modified test/database/performance_schema/cond_instances.frm
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified test/database/performance_schema/events_waits_current.frm
Binary file not shown.
Binary file modified test/database/performance_schema/events_waits_history.frm
Binary file not shown.
Binary file modified test/database/performance_schema/events_waits_history_long.frm
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified test/database/performance_schema/file_instances.frm
Binary file not shown.
Binary file modified test/database/performance_schema/file_summary_by_event_name.frm
Binary file not shown.
Binary file modified test/database/performance_schema/file_summary_by_instance.frm
Binary file not shown.
Binary file modified test/database/performance_schema/host_cache.frm
Binary file not shown.
Binary file removed test/database/performance_schema/hosts.frm
Binary file not shown.
Binary file modified test/database/performance_schema/mutex_instances.frm
Binary file not shown.
Binary file not shown.
Binary file modified test/database/performance_schema/performance_timers.frm
Binary file not shown.
Binary file modified test/database/performance_schema/rwlock_instances.frm
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified test/database/performance_schema/setup_actors.frm
Binary file not shown.
Binary file modified test/database/performance_schema/setup_consumers.frm
Binary file not shown.
Binary file modified test/database/performance_schema/setup_instruments.frm
Binary file not shown.
Binary file modified test/database/performance_schema/setup_objects.frm
Binary file not shown.
Binary file modified test/database/performance_schema/setup_timers.frm
Binary file not shown.
Binary file modified test/database/performance_schema/socket_instances.frm
Binary file not shown.
Binary file not shown.
Binary file modified test/database/performance_schema/socket_summary_by_instance.frm
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file removed test/database/performance_schema/threads.frm
Binary file not shown.
Binary file removed test/database/performance_schema/users.frm
Binary file not shown.
Loading

0 comments on commit 5cadf1d

Please sign in to comment.