Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: docker/mariadb
base: master
Choose a base ref
...
head repository: docker/mariadb
compare: mariadb10.2
Choose a head ref
Able to merge. These branches can be automatically merged.
  • 19 commits
  • 8 files changed
  • 3 contributors

Commits on Aug 7, 2018

  1. mariaDB 10

    pcaskey committed Aug 7, 2018
    Copy the full SHA
    36e5f98 View commit details
  2. add missing file

    pcaskey committed Aug 7, 2018
    Copy the full SHA
    b093785 View commit details
  3. Update Jenkinsfile

    chubing committed Aug 7, 2018
    Copy the full SHA
    ef913e1 View commit details
  4. add net-tools pkg

    pcaskey committed Aug 7, 2018
    Copy the full SHA
    2cb616d View commit details
  5. Merge branch 'mariadb10' of https://github.internet2.edu/docker/mariadb

    … into mariadb10
    pcaskey committed Aug 7, 2018
    Copy the full SHA
    3c25a63 View commit details
  6. re-enable tests

    pcaskey committed Aug 7, 2018
    Copy the full SHA
    c74faae View commit details

Commits on Sep 26, 2018

  1. Add "if_needed" value for CREATE_NEW_DATABASE

    This value means that the database is created only if MYSQL_DATADIR
    does not exist or is empty.
    mederly committed Sep 26, 2018
    Copy the full SHA
    637acf8 View commit details
  2. Merge pull request #7 from mederly/mariadb10

    Add "if_needed" value for CREATE_NEW_DATABASE
    pcaskey committed Sep 26, 2018
    Copy the full SHA
    ae67e47 View commit details

Commits on Oct 12, 2018

  1. Add $AFTER_FIRST_TIME_SQL parameter

    It allows a user to add custom SQL commands to the file that is executed
    during database initialization. Useful e.g. to provide some initial
    content.
    
    Also fixed hardwired directory in my.cnf.
    And a minor start.sh code cleanup.
    mederly committed Oct 12, 2018
    Copy the full SHA
    ea13d8e View commit details
  2. Merge pull request #8 from mederly/mariadb10

    Add $AFTER_FIRST_TIME_SQL parameter
    pcaskey committed Oct 12, 2018
    Copy the full SHA
    4f5bc40 View commit details
  3. Copy the full SHA
    8798551 View commit details
  4. Merge pull request #9 from mederly/mariadb10

    Add diagnostic output for failing tests
    pcaskey committed Oct 12, 2018
    Copy the full SHA
    9efd4c3 View commit details
  5. Add yet more diagnostics...

    mederly committed Oct 12, 2018
    Copy the full SHA
    d326dd9 View commit details

Commits on Oct 13, 2018

  1. Merge pull request #10 from mederly/mariadb10

    Add yet more diagnostics...
    pcaskey committed Oct 13, 2018
    Copy the full SHA
    5f35041 View commit details
  2. Copy the full SHA
    d6783ca View commit details
  3. Merge pull request #11 from mederly/mariadb10

    Attempt to fix the build (wrong charset)
    pcaskey committed Oct 13, 2018
    Copy the full SHA
    ea079a4 View commit details

Commits on Dec 17, 2020

  1. Update mariadb.repo

    pcaskey committed Dec 17, 2020
    Copy the full SHA
    91baec7 View commit details
  2. Update Dockerfile

    pcaskey committed Dec 17, 2020
    Copy the full SHA
    386c121 View commit details
  3. Update Jenkinsfile

    pcaskey committed Dec 17, 2020
    Copy the full SHA
    cb75afb View commit details
Showing with 50 additions and 33 deletions.
  1. +9 −4 Dockerfile
  2. +5 −2 Jenkinsfile
  3. +6 −0 conf/mariadb.repo
  4. +1 −1 conf/my.cnf
  5. +8 −0 container_files/bin/fix-all-permissions.sh
  6. +2 −11 container_files/bin/fix-permissions.sh
  7. +16 −14 container_files/bin/start.sh
  8. +3 −1 tests/running.bats
