diff --git a/Dockerfile b/Dockerfile index ece6ddd..84ef71a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -20,7 +20,8 @@ RUN yum -y install --setopt=tsflags=nodocs mariadb-server bind-utils pwgen psmis # Add starters and installers ADD ./container_files /opt - +RUN rm -rf /etc/my.cnf +COPY ./conf/my.cnf /etc # Add Volumes and Set permissions RUN mkdir /opt/shared && chmod 777 /opt/shared && chmod 777 /opt/bin/*.sh diff --git a/conf/my.cnf b/conf/my.cnf new file mode 100644 index 0000000..ab171a5 --- /dev/null +++ b/conf/my.cnf @@ -0,0 +1,45 @@ +# +# These groups are read by MariaDB server. +# Use it for options that only the server (but not clients) should see +# +# See the examples of server my.cnf files in /usr/share/mysql/ +# + +# this is read by the standalone daemon and embedded servers +[server] + +# this is only for the mysqld standalone daemon +[mysqld] +skip-character-set-client-handshake +datadir=/var/lib/mysqlmounted +socket=/var/lib/mysql/mysql.sock +character-set-server=utf8 +#default-character-set=utf8 +collation-server=utf8_bin +#collation-server=utf8_general_ci +init-connect='SET NAMES utf8' +log-error=/var/log/mariadb/mariadb.log +pid-file=/var/run/mariadb/mariadb.pid +# this is only for embedded server +[embedded] + +# This group is only read by MariaDB-5.5 servers. +# If you use the same .cnf file for MariaDB of different versions, +# use this group for options that older servers don't understand +[mysqld-5.5] + +# These two groups are only read by MariaDB servers, not by MySQL. +# If you use the same .cnf file for MySQL and MariaDB, +# you can put MariaDB-only options here +[mariadb] +collation-server = utf8_bin +#collation-server = utf8_general_ci +init-connect='SET NAMES utf8' +#default-character-set = utf8 +character-set-server = utf8 +[mariadb-5.5] +collation-server = utf8_bin +#collation-server = utf8_general_ci +init-connect='SET NAMES utf8' +#default-character-set = utf8 +character-set-server = utf8 diff --git a/container_files/bin/start.sh b/container_files/bin/start.sh index e419b31..9d86e91 100755 --- a/container_files/bin/start.sh +++ b/container_files/bin/start.sh @@ -28,7 +28,7 @@ if [ -e "/tmp/firsttimerunning" ]; then fi echo 'Running mysql_install_db ...' >> $log - mysql_install_db --datadir="$MYSQL_DATADIR" >> $log + mysql_install_db --defaults-file=/etc/my.cnf --datadir="$MYSQL_DATADIR" >> $log echo 'Finished mysql_install_db' >> $log # These statements _must_ be on individual lines, and _must_ end with @@ -59,7 +59,7 @@ if [ -e "/tmp/firsttimerunning" ]; then # [jvf] mysqld_safe unknown option '--character-set-server=utf8' [FIXME] #echo "character-set-server = utf8" >> /etc/my.cnf #echo "collation-server = utf8_unicode_ci" >> /etc/my.cnf - echo "" >> /etc/my.cnf + #echo "" >> /etc/my.cnf echo "Fixing Permissions" >> $log chown -R mysql:mysql $MYSQL_DATADIR diff --git a/tests/image.bats b/tests/image.bats index 5918a29..85490ac 100644 --- a/tests/image.bats +++ b/tests/image.bats @@ -9,3 +9,8 @@ load ../common @test "MariaDB service available" { docker run -i $maintainer/$imagename find /usr/lib/systemd/system/mariadb.service } + +@test "MariaDB first run consumes tmpfile" { + result="$(docker run -i $maintainer/$imagename find /tmp/firsttimerunning)" + [ "$result" != '' ] +} diff --git a/tests/running.bats b/tests/running.bats index 1d5c5d9..ddb663d 100644 --- a/tests/running.bats +++ b/tests/running.bats @@ -19,3 +19,15 @@ load ../common @test "Creates user account with password" { docker exec -i $imagename mysql -u registry_user --password="WJzesbe3poNZ91qIbmR7" -h 127.0.0.1 -e 'show tables' registry } + +@test "UTF8 character set" { + docker exec -i $imagename mysql -u root -h 127.0.0.1 --password=123321 -e 'show variables' | grep char | grep utf8 +} + +@test "UTF8 collations" { + docker exec -i $imagename mysql -u root -h 127.0.0.1 --password=123321 -e 'show variables' | grep collation | grep utf8_bin +} + +@test "UTF8 databases" { + docker exec -i $imagename mysql -u root -h 127.0.0.1 --password=123321 -e 'show create database registry' | grep "DEFAULT CHARACTER SET utf8 COLLATE utf8_bin" +} \ No newline at end of file