commit ade02c14a9a5fb22525b1478af28d4f1fe3bd8c5 Author: Arnaud G. GIBERT Date: Tue Aug 27 23:32:27 2024 +0200 - Initial release, - Based on server-mga9:1.1.1 image. diff --git a/.env b/.env new file mode 100644 index 0000000..e529000 --- /dev/null +++ b/.env @@ -0,0 +1,36 @@ +# Rx3 MariaDB Mageia-9 Docker Image +#------------------------------------------------------------------------------- + +#------------------------------------------------------------------------------- +# Global Settings +#------------------------------------------------------------------------------- + +IMG_ORG="rx3" +IMG_REGISTRY="docker.xor.rx3:5000" +IMG_URL_PREFIX="${IMG_REGISTRY}/${IMG_ORG}" + + + +#------------------------------------------------------------------------------- +# Image Settings +#------------------------------------------------------------------------------- + +IMG_NAME="mariadb-mga9" +IMG_FULL_NAME="Rx3 MariaDB Mageia-9 Docker Image" +IMG_VERSION="1.0.0" +IMG_URL="${IMG_URL_PREFIX}/${IMG_NAME}:${IMG_VERSION}" +IMG_MAINTAINER='"Arnaud G. GIBERT" ' + + + +#------------------------------------------------------------------------------- +# User Settings +#------------------------------------------------------------------------------- + +MARIADB_UID=983 +MARIADB_GID=981 +MARIADB_ROOT_HOST= '%' # needs to be enclosed with quotes +MARIADB_ROOT_PASSWORD="mysqladmin" +MARIADB_DATABASE="test" +MARIADB_USER="test" +MARIADB_PASSWORD="testadmin" diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..556bc65 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +*~ +*.old diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..ffe1c67 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,110 @@ +# Rx3 MariaDB Mageia-9 Docker Image +#------------------------------------------------------------------------------- + +ARG IMG_URL_PREFIX="rx3" + +FROM ${IMG_URL_PREFIX}/server-mga9:1.1.1 + +ARG IMG_NAME +ARG IMG_FULL_NAME +ARG IMG_VERSION +ARG IMG_MAINTAINER + +LABEL org.rx3.${IMG_NAME}.name=${IMG_FULL_NAME} +LABEL org.rx3.${IMG_NAME}.version=${IMG_VERSION} +LABEL org.rx3.${IMG_NAME}.maintainer=${IMG_MAINTAINER} +LABEL maintainer=${IMG_MAINTAINER} + + + +#--------------------------------------------------------------------------------------------------- +ARG MYSQLD='#!/bin/bash \n\ + \n\ +usermod -u ${MARIADB_UID} mysql \n\ +groupmod -g ${MARIADB_GID} mysql \n\ + \n\ +chown -R mysql:mysql /var/log/mysqld /var/run/mysqld \n\ + \n\ +sed -i -e "s/^skip-networking/#skip-networking/" /etc/my.cnf.d/server.cnf \n\ +sed -i -e "s/^plugin-load-add=/#plugin-load-add=/" /etc/my.cnf.d/cracklib_password_check.cnf \n\ + \n\ +echo "CREATE USER `root`@`${MARIADB_ROOT_HOST}` IDENTIFIED BY `${MARIADB_ROOT_PASSWORD}`; \n\ + GRANT ALL ON *.* TO `root`@`${MARIADB_ROOT_HOST}` WITH GRANT OPTION; \n\ + GRANT PROXY ON ``@`%` TO `root`@`${MARIADB_ROOT_HOST}` WITH GRANT OPTION;" >>/tmp/post.sql \n\ + \n\ +if [[ -n "${MARIADB_DATABASE}" ]] \n\ +then \n\ + echo "CREATE DATABASE IF NOT EXISTS $MARIADB_DATABASE;" >>/tmp/post.sql \n\ +fi \n\ + \n\ +if [[ -n "${MARIADB_USER}" ]] && [[ -n "${MARIADB_PASSWORD}" ]] \n\ +then \n\ + echo "CREATE USER `${MARIADB_USER}`@`%` IDENTIFIED BY `${MARIADB_PASSWORD}`;">>/tmp/post.sql \n\ + \n\ + if [[ -n "${MARIADB_DATABASE}" ]] \n\ + then \n\ + echo "GRANT ALL ON ${MARIADB_DATABASE}.* TO `${MARIADB_USER}`@`%`;" >>/tmp/post.sql \n\ + fi \n\ +fi \n\ + \n\ + \n\ +/usr/sbin/mysqld-prepare-db-dir' +#--------------------------------------------------------------------------------------------------- + +#--------------------------------------------------------------------------------------------------- +ARG MYSQLD_INI='[program:mysqld] \n\ +command=/usr/sbin/mysqld' +#--------------------------------------------------------------------------------------------------- + +#--------------------------------------------------------------------------------------------------- +ARG POSTSQL='#!/bin/bash \n\ + \n\ +function log() { echo "$(date --rfc-3339=ns) PostSQL: $*" | tee -a /var/log/postsql.log; } \n\ + \n\ +log "Starting" \n\ + \n\ +for i in {30..0} \n\ +do \n\ + if mariadb <<< "SELECT 1" &> /dev/null \n\ + then \n\ + break \n\ + fi \n\ + \n\ + sleep 1 \n\ +done \n\ + \n\ +if [ "$i" = 0 ] \n\ +then \n\ + log "Unable to connect server" \n\ +else \n\ + while read line \n\ + do \n\ + log "Executing: [${line}]" \n\ + echo ${line} | mariadb mysql \n\ + done < /tmp/post.sql \n\ +fi \n\ + \n\ +log "Completed"' +#--------------------------------------------------------------------------------------------------- + +#--------------------------------------------------------------------------------------------------- +ARG POSTSQL_INI='[program:postsql] \n\ +command=/usr/local/sbin/postsql' +#--------------------------------------------------------------------------------------------------- + + + +RUN urpmi --force mariadb \ + && echo -e "${MYSQLD}" | sed -e "s/\`/'/g" -e 's/ *$//' > /etc/init.d/mysqld \ + && chmod a+x /etc/init.d/mysqld \ + && ln -s /etc/init.d/mysqld /etc/rcD.d/S30mysqld \ + && echo -e "${MYSQLD_INI}" | sed -e "s/\`/'/g" -e 's/ *$//' > /etc/supervisord.d/mysqld.ini \ + && echo -e "${POSTSQL}" | sed -e "s/\`/'/g" -e 's/ *$//' > /usr/local/sbin/postsql \ + && chmod a+x /usr/local/sbin/postsql \ + && echo -e "${POSTSQL_INI}" | sed -e 's/ *$//' > /etc/supervisord.d/postsql.ini + + + +VOLUME /var/lib/mysql + +EXPOSE 3306 diff --git a/ReadMe.txt b/ReadMe.txt new file mode 100644 index 0000000..3e34f40 --- /dev/null +++ b/ReadMe.txt @@ -0,0 +1,22 @@ +Welcome to Rx3/MariaDB-Mga9 docker image! + + + +This is project aims to build a MariaDB + Mageia 9 docker image used by others Rx3 packaging projects. + +Features: + - Curtently based on rx3/server-mga9:1.1.1 image, + - Following env vars supported: + - MARIADB_UID & MARIADB_GID, + - MARIADB_ROOT_HOST & MARIADB_ROOT_PASSWORD, + - MARIADB_DATABASE, + - MARIADB_USER & MARIADB_PASSWORD. + + +Enjoy it! + +Your Rx3 Team. + +-- +arnaud@rx3.net +https://git.rx3.org/gitea/rx3/mariadb-mga9 diff --git a/ReleaseNotes.txt b/ReleaseNotes.txt new file mode 100644 index 0000000..74e0294 --- /dev/null +++ b/ReleaseNotes.txt @@ -0,0 +1,6 @@ +------------------------------------------------------------------------------------------------------------------------------------ +Rx3/MariaDB-Mga9 V 1.0.0 - A. GIBERT - 2024/08/27 +------------------------------------------------------------------------------------------------------------------------------------ + +- Initial release, +- Based on server-mga9:1.1.1 image. diff --git a/compose.yaml b/compose.yaml new file mode 100644 index 0000000..5fa3f18 --- /dev/null +++ b/compose.yaml @@ -0,0 +1,40 @@ +# Rx3 MariaDB Mageia-9 Docker Image +#------------------------------------------------------------------------------- + +name: ${IMG_NAME} + +services: + + database: + container_name: ${IMG_NAME} + + image: ${IMG_URL} + + build: + context: . + args: + - IMG_NAME=${IMG_NAME} + - IMG_FULL_NAME=${IMG_FULL_NAME} + - IMG_VERSION=${IMG_VERSION} + - IMG_MAINTAINER=${IMG_MAINTAINER} + - IMG_URL_PREFIX=${IMG_URL_PREFIX} + + restart: unless-stopped + + environment: + MARIADB_UID: ${MARIADB_UID} + MARIADB_GID: ${MARIADB_GID} + MARIADB_ROOT_HOST: ${MARIADB_ROOT_HOST} + MARIADB_ROOT_PASSWORD: ${MARIADB_ROOT_PASSWORD} + MARIADB_DATABASE: ${MARIADB_DATABASE} + MARIADB_USER: ${MARIADB_USER} + MARIADB_PASSWORD: ${MARIADB_PASSWORD} + + volumes: + - ./mysql:/var/lib/mysql + + network_mode: bridge + + ports: + - "127.0.0.1:9012:9001" + - "127.0.0.1:8006:3306"