diff --git a/Dockerfile b/Dockerfile index 223c58a..1316c0a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,20 +1,28 @@ -# Rx3 MariaDB Mageia-9 Docker Image +# Rx3-Docker/MariaDB Docker Image #------------------------------------------------------------------------------- -ARG IMG_URL_PREFIX="rx3" +ARG IMG_FROM_URL="rx3-docker/server:latest" -FROM ${IMG_URL_PREFIX}/server-mga9:1.1.3 +FROM ${IMG_FROM_URL} ARG IMG_NAME -ARG IMG_FULL_NAME +ARG IMG_NAME_FULL ARG IMG_VERSION ARG IMG_MAINTAINER -LABEL org.rx3.${IMG_NAME}.name=${IMG_FULL_NAME} +LABEL org.rx3.${IMG_NAME}.name=${IMG_NAME_FULL} LABEL org.rx3.${IMG_NAME}.version=${IMG_VERSION} LABEL org.rx3.${IMG_NAME}.maintainer=${IMG_MAINTAINER} LABEL maintainer=${IMG_MAINTAINER} +ARG MARIADDB_LIB +ARG MARIADDB_LOG +ARG MARIADDB_PORT +ARG POSTSQL_LOG + +ARG MARIADB_LOG_FILE="${MARIADDB_LOG}/mariadb.err" +ARG POSTSQL_LOG_FILE="${POSTSQL_LOG}/postsql.log" + #--------------------------------------------------------------------------------------------------- @@ -23,11 +31,14 @@ ARG MYSQLD='#!/bin/bash usermod -u ${MARIADB_UID} mysql \n\ groupmod -g ${MARIADB_GID} mysql \n\ \n\ -chown -R mysql:mysql /var/lib/mysql /var/log/mysqld /var/run/mysqld \n\ +chown -R mysql:mysql '${MARIADDB_LIB}' '${MARIADDB_LOG}' /var/run/mysqld \n\ \n\ -sed -i -e "s/^skip-networking/#skip-networking/" /etc/my.cnf.d/server.cnf \n\ +sed -i -e "s/^skip-networking/#skip-networking/" /etc/my.cnf.d/server.cnf \n\ +sed -i -e "s%hostname$%hostname\\n\\nlog_error='${MARIADB_LOG_FILE}'%" /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\ +rm -Rf /var/log/mysqld* \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\ @@ -59,7 +70,7 @@ 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\ +function log() { echo "$(date --rfc-3339=ns) PostSQL: $*" | tee -a '${POSTSQL_LOG_FILE}'; } \n\ \n\ log "Starting" \n\ \n\ @@ -105,6 +116,7 @@ RUN urpmi --force mariadb -VOLUME /var/lib/mysql +VOLUME ${MARIADDB_LIB} +VOLUME ${MARIADDB_LOG} -EXPOSE 3306 +EXPOSE ${MARIADDB_PORT} diff --git a/ReleaseNotes.txt b/ReleaseNotes.txt index 54451db..dce4b18 100644 --- a/ReleaseNotes.txt +++ b/ReleaseNotes.txt @@ -1,5 +1,18 @@ ------------------------------------------------------------------------------------------------------------------------------------ -Rx3/MariaDB-Mga9 V 1.0.2 - A. GIBERT - 2024/11/xx +Rx3-Docker/MariaDB-Mga9 V 1.0.2 - A. GIBERT - 2024/11/17 +------------------------------------------------------------------------------------------------------------------------------------ + +- Move & Rename repo from Rx3/MariaDB-MGA9 to Rx3-Docker/MariaDB, +- New version naming standard, +- Now use docker_tools for .env building, +- Now use docker_service_add macro, +- Use now rx3-docker/server:1.2.0-mga9 image, +- Add /var/log/init, /var/log/supervisor & var/log/mysql volumes. + + + +------------------------------------------------------------------------------------------------------------------------------------ +Rx3/MariaDB-Mga9 V 1.0.2 - A. GIBERT - 2024/11/05 ------------------------------------------------------------------------------------------------------------------------------------ - Add healthcheck example in compose file. diff --git a/compose.yaml b/compose.yaml index f359bbc..b2c8289 100644 --- a/compose.yaml +++ b/compose.yaml @@ -1,46 +1,54 @@ -# Rx3 MariaDB Mageia-9 Docker Image +# Rx3-Docker/MariaDB Docker Image #------------------------------------------------------------------------------- -name: ${IMG_NAME} +name: ${DATABASE_IMG_NAME} services: database: - container_name: ${IMG_NAME} + container_name: ${DATABASE_HOST} + hostname: ${DATABASE_HOST} - image: ${IMG_URL} + image: ${DATABASE_IMG_URL} build: - context: . + 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} + IMG_NAME: ${DATABASE_IMG_NAME} + IMG_NAME_FULL: ${DATABASE_IMG_NAME_FULL} + IMG_VERSION: ${DATABASE_IMG_VERSION} + IMG_MAINTAINER: ${DATABASE_IMG_MAINTAINER} + IMG_FROM_URL: ${DATABASE_IMG_FROM_URL} + + MARIADDB_LIB: ${DATABASE_LIB_INT} + MARIADDB_LOG: ${DATABASE_LOG_MAIN_INT} + MARIADDB_PORT: ${DATABASE_PORT_MAIN_INT} + POSTSQL_LOG: ${DATABASE_LOG_POST_INT} - restart: unless-stopped + 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} + MARIADB_UID: ${DATABASE_USER_ID} + MARIADB_GID: ${DATABASE_GROUP_ID} + + MARIADB_ROOT_HOST: ${MARIADB_ROOT_HOST} + MARIADB_ROOT_PASSWORD: ${MARIADB_ROOT_PASSWORD} + MARIADB_DATABASE: ${MARIADB_DATABASE} + MARIADB_USER: ${MARIADB_USER} + MARIADB_PASSWORD: ${MARIADB_PASSWORD} healthcheck: - test: ["CMD", 'mysqladmin', 'ping', '-h', 'localhost', '-u', 'root', '-p${MARIADB_ROOT_PASSWORD}' ] - interval: 10s - timeout: 3s - retries: 3 + test: ["CMD", 'mysqladmin', 'ping', '-h', 'localhost', '-u', 'root', '-p${MARIADB_ROOT_PASSWORD}' ] + interval: 10s + timeout: 3s + retries: 3 volumes: - - ./var/lib/mysql:/var/lib/mysql + - ./${DATABASE_LIB_EXT}:${DATABASE_LIB_INT} + - ./${DATABASE_LOG_INIT_EXT}:${DATABASE_LOG_INIT_INT} + - ./${DATABASE_LOG_SV_EXT}:${DATABASE_LOG_SV_INT} + - ./${DATABASE_LOG_MAIN_EXT}:${DATABASE_LOG_MAIN_INT} - network_mode: bridge - ports: - - "127.0.0.1:${DATABASE_SV_PORT}:9001" - - "127.0.0.1:${DATABASE_PORT}:3306" + - "127.0.0.1:${DATABASE_PORT_SV_EXT}:${DATABASE_PORT_SV_INT}" + - "127.0.0.1:${DATABASE_PORT_MAIN_EXT}:${DATABASE_PORT_MAIN_INT}" diff --git a/env b/env deleted file mode 100644 index 904af1f..0000000 --- a/env +++ /dev/null @@ -1,42 +0,0 @@ -# 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.2" -IMG_URL="${IMG_URL_PREFIX}/${IMG_NAME}:${IMG_VERSION}" -IMG_MAINTAINER='"Arnaud G. GIBERT" ' - - - -#------------------------------------------------------------------------------- -# User Settings -#------------------------------------------------------------------------------- - -ENV_PORT_OFFSET=0 -SV_PORT_OFFSET=1000 - -DATABASE_PORT=$(( 8006 + ${ENV_PORT_OFFSET})) -DATABASE_SV_PORT=$(( ${DATABASE_PORT} + ${SV_PORT_OFFSET})) - -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/env.dist b/env.dist new file mode 100644 index 0000000..e10f93e --- /dev/null +++ b/env.dist @@ -0,0 +1,40 @@ +# Rx3-Docker/MariaDB Docker Image +#------------------------------------------------------------------------------- + +#------------------------------------------------------------------------------- +# Global Settings +#------------------------------------------------------------------------------- + +ORG_NAME="rx3-docker" +ORG_REGISTRY="docker.xor.rx3:5000" +ORG_MAINTAINER='"Arnaud G. GIBERT" ' + + +ORG_URL_PREFIX="${ORG_REGISTRY}/${ORG_NAME}" + + + +#------------------------------------------------------------------------------- +# Image Settings +#------------------------------------------------------------------------------- + +HOST_NAME_PREFIX="" + +PORT_ENV_OFFSET=0 +PORT_SV_OFFSET=1000 + + +#------------------+----------+--------------------+--------------------------+------------------------------------------+------------+--------------------+---------------+------------+--------------+------------+-------+-------+-------+-------+--------------+--------------+ +# | Variable | Target Image | From Image | Module | Main Port | Admin Port | User | Group | +# | Prefix | URL Prefix | Name | Name Full + Version | URL Prefix | Name + Version | Name | Version | Ext | Int | Ext | Int | Name / Id | Name / Id | +#------------------+----------+--------------------+--------------------------+------------------------------------------+------------+--------------------+---------------+------------+--------------+------------+-------+-------+-------+-------+--------------+--------------+ + +docker_service_add DATABASE ${ORG_URL_PREFIX} mariadb "Rx3-Docker/MariaDB Docker Image" 1.1.0-mga9 ${ORG_URL_PREFIX} server 1.2.0-mga9 mysql - 8006 3306 - - 983 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/var/lib/.gitignore b/var/lib/mysql/.gitignore similarity index 100% rename from var/lib/.gitignore rename to var/lib/mysql/.gitignore diff --git a/var/log/init/.gitignore b/var/log/init/.gitignore new file mode 100644 index 0000000..5e7d273 --- /dev/null +++ b/var/log/init/.gitignore @@ -0,0 +1,4 @@ +# Ignore everything in this directory +* +# Except this file +!.gitignore diff --git a/var/log/mysql/.gitignore b/var/log/mysql/.gitignore new file mode 100644 index 0000000..5e7d273 --- /dev/null +++ b/var/log/mysql/.gitignore @@ -0,0 +1,4 @@ +# Ignore everything in this directory +* +# Except this file +!.gitignore diff --git a/var/log/supervisor/.gitignore b/var/log/supervisor/.gitignore new file mode 100644 index 0000000..5e7d273 --- /dev/null +++ b/var/log/supervisor/.gitignore @@ -0,0 +1,4 @@ +# Ignore everything in this directory +* +# Except this file +!.gitignore