Browse Source

new: [mariadb] upgrade to ``10.3.25``.

Signed-off-by: Valentin Lab <valentin.lab@kalysto.org>
dev
Valentin Lab 4 years ago
parent
commit
aca5e6e10d
  1. 19
      mariadb/build/Dockerfile
  2. 20
      mariadb/build/src/entrypoint.sh
  3. 48
      mariadb/hooks/init
  4. 2
      mariadb/metadata.yml

19
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"]

20
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 "$@"

48
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 <<EOF > "$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 <<EOF
USE mysql;
GRANT ALL ON *.* TO 'root'@'%' IDENTIFIED BY '$MYSQL_ROOT_PASSWORD' WITH GRANT OPTION;
GRANT ALL ON *.* TO 'root'@'localhost' IDENTIFIED BY '$MYSQL_ROOT_PASSWORD' WITH GRANT OPTION;
SET PASSWORD FOR 'root'@'localhost'=PASSWORD('${MYSQL_ROOT_PASSWORD}');
FLUSH PRIVILEGES;
EOF
. lib/common
err=$(echo "$check_command" | ddb 2>&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

2
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 <valentin.lab@kalysto.org>"
provides:
mysql-database:

Loading…
Cancel
Save