13 changes: 9 additions & 4 deletions Dockerfile
@@ -1,10 +1,10 @@
FROM tier/centos7base
FROM centos:centos7

# Define args and set a default value
ARG registry=docker.io
ARG maintainer=tier
ARG imagename=mariadb
ARG version=5.5
ARG version=10.2

MAINTAINER $maintainer
LABEL Vendor="Internet2"
@@ -15,15 +15,20 @@ LABEL Version=$version

LABEL Build docker build --rm --tag $registry/$maintainer/$imagename .

#copy MariaDB yum repo file
COPY ./conf/mariadb.repo /etc/yum.repos.d/

# Install base deps
RUN yum -y install --setopt=tsflags=nodocs mariadb-server bind-utils pwgen psmisc hostname vim
RUN yum -y install --setopt=tsflags=nodocs MariaDB-server bind-utils net-tools pwgen psmisc hostname vim

RUN yum -y update

# 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
RUN mkdir /opt/shared && chmod 777 /opt/shared && mkdir /var/log/mariadb && mkdir /var/run/mariadb && chmod 777 /opt/bin/*.sh && touch /tmp/firsttimerunning

# Place VOLUME statement below all changes to /var/lib/mysql
VOLUME /var/lib/mysql
7 changes: 5 additions & 2 deletions Jenkinsfile
@@ -10,9 +10,11 @@ node('docker') {
dir('tmp'){
git([ url: "https://github.internet2.edu/docker/util.git",
credentialsId: "jenkins-github-access-token" ])
sh 'rm -rf ../bin/*'
sh 'mv ./bin/* ../bin/.'
}

sh 'rm -rf tmp'

stage 'Setting build context'

def maintainer = maintainer()
@@ -53,6 +55,7 @@ node('docker') {
try{
sh 'bin/test.sh &> debug'
} catch(error) {
sh "docker logs $imagename &>> debug"
def error_details = readFile('./debug');
def message = "BUILD ERROR: There was a problem building ${imagename}:${tag}. \n\n ${error_details}"
sh "rm -f ./debug"
@@ -100,4 +103,4 @@ def handleError(String message){
slackSend color: 'danger', message: "${message}"
//step([$class: 'Mailer', notifyEveryUnstableBuild: true, recipients: 'chris.bynum@levvel.io', sendToIndividuals: true])
sh 'exit 1'
}
}
6 changes: 6 additions & 0 deletions conf/mariadb.repo
@@ -0,0 +1,6 @@
[mariadb]
name = MariaDB
baseurl = http://yum.mariadb.org/10.2/centos7-amd64
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck=1

2 changes: 1 addition & 1 deletion conf/my.cnf
@@ -11,7 +11,7 @@
# this is only for the mysqld standalone daemon
[mysqld]
skip-character-set-client-handshake
datadir=/var/lib/mysqlmounted
datadir=${MYSQL_DATADIR}
socket=/var/lib/mysql/mysql.sock
character-set-server=utf8
#default-character-set=utf8
8 changes: 8 additions & 0 deletions container_files/bin/fix-all-permissions.sh
@@ -0,0 +1,8 @@
#!/bin/bash

echo "Fixing Permissions"
chown -R mysql:mysql $MYSQL_DATADIR
/opt/bin/fix-permissions.sh $MYSQL_DATADIR
/opt/bin/fix-permissions.sh /var/log/mariadb/
/opt/bin/fix-permissions.sh /var/run/
echo "Done Fixing Permissions"
13 changes: 2 additions & 11 deletions container_files/bin/fix-permissions.sh
@@ -2,15 +2,6 @@

log="/tmp/permissions.log"

echo "Starting Container: " > $log
date >> $log
echo "" >> $log

# Taken from https://raw.githubusercontent.com/openshift/sti-base/master/bin/fix-permissions
# Fix permissions on the given directory to allow group read/write of
# regular files and execute of directories.
chgrp -R 0 $1 >> $log
chmod -R g+rw $1 >> $log
find $1 -type d -exec chmod g+x {} + >> $log

chmod -R 777 $1
find $1 -type d -exec chmod 777 {} + >> $log
exit 0
30 changes: 16 additions & 14 deletions container_files/bin/start.sh
@@ -16,8 +16,11 @@ if [ -e "/tmp/firsttimerunning" ]; then
fi

echo "Setting DataDir: $MYSQL_DATADIR" >> $log

if [ "$CREATE_NEW_DATABASE" == "1" ]; then
sed -e "s=\${MYSQL_DATADIR}=$MYSQL_DATADIR=" < /etc/my.cnf > /etc/my.cnf.new
rm /etc/my.cnf >> $log
mv /etc/my.cnf.new /etc/my.cnf >> $log

if [[ $CREATE_NEW_DATABASE == 1 || ($CREATE_NEW_DATABASE == if_needed && ( ! -d $MYSQL_DATADIR || -z $(ls -A $MYSQL_DATADIR) ) ) ]]; then

echo "Installing MariaDB" >> $log

@@ -26,15 +29,15 @@ if [ -e "/tmp/firsttimerunning" ]; then
echo >&2 ' Did you forget to add -e MYSQL_ROOT_PASSWORD=... ?' >> $log
exit 1
fi

echo 'Running mysql_install_db ...' >> $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
# semicolons (no line breaks or comments are permitted).
# TODO proper SQL escaping on ALL the things D:

tempSqlFile='/tmp/mysql-first-time.sql'
echo "DELETE FROM mysql.user ;" > $tempSqlFile
echo "CREATE USER 'root'@'%' IDENTIFIED BY '${MYSQL_ROOT_PASSWORD}' ;" >> $tempSqlFile
@@ -43,7 +46,6 @@ if [ -e "/tmp/firsttimerunning" ]; then
echo "GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' WITH GRANT OPTION;" >> $tempSqlFile
echo "DROP DATABASE IF EXISTS test ;" >> $tempSqlFile


if [ "$MYSQL_DATABASE" != "" ]; then
echo "flush privileges;" >> "$tempSqlFile"
echo "CREATE DATABASE IF NOT EXISTS \`$MYSQL_DATABASE\` ;" >> "$tempSqlFile"
@@ -54,23 +56,23 @@ if [ -e "/tmp/firsttimerunning" ]; then
echo "GRANT ALL ON $MYSQL_DATABASE.* TO '$MYSQL_USER'@'$MYSQL_DATABASE.%_i2network' IDENTIFIED BY '$MYSQL_PASSWORD' ;" >> "$tempSqlFile"
echo "GRANT ALL ON $MYSQL_DATABASE.* TO '$MYSQL_USER'@'$MYSQL_DATABASE.%_i2network' IDENTIFIED BY '$MYSQL_PASSWORD' ;" >> "$tempSqlFile"
fi

echo 'FLUSH PRIVILEGES ;' >> "$tempSqlFile"
# [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 "Fixing Permissions" >> $log
chown -R mysql:mysql $MYSQL_DATADIR
/opt/bin/fix-permissions.sh $MYSQL_DATADIR >> $log
/opt/bin/fix-permissions.sh /var/log/mariadb/ >> $log
/opt/bin/fix-permissions.sh /var/run/ >> $log
echo "Done Fixing Permissions" >> $log

if [ -e "$AFTER_FIRST_TIME_SQL" ]; then
cat $AFTER_FIRST_TIME_SQL >> $tempSqlFile
fi

/opt/bin/fix-all-permissions.sh >> $log
rm -f /tmp/firsttimerunning
/usr/bin/mysqld_safe --init-file="$tempSqlFile" --datadir="$MYSQL_DATADIR"
else
echo "Not Creating a MariaDB - Using Existing from DataDir: $MYSQL_DATADIR" >> $log
/opt/bin/fix-all-permissions.sh >> $log
rm -f /tmp/firsttimerunning
/usr/bin/mysqld_safe --datadir="$MYSQL_DATADIR"
fi
4 changes: 3 additions & 1 deletion tests/running.bats
@@ -25,9 +25,11 @@ load ../common
}

@test "UTF8 collations" {
docker exec -i $imagename mysql -u root -h 127.0.0.1 --password=123321 -e 'show variables' | grep collation
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'
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"
}
}