diff --git a/example/images/mariadb/Dockerfile b/example/images/mariadb/Dockerfile deleted file mode 100644 index 5631915..0000000 --- a/example/images/mariadb/Dockerfile +++ /dev/null @@ -1,20 +0,0 @@ -FROM danielberteaud/mariadb-client:24.1-1 -MAINTAINER Daniel Berteaud - -ENV MYSQL_CONF_10_section=mysqld \ - MYSQL_CONF_11_innodb_buffer_pool_size=50% - -RUN set -eux &&\ - apk --no-cache upgrade &&\ - apk --no-cache add mariadb mariadb-server-utils &&\ - chown mysql:mysql /etc/my.cnf.d &&\ - rm -f /etc/my.cnf.d/* &&\ - mkdir /data /run/mysqld &&\ - chown mysql:mysql /data /run/mysqld &&\ - chmod 700 /data - -COPY root/ / - -EXPOSE 3306 -USER mysql -CMD ["mariadbd", "--console", "--skip-name-resolve"] diff --git a/example/images/mariadb/root/entrypoint.d/10-mariadb-conf.sh b/example/images/mariadb/root/entrypoint.d/10-mariadb-conf.sh deleted file mode 100755 index ded85d9..0000000 --- a/example/images/mariadb/root/entrypoint.d/10-mariadb-conf.sh +++ /dev/null @@ -1,44 +0,0 @@ -#!/bin/sh - -set -eo pipefail - -get_max_mem(){ - if [ -e /sys/fs/cgroup/memory.max ]; then - # Read /sys/fs/cgroup/memory.max - MAX=$(cat /sys/fs/cgroup/memory.max) - # If it's "max", then the container has no limit, and we must detect the available RAM - if [ "${MAX}" = "max" ]; then - echo $(($(cat /proc/meminfo | grep MemTotal | sed -E 's/MemTotal:\s+([0-9]+)\s+kB/\1/')/1024)) - else - echo $(($(cat /sys/fs/cgroup/memory.max)/1024/1024)) - fi - else - echo $(($(cat /proc/meminfo | grep MemTotal | sed -E 's/MemTotal:\s+([0-9]+)\s+kB/\1/')/1024)) - fi -} - -if mount | grep -q ' /etc/my.cnf '; then - echo "/etc/my.cnf is mounted, skiping config from env vars" -else - echo "Configuring from env vars" - for VAR in $(printenv | grep -E '^MYSQL_CONF_' | sed -E 's/MYSQL_CONF_([^=]+)=.*/\1/' | sort -V); do - DIRECTIVE=$(echo ${VAR} | sed -E 's/^[0-9]+_//') - VALUE=$(printenv MYSQL_CONF_${VAR}) - - if [ "${DIRECTIVE}" = "section" ]; then - echo "[${VALUE}]" >> /etc/my.cnf.d/env.cnf - else - - # Allow some memory related settings to be expressed as a % - if echo ${DIRECTIVE} | grep -q -E "^(innodb_buffer_pool_size)$"; then - if echo ${VALUE} | grep -q -E "[0-9]+%$"; then - PERCENT=$(echo $VALUE | sed -E 's|%$||') - MAX_MEM=$(get_max_mem) - VALUE=$((${MAX_MEM}*${PERCENT}/100))MB - fi - fi - echo "Adding ${DIRECTIVE} = ${VALUE} in /etc/my.cnf.d/env.cnf" - echo "${DIRECTIVE} = ${VALUE}" >> /etc/my.cnf.d/env.cnf - fi - done -fi diff --git a/example/images/mariadb/root/entrypoint.d/20-mariadb-init.sh b/example/images/mariadb/root/entrypoint.d/20-mariadb-init.sh deleted file mode 100755 index bc07a89..0000000 --- a/example/images/mariadb/root/entrypoint.d/20-mariadb-init.sh +++ /dev/null @@ -1,36 +0,0 @@ -#!/bin/sh - -set -euo pipefail - -mkdir -p /data/db - -if [ -d /data/db/mysql ]; then - echo "MariaDB is already initialized" -else - echo "Bootstraping MariaDB" - - mysql_install_db - - MYSQL_DATABASE=${MYSQL_DATABASE:-""} - MYSQL_USER=${MYSQL_USER:-""} - MYSQL_PASSWORD=${MYSQL_PASSWORD:-""} - - cat << EOF > /tmp/mariainit.sql -USE mysql; -FLUSH PRIVILEGES; -GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' identified by '$MYSQL_ROOT_PASSWORD' WITH GRANT OPTION; -GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' identified by '$MYSQL_ROOT_PASSWORD' WITH GRANT OPTION; -DROP DATABASE test; -EOF - if [ "$MYSQL_DATABASE" != "" ]; then - echo "CREATE DATABASE IF NOT EXISTS \`$MYSQL_DATABASE\` CHARACTER SET utf8 COLLATE utf8_general_ci;" - - if [ "$MYSQL_USER" != "" ]; then - echo "GRANT ALL ON \`$MYSQL_DATABASE\`.* to '$MYSQL_USER'@'%' IDENTIFIED BY '$MYSQL_PASSWORD';" - fi - fi - - mariadbd --bootstrap --verbose=0 --skip-name-resolve < /tmp/mariainit.sql - rm -f /tmp/mariainit.sql - -fi diff --git a/example/images/mariadb/root/etc/my.cnf b/example/images/mariadb/root/etc/my.cnf deleted file mode 100644 index b18587c..0000000 --- a/example/images/mariadb/root/etc/my.cnf +++ /dev/null @@ -1,13 +0,0 @@ - -[client-server] -port = 3306 -socket = /run/mysqld/mysqld.sock - -[mysqld] -pid-file = /tmp/mysql.pid -symbolic-links = 0 -datadir = /data/db -default_storage_engine = InnoDB -innodb_log_file_size = 512M - -!includedir /etc/my.cnf.d diff --git a/example/mariadb.nomad.hcl b/example/mariadb.nomad.hcl index 8d78296..91ee770 100644 --- a/example/mariadb.nomad.hcl +++ b/example/mariadb.nomad.hcl @@ -58,7 +58,7 @@ job "mariadb" { } config { - image = "danielberteaud/mariadb:24.1-2" + image = "danielberteaud/mariadb:24.1-5" pids_limit = 100 command = "/local/mysql_upgrade.sh" } @@ -127,7 +127,7 @@ _EOT kill_timeout = "5m" config { - image = "danielberteaud/mariadb:24.1-2" + image = "danielberteaud/mariadb:24.1-5" volumes = [ "secrets/:/etc/my.cnf.d", "secrets/my.conf:/var/lib/mysql/.my.cnf:ro", diff --git a/images/mariadb/Dockerfile b/images/mariadb/Dockerfile deleted file mode 100644 index b989e1a..0000000 --- a/images/mariadb/Dockerfile +++ /dev/null @@ -1,20 +0,0 @@ -FROM [[ .docker.repo ]][[ .docker.base_images.mariadb_client.image ]] -MAINTAINER [[ .docker.maintainer ]] - -ENV MYSQL_CONF_10_section=mysqld \ - MYSQL_CONF_11_innodb_buffer_pool_size=50% - -RUN set -eux &&\ - apk --no-cache upgrade &&\ - apk --no-cache add mariadb mariadb-server-utils &&\ - chown mysql:mysql /etc/my.cnf.d &&\ - rm -f /etc/my.cnf.d/* &&\ - mkdir /data /run/mysqld &&\ - chown mysql:mysql /data /run/mysqld &&\ - chmod 700 /data - -COPY root/ / - -EXPOSE 3306 -USER mysql -CMD ["mariadbd", "--console", "--skip-name-resolve"] diff --git a/images/mariadb/root/entrypoint.d/10-mariadb-conf.sh b/images/mariadb/root/entrypoint.d/10-mariadb-conf.sh deleted file mode 100755 index ded85d9..0000000 --- a/images/mariadb/root/entrypoint.d/10-mariadb-conf.sh +++ /dev/null @@ -1,44 +0,0 @@ -#!/bin/sh - -set -eo pipefail - -get_max_mem(){ - if [ -e /sys/fs/cgroup/memory.max ]; then - # Read /sys/fs/cgroup/memory.max - MAX=$(cat /sys/fs/cgroup/memory.max) - # If it's "max", then the container has no limit, and we must detect the available RAM - if [ "${MAX}" = "max" ]; then - echo $(($(cat /proc/meminfo | grep MemTotal | sed -E 's/MemTotal:\s+([0-9]+)\s+kB/\1/')/1024)) - else - echo $(($(cat /sys/fs/cgroup/memory.max)/1024/1024)) - fi - else - echo $(($(cat /proc/meminfo | grep MemTotal | sed -E 's/MemTotal:\s+([0-9]+)\s+kB/\1/')/1024)) - fi -} - -if mount | grep -q ' /etc/my.cnf '; then - echo "/etc/my.cnf is mounted, skiping config from env vars" -else - echo "Configuring from env vars" - for VAR in $(printenv | grep -E '^MYSQL_CONF_' | sed -E 's/MYSQL_CONF_([^=]+)=.*/\1/' | sort -V); do - DIRECTIVE=$(echo ${VAR} | sed -E 's/^[0-9]+_//') - VALUE=$(printenv MYSQL_CONF_${VAR}) - - if [ "${DIRECTIVE}" = "section" ]; then - echo "[${VALUE}]" >> /etc/my.cnf.d/env.cnf - else - - # Allow some memory related settings to be expressed as a % - if echo ${DIRECTIVE} | grep -q -E "^(innodb_buffer_pool_size)$"; then - if echo ${VALUE} | grep -q -E "[0-9]+%$"; then - PERCENT=$(echo $VALUE | sed -E 's|%$||') - MAX_MEM=$(get_max_mem) - VALUE=$((${MAX_MEM}*${PERCENT}/100))MB - fi - fi - echo "Adding ${DIRECTIVE} = ${VALUE} in /etc/my.cnf.d/env.cnf" - echo "${DIRECTIVE} = ${VALUE}" >> /etc/my.cnf.d/env.cnf - fi - done -fi diff --git a/images/mariadb/root/entrypoint.d/20-mariadb-init.sh b/images/mariadb/root/entrypoint.d/20-mariadb-init.sh deleted file mode 100755 index bc07a89..0000000 --- a/images/mariadb/root/entrypoint.d/20-mariadb-init.sh +++ /dev/null @@ -1,36 +0,0 @@ -#!/bin/sh - -set -euo pipefail - -mkdir -p /data/db - -if [ -d /data/db/mysql ]; then - echo "MariaDB is already initialized" -else - echo "Bootstraping MariaDB" - - mysql_install_db - - MYSQL_DATABASE=${MYSQL_DATABASE:-""} - MYSQL_USER=${MYSQL_USER:-""} - MYSQL_PASSWORD=${MYSQL_PASSWORD:-""} - - cat << EOF > /tmp/mariainit.sql -USE mysql; -FLUSH PRIVILEGES; -GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' identified by '$MYSQL_ROOT_PASSWORD' WITH GRANT OPTION; -GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' identified by '$MYSQL_ROOT_PASSWORD' WITH GRANT OPTION; -DROP DATABASE test; -EOF - if [ "$MYSQL_DATABASE" != "" ]; then - echo "CREATE DATABASE IF NOT EXISTS \`$MYSQL_DATABASE\` CHARACTER SET utf8 COLLATE utf8_general_ci;" - - if [ "$MYSQL_USER" != "" ]; then - echo "GRANT ALL ON \`$MYSQL_DATABASE\`.* to '$MYSQL_USER'@'%' IDENTIFIED BY '$MYSQL_PASSWORD';" - fi - fi - - mariadbd --bootstrap --verbose=0 --skip-name-resolve < /tmp/mariainit.sql - rm -f /tmp/mariainit.sql - -fi diff --git a/images/mariadb/root/etc/my.cnf b/images/mariadb/root/etc/my.cnf deleted file mode 100644 index b18587c..0000000 --- a/images/mariadb/root/etc/my.cnf +++ /dev/null @@ -1,13 +0,0 @@ - -[client-server] -port = 3306 -socket = /run/mysqld/mysqld.sock - -[mysqld] -pid-file = /tmp/mysql.pid -symbolic-links = 0 -datadir = /data/db -default_storage_engine = InnoDB -innodb_log_file_size = 512M - -!includedir /etc/my.cnf.d diff --git a/variables.yml b/variables.yml index 002c2c3..404bf37 100644 --- a/variables.yml +++ b/variables.yml @@ -9,7 +9,7 @@ mariadb: server: # The image to use - image: '[[ .docker.repo ]]mariadb:24.1-2' + image: '[[ .docker.repo ]][[ .docker.base_images.mariadb.image ]]' # Resource allocation resources: