From aca5e6e10da46734ee166ff1840a487b3d4e8254 Mon Sep 17 00:00:00 2001 From: Valentin Lab Date: Mon, 30 Nov 2020 13:51:25 +0100 Subject: [PATCH] new: [mariadb] upgrade to ``10.3.25``. Signed-off-by: Valentin Lab --- mariadb/build/Dockerfile | 19 +++++++++++++ mariadb/build/src/entrypoint.sh | 20 ++++++++++++++ mariadb/hooks/init | 48 ++++++++++++++++----------------- mariadb/metadata.yml | 2 -- 4 files changed, 62 insertions(+), 27 deletions(-) create mode 100644 mariadb/build/Dockerfile create mode 100755 mariadb/build/src/entrypoint.sh diff --git a/mariadb/build/Dockerfile b/mariadb/build/Dockerfile new file mode 100644 index 00000000..5d957d44 --- /dev/null +++ b/mariadb/build/Dockerfile @@ -0,0 +1,19 @@ +FROM alpine:3.9 + +RUN apk add --no-cache mariadb mariadb-client mariadb-server-utils && \ + rm -f /var/cache/apk/* + +## Required by mysql-backup +RUN apk add --no-cache bash gzip && \ + rm -f /var/cache/apk/* + +RUN mkdir -p /run/mysqld && \ + chown -R mysql:mysql /run/mysqld + +RUN sed -i "s|.*bind-address\s*=.*|bind-address=0.0.0.0|g" /etc/my.cnf.d/mariadb-server.cnf + +COPY src/ / + +EXPOSE 3306 + +ENTRYPOINT ["/entrypoint.sh"] diff --git a/mariadb/build/src/entrypoint.sh b/mariadb/build/src/entrypoint.sh new file mode 100755 index 00000000..ae31f706 --- /dev/null +++ b/mariadb/build/src/entrypoint.sh @@ -0,0 +1,20 @@ +#!/bin/sh + + + +if ! [ -d /var/lib/mysql/mysql ]; then + chown -R mysql:mysql /var/lib/mysql + mysql_install_db --user=mysql --ldata=/var/lib/mysql > /dev/null +fi + + + +## Support of Ctrl-C: see https://github.com/docker-library/mysql/issues/47 +run() { + "$@" & + pid="$!" + trap "kill -SIGQUIT $pid" INT TERM + wait +} + +run mysqld --user=mysql --skip-name-resolve --skip-networking=0 "$@" \ No newline at end of file diff --git a/mariadb/hooks/init b/mariadb/hooks/init index 2e8a84c2..2c64b8dc 100755 --- a/mariadb/hooks/init +++ b/mariadb/hooks/init @@ -25,31 +25,7 @@ fi if ! [ -d "$HOST_DATASTORE/${SERVICE_NAME}$DB_DATADIR" ]; then MYSQL_ROOT_PASSWORD="$(gen_password)" - - debug docker run -e "MYSQL_ROOT_PASSWORD=$MYSQL_ROOT_PASSWORD" \ - --rm \ - -v "$DATA_DIR:$DB_DATADIR" \ - --entrypoint /bin/bash "$DOCKER_BASE_IMAGE" - docker run -e "MYSQL_ROOT_PASSWORD=$MYSQL_ROOT_PASSWORD" \ - --rm \ - -v "$DATA_DIR:$DB_DATADIR" \ - --entrypoint /bin/bash "$DOCKER_BASE_IMAGE" -c ' - mysqld() { - echo "diverted mysqld call..." >&2; - echo "$*" | grep -E "(--help|--skip-networking)" >/dev/null 2>&1 || return; - echo " .. Allowing call." >&2; - /usr/sbin/mysqld "$@"; - } - export -f mysqld; - /docker-entrypoint.sh mysqld' || true - ## docker errorlevel is still 0 even if it failed. - ## AND we must ignore mysqld error ! - [ "$(find "$DATA_DIR" \ - -maxdepth 0 -type d -empty 2>/dev/null)" ] && { - err "Docker run probably failed to do it's job." - exit 1 - } - + mkdir -p "${HOST_DB_PASSFILE%/*}" ## XXXvlab: this won't help support multiple project running on the ## same host cat < "$HOST_DB_PASSFILE" @@ -57,5 +33,27 @@ if ! [ -d "$HOST_DATASTORE/${SERVICE_NAME}$DB_DATADIR" ]; then password=$MYSQL_ROOT_PASSWORD EOF chmod 600 "$HOST_DB_PASSFILE" + + ## deactivating final connection check + ddb () { true; } + export -f ddb + ensure_db_docker_running || exit 1 + + docker exec -i "$_DB_NAME" mysql <&1 >/dev/null) || { + err "Docker run probably failed to do it's job." + echo "$err" | prefix " " >&2 + exit 1 + } + info "New root password for mysql. " fi \ No newline at end of file diff --git a/mariadb/metadata.yml b/mariadb/metadata.yml index 3c742ee1..24c018e4 100644 --- a/mariadb/metadata.yml +++ b/mariadb/metadata.yml @@ -1,6 +1,4 @@ name: MariaDB -## From: mysql Ver 15.1 Distrib 10.0.21-MariaDB -docker-image: docker.0k.io/mariadb:1.0.0 maintainer: "Valentin Lab " provides: mysql-database: