├── 10.11 ├── test ├── root-common ├── s2i-common ├── README.md ├── Dockerfile.rhel8 ├── Dockerfile.rhel10 ├── Dockerfile.c10s ├── Dockerfile.rhel9 ├── Dockerfile.c9s └── Dockerfile.fedora ├── 10.3 ├── test ├── s2i-common ├── root-common ├── README.md ├── Dockerfile.rhel8 └── root │ └── usr │ └── share │ └── container-scripts │ └── mysql │ └── README.md ├── 10.5 ├── test ├── s2i-common ├── root-common ├── README.md ├── Dockerfile.rhel8 ├── Dockerfile.rhel9 ├── Dockerfile.c9s └── root │ └── usr │ └── share │ └── container-scripts │ └── mysql │ └── README.md ├── 11.8 ├── .exclude-c10s ├── .exclude-c9s ├── test ├── .exclude-rhel10 ├── .exclude-rhel9 ├── s2i-common ├── root-common ├── README.md ├── Dockerfile.rhel10 ├── Dockerfile.c10s ├── Dockerfile.rhel9 ├── Dockerfile.c9s └── Dockerfile.fedora ├── test ├── __init__.py ├── examples ├── imagestreams ├── test-app ├── test-lib.sh ├── test-openshift.yaml ├── check_imagestreams.py ├── test-lib-openshift.sh ├── show_all_imagestreams.py ├── test-lib-remote-openshift.sh ├── mariadb-ephemeral-template.json ├── mariadb-persistent-template.json ├── conftest.py ├── run-openshift-pytest ├── test_ocp_latest_imagestreams.py ├── run-openshift-remote-cluster ├── test_ocp_imagestream_template.py ├── test_ocp_imagestream.py ├── test_ocp_shared_helm_template.py ├── test_ocp_shared_helm_imagestreams.py ├── test_ocp_local_template.py └── test-lib-mysql.sh ├── .gitignore ├── .github ├── auto-merge.yml ├── dependabot.yml └── workflows │ ├── container-tests.yml │ ├── pr-metadata.yml │ ├── auto-merge.yml │ ├── auto-merge-on-demand.yml │ └── build-and-push.yml ├── root-common ├── usr │ ├── bin │ │ ├── mysqld-slave │ │ ├── mysqld-master │ │ ├── container-entrypoint │ │ ├── usage │ │ ├── run-mysqld │ │ ├── run-mysqld-master │ │ └── run-mysqld-slave │ ├── share │ │ └── container-scripts │ │ │ └── mysql │ │ │ ├── post-init.sh │ │ │ ├── pre-init │ │ │ ├── my-repl-gtid.cnf.template │ │ │ ├── my-base.cnf.template │ │ │ ├── 30-base-config.sh │ │ │ ├── 70-s2i-config.sh │ │ │ ├── my-master.cnf.template │ │ │ ├── my-slave.cnf.template │ │ │ ├── 60-replication-config.sh │ │ │ ├── 25-validate-replication-variables.sh │ │ │ └── 20-validate-variables.sh │ │ │ ├── helpers.sh │ │ │ ├── cnf │ │ │ ├── 50-my-tuning.cnf │ │ │ └── 40-paas.cnf │ │ │ ├── init │ │ │ ├── 50-passwd-change.sh │ │ │ └── 40-datadir-action.sh │ │ │ └── common.sh │ └── libexec │ │ ├── fix-permissions │ │ └── container-setup └── etc │ └── my.cnf ├── examples ├── extend-image │ ├── mysql-cfg │ │ └── myconfig.cnf │ ├── mysql-data │ │ └── init.sql │ ├── mysql-pre-init │ │ └── 80-check-arbitrary-users.sh │ └── mysql-init │ │ ├── 90-init-db.sh │ │ └── 80-add-arbitrary-users.sh ├── self-signed-ssl │ ├── mysql-cfg │ │ └── ssl.cnf │ └── mysql-certs │ │ ├── server-cert-selfsigned.pem │ │ └── server-key.pem ├── mariadb-ephemeral-template.json └── mariadb-persistent-template.json ├── .gitmodules ├── s2i-common └── bin │ ├── usage │ └── assemble ├── Makefile ├── imagestreams ├── imagestreams.yaml ├── mariadb-centos.json ├── mariadb-rhel.json └── mariadb-rhel-aarch64.json ├── README.md └── LICENSE /10.11/test: -------------------------------------------------------------------------------- 1 | ../test -------------------------------------------------------------------------------- /10.3/test: -------------------------------------------------------------------------------- 1 | ../test -------------------------------------------------------------------------------- /10.5/test: -------------------------------------------------------------------------------- 1 | ../test -------------------------------------------------------------------------------- /11.8/.exclude-c10s: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /11.8/.exclude-c9s: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /11.8/test: -------------------------------------------------------------------------------- 1 | ../test -------------------------------------------------------------------------------- /test/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /11.8/.exclude-rhel10: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /11.8/.exclude-rhel9: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /10.3/s2i-common: -------------------------------------------------------------------------------- 1 | ../s2i-common -------------------------------------------------------------------------------- /10.5/s2i-common: -------------------------------------------------------------------------------- 1 | ../s2i-common -------------------------------------------------------------------------------- /11.8/s2i-common: -------------------------------------------------------------------------------- 1 | ../s2i-common -------------------------------------------------------------------------------- /test/examples: -------------------------------------------------------------------------------- 1 | ../examples/ -------------------------------------------------------------------------------- /10.11/root-common: -------------------------------------------------------------------------------- 1 | ../root-common -------------------------------------------------------------------------------- /10.11/s2i-common: -------------------------------------------------------------------------------- 1 | ../s2i-common -------------------------------------------------------------------------------- /10.3/root-common: -------------------------------------------------------------------------------- 1 | ../root-common -------------------------------------------------------------------------------- /10.5/root-common: -------------------------------------------------------------------------------- 1 | ../root-common -------------------------------------------------------------------------------- /11.8/root-common: -------------------------------------------------------------------------------- 1 | ../root-common -------------------------------------------------------------------------------- /test/imagestreams: -------------------------------------------------------------------------------- 1 | ../imagestreams/ -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .*image-id* 2 | help.1 3 | -------------------------------------------------------------------------------- /test/test-app: -------------------------------------------------------------------------------- 1 | ../examples/extend-image/ -------------------------------------------------------------------------------- /test/test-lib.sh: -------------------------------------------------------------------------------- 1 | ../common/test-lib.sh -------------------------------------------------------------------------------- /.github/auto-merge.yml: -------------------------------------------------------------------------------- 1 | target-branch: [] 2 | -------------------------------------------------------------------------------- /root-common/usr/bin/mysqld-slave: -------------------------------------------------------------------------------- 1 | run-mysqld-slave -------------------------------------------------------------------------------- /root-common/usr/bin/mysqld-master: -------------------------------------------------------------------------------- 1 | run-mysqld-master -------------------------------------------------------------------------------- /test/test-openshift.yaml: -------------------------------------------------------------------------------- 1 | ../common/test-openshift.yaml -------------------------------------------------------------------------------- /root-common/usr/share/container-scripts/mysql/post-init.sh: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /test/check_imagestreams.py: -------------------------------------------------------------------------------- 1 | ../common/check_imagestreams.py -------------------------------------------------------------------------------- /test/test-lib-openshift.sh: -------------------------------------------------------------------------------- 1 | ../common/test-lib-openshift.sh -------------------------------------------------------------------------------- /10.11/README.md: -------------------------------------------------------------------------------- 1 | root/usr/share/container-scripts/mysql/README.md -------------------------------------------------------------------------------- /10.3/README.md: -------------------------------------------------------------------------------- 1 | root/usr/share/container-scripts/mysql/README.md -------------------------------------------------------------------------------- /10.5/README.md: -------------------------------------------------------------------------------- 1 | root/usr/share/container-scripts/mysql/README.md -------------------------------------------------------------------------------- /11.8/README.md: -------------------------------------------------------------------------------- 1 | root/usr/share/container-scripts/mysql/README.md -------------------------------------------------------------------------------- /test/show_all_imagestreams.py: -------------------------------------------------------------------------------- 1 | ../common/show_all_imagestreams.py -------------------------------------------------------------------------------- /root-common/usr/bin/container-entrypoint: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | exec "$@" 3 | -------------------------------------------------------------------------------- /test/test-lib-remote-openshift.sh: -------------------------------------------------------------------------------- 1 | ../common/test-lib-remote-openshift.sh -------------------------------------------------------------------------------- /test/mariadb-ephemeral-template.json: -------------------------------------------------------------------------------- 1 | ../examples/mariadb-ephemeral-template.json -------------------------------------------------------------------------------- /test/mariadb-persistent-template.json: -------------------------------------------------------------------------------- 1 | ../examples/mariadb-persistent-template.json -------------------------------------------------------------------------------- /examples/extend-image/mysql-cfg/myconfig.cnf: -------------------------------------------------------------------------------- 1 | [mysqld] 2 | query-cache-limit=262144 3 | 4 | -------------------------------------------------------------------------------- /root-common/usr/bin/usage: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | cat /usr/share/container-scripts/mysql/README.md 4 | 5 | -------------------------------------------------------------------------------- /test/conftest.py: -------------------------------------------------------------------------------- 1 | TAGS = { 2 | "rhel8": "-el8", 3 | "rhel9": "-el9", 4 | "rhel10": "-el10", 5 | } 6 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "common"] 2 | path = common 3 | url = https://github.com/sclorg/container-common-scripts.git 4 | -------------------------------------------------------------------------------- /root-common/usr/share/container-scripts/mysql/pre-init/my-repl-gtid.cnf.template: -------------------------------------------------------------------------------- 1 | [mysqld] 2 | 3 | log-slave-updates = ON 4 | 5 | -------------------------------------------------------------------------------- /s2i-common/bin/usage: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -o errexit 4 | set -o nounset 5 | set -o pipefail 6 | 7 | groff -t -man -ETascii /help.1 8 | 9 | -------------------------------------------------------------------------------- /examples/self-signed-ssl/mysql-cfg/ssl.cnf: -------------------------------------------------------------------------------- 1 | [mysqld] 2 | ssl-key=${APP_DATA}/mysql-certs/server-key.pem 3 | ssl-cert=${APP_DATA}/mysql-certs/server-cert-selfsigned.pem 4 | 5 | -------------------------------------------------------------------------------- /root-common/usr/share/container-scripts/mysql/pre-init/my-base.cnf.template: -------------------------------------------------------------------------------- 1 | [mysqld] 2 | datadir = ${MYSQL_DATADIR} 3 | basedir = ${MYSQL_PREFIX} 4 | plugin-dir = ${MYSQL_PREFIX}/lib64/mariadb/plugin 5 | 6 | -------------------------------------------------------------------------------- /root-common/usr/share/container-scripts/mysql/pre-init/30-base-config.sh: -------------------------------------------------------------------------------- 1 | log_info 'Processing basic MySQL configuration files ...' 2 | envsubst < ${CONTAINER_SCRIPTS_PATH}/pre-init/my-base.cnf.template > /etc/my.cnf.d/base.cnf 3 | 4 | -------------------------------------------------------------------------------- /examples/extend-image/mysql-data/init.sql: -------------------------------------------------------------------------------- 1 | CREATE TABLE products (id INTEGER, name VARCHAR(256), price FLOAT, variant INTEGER); 2 | CREATE TABLE products_variant (id INTEGER, name VARCHAR(256)); 3 | INSERT INTO products_variant (id, name) VALUES ('1', 'blue'), ('2', 'green'); 4 | 5 | -------------------------------------------------------------------------------- /root-common/usr/libexec/fix-permissions: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # Fix permissions on the given directory to allow group read/write of 3 | # regular files and execute of directories. 4 | find $@ -exec chown mysql:0 {} \; 5 | find $@ -exec chmod g+rw {} \; 6 | find $@ -type d -exec chmod g+x {} + 7 | -------------------------------------------------------------------------------- /s2i-common/bin/assemble: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -o errexit 4 | set -o nounset 5 | set -o pipefail 6 | 7 | shopt -s dotglob 8 | echo "---> Installing application source ..." 9 | mv /tmp/src/* ./ 2>/dev/null || true 10 | 11 | # Fix source directory permissions 12 | /usr/libexec/fix-permissions ./ 13 | 14 | -------------------------------------------------------------------------------- /root-common/usr/share/container-scripts/mysql/pre-init/70-s2i-config.sh: -------------------------------------------------------------------------------- 1 | # additional arbitrary mysqld configuration provided by user using s2i 2 | 3 | log_info 'Processing additional arbitrary MySQL configuration provided by s2i ...' 4 | 5 | process_extending_config_files ${APP_DATA}/mysql-cfg/ ${CONTAINER_SCRIPTS_PATH}/cnf/ 6 | 7 | -------------------------------------------------------------------------------- /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | --- 2 | 3 | version: 2 4 | updates: 5 | - package-ecosystem: gitsubmodule 6 | directory: / 7 | schedule: 8 | interval: weekly 9 | labels: 10 | - 'ready for review' 11 | - package-ecosystem: github-actions 12 | directory: / 13 | schedule: 14 | interval: monthly 15 | labels: 16 | - 'ready for review' 17 | -------------------------------------------------------------------------------- /examples/extend-image/mysql-pre-init/80-check-arbitrary-users.sh: -------------------------------------------------------------------------------- 1 | check_arbitrary_users() { 2 | if ! [[ -v MYSQL_OPERATIONS_USER && -v MYSQL_OPERATIONS_PASSWORD && -v MYSQL_DATABASE ]]; then 3 | echo "You need to specify all these variables: MYSQL_OPERATIONS_USER, MYSQL_OPERATIONS_PASSWORD, and MYSQL_DATABASE" 4 | return 1 5 | fi 6 | } 7 | 8 | if ! [ -v MYSQL_RUNNING_AS_SLAVE ]; then 9 | check_arbitrary_users 10 | fi 11 | -------------------------------------------------------------------------------- /root-common/usr/share/container-scripts/mysql/pre-init/my-master.cnf.template: -------------------------------------------------------------------------------- 1 | [mysqld] 2 | 3 | server-id = ${MYSQL_SERVER_ID} 4 | log_bin = ${MYSQL_DATADIR}/mysql-bin.log 5 | # Not using explicit DB filtering, from some unknown reason this makes the user 6 | # permissions not being replicated on 10.5 and further 7 | # binlog_do_db = mysql 8 | # binlog_do_db = ${MYSQL_DATABASE} 9 | binlog_format = ${MYSQL_BINLOG_FORMAT} 10 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | # Variables are documented in hack/build.sh. 2 | BASE_IMAGE_NAME = mariadb 3 | VERSIONS = 10.3 10.5 10.11 11.8 4 | OPENSHIFT_NAMESPACES = 5 | DOCKER_BUILD_CONTEXT = .. 6 | 7 | # HACK: Ensure that 'git pull' for old clones doesn't cause confusion. 8 | # New clones should use '--recursive'. 9 | .PHONY: $(shell test -f common/common.mk || echo >&2 'Please do "git submodule update --init" first.') 10 | 11 | include common/common.mk 12 | -------------------------------------------------------------------------------- /root-common/usr/share/container-scripts/mysql/pre-init/my-slave.cnf.template: -------------------------------------------------------------------------------- 1 | [mysqld] 2 | 3 | server-id = ${MYSQL_SERVER_ID} 4 | log_bin = ${MYSQL_DATADIR}/mysql-bin.log 5 | relay-log = ${MYSQL_DATADIR}/mysql-relay-bin.log 6 | # Not using explicit DB filtering, from some unknown reason this makes the user 7 | # permissions not being replicated on 10.5 and further 8 | # binlog_do_db = mysql 9 | # binlog_do_db = ${MYSQL_DATABASE} 10 | -------------------------------------------------------------------------------- /test/run-openshift-pytest: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # IMAGE_NAME specifies a name of the candidate image used for testing. 4 | # The image has to be available before this script is executed. 5 | # VERSION specifies the major version of the MariaDB in format of X.Y 6 | # OS specifies RHEL version (e.g. OS=rhel10) 7 | # 8 | 9 | THISDIR=$(dirname ${BASH_SOURCE[0]}) 10 | 11 | git show -s 12 | 13 | cd "${THISDIR}" && python3.12 -m pytest -s -rA --showlocals -vv test_ocp_*.py 14 | -------------------------------------------------------------------------------- /examples/extend-image/mysql-init/90-init-db.sh: -------------------------------------------------------------------------------- 1 | init_arbitrary_database() { 2 | local thisdir 3 | local init_data_file 4 | thisdir=$(dirname ${BASH_SOURCE[0]}) 5 | init_data_file=$(readlink -f ${thisdir}/../mysql-data/init.sql) 6 | log_info "Initializing the arbitrary database from file ${init_data_file}..." 7 | mysql $mysql_flags ${MYSQL_DATABASE} < ${init_data_file} 8 | } 9 | 10 | if ! [ -v MYSQL_RUNNING_AS_SLAVE ] && $MYSQL_DATADIR_FIRST_INIT ; then 11 | init_arbitrary_database 12 | fi 13 | -------------------------------------------------------------------------------- /root-common/etc/my.cnf: -------------------------------------------------------------------------------- 1 | [mysqld] 2 | 3 | # Disabling symbolic-links is recommended to prevent assorted security risks 4 | symbolic-links = 0 5 | 6 | # http://www.percona.com/blog/2008/05/31/dns-achilles-heel-mysql-installation/ 7 | skip_name_resolve 8 | 9 | # http://www.chriscalender.com/ignoring-the-lostfound-directory-in-your-datadir/ 10 | ignore-db-dirs=lost+found 11 | 12 | # GlusterFS equivalent of 'lost+found' 13 | ignore-db-dirs=.trashcan 14 | 15 | # NetApp snapshot dir 16 | ignore-db-dirs=.snapshot 17 | 18 | !includedir /etc/my.cnf.d 19 | -------------------------------------------------------------------------------- /.github/workflows/container-tests.yml: -------------------------------------------------------------------------------- 1 | on: 2 | issue_comment: 3 | types: 4 | - created 5 | jobs: 6 | check-readme: 7 | uses: "sclorg/ci-actions/.github/workflows/check-readme.yml@main" 8 | container-tests: 9 | needs: check-readme 10 | uses: "sclorg/ci-actions/.github/workflows/container-tests.yml@main" 11 | with: 12 | enabled-tests: '["container", "container-pytest", "openshift-4","openshift-pytest"]' 13 | versions: '[ "10.3", "10.5", "10.11", "11.8" ]' 14 | openshift-versions: '[ "10.3", "10.5", "10.11", "11.8" ]' 15 | secrets: inherit 16 | -------------------------------------------------------------------------------- /root-common/usr/share/container-scripts/mysql/helpers.sh: -------------------------------------------------------------------------------- 1 | function log_info { 2 | echo "---> `date +%T` $@" 3 | } 4 | 5 | function log_warn { 6 | echo "---> `date +%T` Warning: $@" 7 | } 8 | 9 | function log_and_run { 10 | log_info "Running $@" 11 | "$@" 12 | } 13 | 14 | function log_volume_info { 15 | CONTAINER_DEBUG=${CONTAINER_DEBUG:-} 16 | if [[ "${CONTAINER_DEBUG,,}" != "true" ]]; then 17 | return 18 | fi 19 | 20 | log_info "Volume info for $@:" 21 | set +e 22 | log_and_run mount 23 | while [ $# -gt 0 ]; do 24 | log_and_run ls -alZ $1 25 | shift 26 | done 27 | set -e 28 | if [[ -v DEBUG_IGNORE_SCRIPT_FAILURES ]]; then 29 | set +e 30 | fi 31 | } 32 | -------------------------------------------------------------------------------- /examples/extend-image/mysql-init/80-add-arbitrary-users.sh: -------------------------------------------------------------------------------- 1 | create_arbitrary_users() { 2 | # Do not care what option is compulsory here, just create what is specified 3 | log_info "Creating user specified by MYSQL_OPERATIONS_USER (${MYSQL_OPERATIONS_USER}) ..." 4 | mysql $mysql_flags < /etc/my.cnf.d/repl-gtid.cnf 6 | fi 7 | 8 | if [ -v MYSQL_RUNNING_AS_MASTER ] ; then 9 | log_info 'Processing basic MySQL configuration for replication (master only) files ...' 10 | envsubst < ${CONTAINER_SCRIPTS_PATH}/pre-init/my-master.cnf.template > /etc/my.cnf.d/master.cnf 11 | fi 12 | 13 | if [ -v MYSQL_RUNNING_AS_SLAVE ] ; then 14 | log_info 'Processing basic MySQL configuration for replication (slave only) files ...' 15 | envsubst < ${CONTAINER_SCRIPTS_PATH}/pre-init/my-slave.cnf.template > /etc/my.cnf.d/slave.cnf 16 | fi 17 | 18 | -------------------------------------------------------------------------------- /root-common/usr/share/container-scripts/mysql/cnf/50-my-tuning.cnf: -------------------------------------------------------------------------------- 1 | [mysqld] 2 | key_buffer_size = ${MYSQL_KEY_BUFFER_SIZE} 3 | max_allowed_packet = ${MYSQL_MAX_ALLOWED_PACKET} 4 | table_open_cache = ${MYSQL_TABLE_OPEN_CACHE} 5 | sort_buffer_size = ${MYSQL_SORT_BUFFER_SIZE} 6 | read_buffer_size = ${MYSQL_READ_BUFFER_SIZE} 7 | read_rnd_buffer_size = 256K 8 | net_buffer_length = 2K 9 | thread_stack = 256K 10 | myisam_sort_buffer_size = 2M 11 | 12 | # It is recommended that innodb_buffer_pool_size is configured to 50 to 75 percent of system memory. 13 | innodb_buffer_pool_size = ${MYSQL_INNODB_BUFFER_POOL_SIZE} 14 | # Set .._log_file_size to 25 % of buffer pool size 15 | innodb_log_file_size = ${MYSQL_INNODB_LOG_FILE_SIZE} 16 | innodb_log_buffer_size = ${MYSQL_INNODB_LOG_BUFFER_SIZE} 17 | 18 | [mysqldump] 19 | quick 20 | max_allowed_packet = 16M 21 | 22 | [mysql] 23 | no-auto-rehash 24 | 25 | [myisamchk] 26 | key_buffer_size = 8M 27 | sort_buffer_size = 8M 28 | -------------------------------------------------------------------------------- /root-common/usr/bin/run-mysqld: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | export_vars=$(cgroup-limits); export $export_vars 4 | source ${CONTAINER_SCRIPTS_PATH}/common.sh 5 | set -eu 6 | if [[ -v DEBUG_IGNORE_SCRIPT_FAILURES ]]; then 7 | set +e 8 | fi 9 | 10 | export_setting_variables 11 | 12 | log_volume_info $MYSQL_DATADIR 13 | 14 | # pre-init files 15 | process_extending_files ${APP_DATA}/mysql-pre-init/ ${CONTAINER_SCRIPTS_PATH}/pre-init/ 16 | 17 | if [ ! -d "$MYSQL_DATADIR/mysql" ]; then 18 | initialize_database "$@" 19 | else 20 | start_local_mysql "$@" 21 | fi 22 | 23 | # init files 24 | process_extending_files ${APP_DATA}/mysql-init/ ${CONTAINER_SCRIPTS_PATH}/init/ 25 | 26 | # Restart the MySQL server with public IP bindings 27 | shutdown_local_mysql 28 | unset_env_vars 29 | log_volume_info $MYSQL_DATADIR 30 | log_info 'Running final exec -- Only MySQL server logs after this point' 31 | exec ${MYSQL_PREFIX}/libexec/mysqld --defaults-file=$MYSQL_DEFAULTS_FILE "$@" 2>&1 32 | -------------------------------------------------------------------------------- /root-common/usr/share/container-scripts/mysql/pre-init/25-validate-replication-variables.sh: -------------------------------------------------------------------------------- 1 | function validate_replication_variables() { 2 | if ! [[ -v MYSQL_DATABASE && -v MYSQL_MASTER_USER && -v MYSQL_MASTER_PASSWORD && \ 3 | ( "${MYSQL_RUNNING_AS_SLAVE:-0}" != "1" || -v MYSQL_MASTER_SERVICE_NAME ) ]]; then 4 | echo 5 | echo "For master/slave replication, you have to specify following environment variables:" 6 | echo " MYSQL_MASTER_SERVICE_NAME (slave only)" 7 | echo " MYSQL_DATABASE" 8 | echo " MYSQL_MASTER_USER" 9 | echo " MYSQL_MASTER_PASSWORD" 10 | echo 11 | return 1 12 | fi 13 | [[ "$MYSQL_DATABASE" =~ $mysql_identifier_regex ]] || usage "Invalid database name" 14 | [[ "$MYSQL_MASTER_USER" =~ $mysql_identifier_regex ]] || usage "Invalid MySQL master username" 15 | [ ${#MYSQL_MASTER_USER} -le 16 ] || usage "MySQL master username too long (maximum 16 characters)" 16 | [[ "$MYSQL_MASTER_PASSWORD" =~ $mysql_password_regex ]] || usage "Invalid MySQL master password" 17 | } 18 | 19 | if [ -v MYSQL_RUNNING_AS_MASTER ] || [ -v MYSQL_RUNNING_AS_SLAVE ] ; then 20 | validate_replication_variables 21 | fi 22 | -------------------------------------------------------------------------------- /test/run-openshift-remote-cluster: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # Test the MariaDB image in OpenShift (remote cluster) 4 | # 5 | # IMAGE_NAME specifies a name of the candidate image used for testing. 6 | # The image has to be available before this script is executed. 7 | # VERSION specifies the major version of the MariaDB in format of X.Y 8 | # OS specifies RHEL version (e.g. OS=rhel10) 9 | # 10 | 11 | THISDIR=$(dirname ${BASH_SOURCE[0]}) 12 | 13 | source "${THISDIR}/test-lib-mysql.sh" 14 | source "${THISDIR}/test-lib-remote-openshift.sh" 15 | 16 | TEST_LIST="\ 17 | test_mariadb_integration 18 | test_mariadb_imagestream 19 | test_mariadb_template 20 | run_latest_imagestreams 21 | " 22 | 23 | trap ct_os_cleanup EXIT SIGINT 24 | 25 | ct_os_set_ocp4 || exit $OC_ERR 26 | 27 | ct_os_check_compulsory_vars || exit $OC_ERR 28 | 29 | ct_os_check_login || exit $OC_ERR 30 | 31 | ct_os_tag_image_for_cvp "mariadb" 32 | 33 | set -u 34 | 35 | # For testing on OpenShift 4 we use internal registry 36 | export CT_OCP4_TEST=true 37 | 38 | TEST_SUMMARY='' 39 | TEST_SET=${TESTS:-$TEST_LIST} ct_run_tests_from_testset "openshift-remote-cluster" 40 | # vim: set tabstop=2:shiftwidth=2:expandtab: 41 | 42 | -------------------------------------------------------------------------------- /.github/workflows/auto-merge.yml: -------------------------------------------------------------------------------- 1 | name: Auto Merge 2 | on: 3 | workflow_run: 4 | workflows: [ Gather Pull Request Metadata ] 5 | types: 6 | - completed 7 | 8 | permissions: 9 | contents: read 10 | 11 | jobs: 12 | download-metadata: 13 | if: > 14 | github.event.workflow_run.event == 'pull_request' && 15 | github.event.workflow_run.conclusion == 'success' 16 | runs-on: ubuntu-latest 17 | 18 | outputs: 19 | pr-metadata: ${{ steps.Artifact.outputs.pr-metadata-json }} 20 | 21 | steps: 22 | - id: Artifact 23 | name: Download Artifact 24 | uses: redhat-plumbers-in-action/download-artifact@v1 25 | with: 26 | name: pr-metadata 27 | 28 | auto-merge: 29 | needs: [ download-metadata ] 30 | runs-on: ubuntu-latest 31 | 32 | permissions: 33 | # required for merging PRs 34 | contents: write 35 | # required for PR comments and setting labels 36 | pull-requests: write 37 | 38 | steps: 39 | - name: Auto Merge wrapper 40 | uses: sclorg/auto-merge-wrapper@v1 41 | with: 42 | pr-metadata: ${{ needs.download-metadata.outputs.pr-metadata }} 43 | token: ${{ secrets.GITHUB_TOKEN }} 44 | -------------------------------------------------------------------------------- /root-common/usr/share/container-scripts/mysql/cnf/40-paas.cnf: -------------------------------------------------------------------------------- 1 | [mysqld] 2 | # 3 | # Settings configured by the user 4 | # 5 | 6 | # Sets how the table names are stored and compared. Default: 0 7 | lower_case_table_names = ${MYSQL_LOWER_CASE_TABLE_NAMES} 8 | 9 | # Sets whether queries should be logged 10 | general_log = ${MYSQL_LOG_QUERIES_ENABLED} 11 | general_log_file = ${MYSQL_DATADIR}/mysql-query.log 12 | 13 | # The maximum permitted number of simultaneous client connections. Default: 151 14 | max_connections = ${MYSQL_MAX_CONNECTIONS} 15 | 16 | # The minimum/maximum lengths of the word to be included in a FULLTEXT index. Default: 4/20 17 | ft_min_word_len = ${MYSQL_FT_MIN_WORD_LEN} 18 | ft_max_word_len = ${MYSQL_FT_MAX_WORD_LEN} 19 | 20 | # In case the native AIO is broken. Default: 1 21 | # See http://help.directadmin.com/item.php?id=529 22 | innodb_use_native_aio = ${MYSQL_AIO} 23 | 24 | [myisamchk] 25 | # The minimum/maximum lengths of the word to be included in a FULLTEXT index. Default: 4/20 26 | # 27 | # To ensure that myisamchk and the server use the same values for full-text 28 | # parameters, we placed them in both sections. 29 | ft_min_word_len = ${MYSQL_FT_MIN_WORD_LEN} 30 | ft_max_word_len = ${MYSQL_FT_MAX_WORD_LEN} 31 | -------------------------------------------------------------------------------- /imagestreams/imagestreams.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | - name: mariadb 3 | pretty_name: MariaDB 4 | sample_repo: "" 5 | category: database 6 | description: >- 7 | Provides a MariaDB APP_VERSION database on DISTRO_NAME. For more information 8 | about using this database image, including OpenShift considerations, see 9 | https://github.com/sclorg/mariadb-container/tree/master/APP_VERSION/README.md. 10 | imagestream_files: 11 | - filename: mariadb-centos.json 12 | latest: "10.11-el9" 13 | distros: 14 | - name: CentOS Stream 9 15 | app_versions: ["10.5", "10.11"] 16 | 17 | - name: CentOS Stream 10 18 | app_versions: ["10.11"] 19 | 20 | - filename: mariadb-rhel.json 21 | latest: "10.11-el9" 22 | distros: 23 | - name: RHEL 8 24 | app_versions: ["10.3", "10.5", "10.11"] 25 | 26 | - name: RHEL 9 27 | app_versions: ["10.5", "10.11"] 28 | 29 | - name: RHEL 10 30 | app_versions: ["10.11"] 31 | 32 | - filename: mariadb-rhel-aarch64.json 33 | latest: "10.11-el9" 34 | distros: 35 | - name: RHEL 8 36 | app_versions: ["10.3", "10.5", "10.11" ] 37 | 38 | - name: RHEL 9 39 | app_versions: ["10.5", "10.11"] 40 | 41 | - name: RHEL 10 42 | app_versions: ["10.11"] 43 | -------------------------------------------------------------------------------- /examples/self-signed-ssl/mysql-certs/server-cert-selfsigned.pem: -------------------------------------------------------------------------------- 1 | -----BEGIN CERTIFICATE----- 2 | MIIDWjCCAkKgAwIBAgIJALgudSbcOIlmMA0GCSqGSIb3DQEBCwUAMEIxCzAJBgNV 3 | BAYTAlhYMRUwEwYDVQQHDAxEZWZhdWx0IENpdHkxHDAaBgNVBAoME0RlZmF1bHQg 4 | Q29tcGFueSBMdGQwHhcNMTcxMDAzMjEzNjQxWhcNMTcxMTAyMjEzNjQxWjBCMQsw 5 | CQYDVQQGEwJYWDEVMBMGA1UEBwwMRGVmYXVsdCBDaXR5MRwwGgYDVQQKDBNEZWZh 6 | dWx0IENvbXBhbnkgTHRkMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA 7 | 5jSGpjnTdd8Wm9n76J1J9TL7MpZuk5y+LgrlgpQDY4nEgjCxyovOSG/XXdkPYq8C 8 | G1STOPYbzIlgNf17zz3qkk6CerTHYX1S3vx+cGGTuSHXM8S/X/ZuQYCoekfrYIOr 9 | XQqpigUAbDSRD8+agW8MNvL9VqajsrdJ6TeyzxQhaLHlUext7bfUy2aFq4x+84HX 10 | mwWRQRAUsL2j8jIo1PGAXCEeUqqHXo0poiHXbmC3mOH4FU2JWOFDcloeAjtTAy1v 11 | YcC/s5T7d/worAtNLQe5Yq/jZzUDKRlU2Om4H8d/4eFMGJXON5PasFMVsg8P9vy9 12 | ThBPJCmFegjyiqG4QN+tSQIDAQABo1MwUTAdBgNVHQ4EFgQUPjbxIDFAILmztsck 13 | MLi914dfNcIwHwYDVR0jBBgwFoAUPjbxIDFAILmztsckMLi914dfNcIwDwYDVR0T 14 | AQH/BAUwAwEB/zANBgkqhkiG9w0BAQsFAAOCAQEAjj0FC1J2Iv/+wmc5SsC6Ej0u 15 | fHlYsYSM0/nhNkvh+V0gIMfiTh90rPQ6K8DlmXK7HgCCqWTKRh6b030bcR33iMSk 16 | FeYgEsTqEBF9xae5rIUSEGznjfC/jGO6s8FjbZRxF2aVCoFADeIchBjaA2IRfVuT 17 | 2gXaf1s4UHJfY/b6cKlTWsGeOhUdPytHTDo3BbPLUfl1v0WGdCixEtd9M48Rdtxs 18 | bL4KuT4MEMlEYOZ3UjQ19iHWuzzAHuoZPhMvRTHXyL5Lz73zFBw7hOaCKiw7qH2C 19 | BwLmLtFkzTbD8cQD6Q1tCYzoXeO1769KxoUhULqrhvcgohmzj8vepabeFLHaeQ== 20 | -----END CERTIFICATE----- 21 | -------------------------------------------------------------------------------- /test/test_ocp_imagestream_template.py: -------------------------------------------------------------------------------- 1 | import os 2 | import sys 3 | 4 | import pytest 5 | 6 | from container_ci_suite.openshift import OpenShiftAPI 7 | from container_ci_suite.utils import check_variables 8 | 9 | from conftest import TAGS 10 | 11 | if not check_variables(): 12 | print("At least one variable from IMAGE_NAME, OS, VERSION is missing.") 13 | sys.exit(1) 14 | 15 | 16 | VERSION = os.getenv("VERSION") 17 | IMAGE_NAME = os.getenv("IMAGE_NAME") 18 | OS = os.getenv("TARGET") 19 | 20 | TAG = TAGS.get(OS) 21 | 22 | 23 | class TestMariaDBImagestreamTemplate: 24 | 25 | def setup_method(self): 26 | self.oc_api = OpenShiftAPI(pod_name_prefix="mariadb", version=VERSION, shared_cluster=True) 27 | 28 | def teardown_method(self): 29 | self.oc_api.delete_project() 30 | 31 | @pytest.mark.parametrize( 32 | "template", 33 | [ 34 | "mariadb-ephemeral-template.json", 35 | "mariadb-persistent-template.json" 36 | ] 37 | ) 38 | def test_mariadb_imagestream_template(self, template): 39 | os_name = ''.join(i for i in OS if not i.isdigit()) 40 | assert self.oc_api.deploy_image_stream_template( 41 | imagestream_file=f"imagestreams/mariadb-{os_name}.json", 42 | template_file=f"examples/{template}", 43 | app_name=self.oc_api.pod_name_prefix 44 | ) 45 | assert self.oc_api.is_pod_running(pod_name_prefix=self.oc_api.pod_name_prefix) 46 | -------------------------------------------------------------------------------- /test/test_ocp_imagestream.py: -------------------------------------------------------------------------------- 1 | import os 2 | import sys 3 | 4 | import pytest 5 | 6 | from container_ci_suite.openshift import OpenShiftAPI 7 | from container_ci_suite.utils import check_variables 8 | 9 | from conftest import TAGS 10 | 11 | if not check_variables(): 12 | print("At least one variable from IMAGE_NAME, OS, VERSION is missing.") 13 | sys.exit(1) 14 | 15 | 16 | VERSION = os.getenv("VERSION") 17 | IMAGE_NAME = os.getenv("IMAGE_NAME") 18 | OS = os.getenv("TARGET") 19 | 20 | TAG = TAGS.get(OS) 21 | 22 | 23 | class TestMariaDBImagestreamTemplate: 24 | 25 | def setup_method(self): 26 | self.oc_api = OpenShiftAPI(pod_name_prefix="mariadb", version=VERSION, shared_cluster=True) 27 | 28 | def teardown_method(self): 29 | self.oc_api.delete_project() 30 | 31 | @pytest.mark.parametrize( 32 | "template", 33 | [ 34 | "mariadb-ephemeral-template.json", 35 | "mariadb-persistent-template.json" 36 | ] 37 | ) 38 | def test_mariadb_imagestream_template(self, template): 39 | os_name = ''.join(i for i in OS if not i.isdigit()) 40 | print(os.getcwd()) 41 | assert self.oc_api.deploy_image_stream_template( 42 | imagestream_file=f"imagestreams/mariadb-{os_name}.json", 43 | template_file=f"examples/{template}", 44 | app_name=self.oc_api.pod_name_prefix, 45 | openshift_args=[ 46 | f"MARIADB_VERSION={VERSION}{TAG}" 47 | ] 48 | ) 49 | assert self.oc_api.is_pod_running(pod_name_prefix=self.oc_api.pod_name_prefix) 50 | -------------------------------------------------------------------------------- /test/test_ocp_shared_helm_template.py: -------------------------------------------------------------------------------- 1 | import os 2 | 3 | import pytest 4 | from pathlib import Path 5 | 6 | from container_ci_suite.helm import HelmChartsAPI 7 | 8 | from conftest import TAGS 9 | test_dir = Path(os.path.abspath(os.path.dirname(__file__))) 10 | 11 | VERSION = os.getenv("VERSION") 12 | IMAGE_NAME = os.getenv("IMAGE_NAME") 13 | OS = os.getenv("TARGET") 14 | 15 | TAG = TAGS.get(OS) 16 | 17 | 18 | class TestHelmMariaDBPersistent: 19 | 20 | def setup_method(self): 21 | package_name = "redhat-mariadb-persistent" 22 | path = test_dir 23 | self.hc_api = HelmChartsAPI(path=path, package_name=package_name, tarball_dir=test_dir, shared_cluster=True) 24 | self.hc_api.clone_helm_chart_repo( 25 | repo_url="https://github.com/sclorg/helm-charts", repo_name="helm-charts", 26 | subdir="charts/redhat" 27 | ) 28 | 29 | def teardown_method(self): 30 | self.hc_api.delete_project() 31 | 32 | def test_package_persistent(self): 33 | self.hc_api.package_name = "redhat-mariadb-imagestreams" 34 | assert self.hc_api.helm_package() 35 | assert self.hc_api.helm_installation() 36 | self.hc_api.package_name = "redhat-mariadb-persistent" 37 | assert self.hc_api.helm_package() 38 | assert self.hc_api.helm_installation( 39 | values={ 40 | "mariadb_version": f"{VERSION}{TAG}", 41 | "namespace": self.hc_api.namespace 42 | } 43 | ) 44 | assert self.hc_api.is_pod_running(pod_name_prefix="mariadb") 45 | assert self.hc_api.test_helm_chart(expected_str=["42", "testval"]) 46 | -------------------------------------------------------------------------------- /root-common/usr/libexec/container-setup: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | export MYSQL_CONFIG_FILE="/etc/my.cnf" 4 | 5 | [ -z "$MYSQL_CONFIG_FILE" ] && echo "MYSQL_CONFIG_FILE is empty" && exit 1 6 | 7 | unset -f mysql_get_correct_config mysql_get_config_files_scl 8 | 9 | # we provide own config files for the container, so clean what rpm ships here 10 | mkdir -p ${MYSQL_CONFIG_FILE}.d 11 | rm -f ${MYSQL_CONFIG_FILE}.d/* 12 | 13 | # we may add options during service init, so we need to have this dir writable by daemon user 14 | chown -R mysql:0 ${MYSQL_CONFIG_FILE}.d ${MYSQL_CONFIG_FILE} 15 | restorecon -R ${MYSQL_CONFIG_FILE}.d ${MYSQL_CONFIG_FILE} 16 | 17 | # API of the container are standard paths /etc/my.cnf and /etc/my.cnf.d 18 | # we already include own /etc/my.cnf for container, but for cases the 19 | # actually used config file is not on standard path /etc/my.cnf, we 20 | # need to move it to the location daemon expects it and create symlinks 21 | if [ "$MYSQL_CONFIG_FILE" != "/etc/my.cnf" ] ; then 22 | rm -rf /etc/my.cnf.d 23 | mv /etc/my.cnf ${MYSQL_CONFIG_FILE} 24 | ln -s ${MYSQL_CONFIG_FILE} /etc/my.cnf 25 | ln -s ${MYSQL_CONFIG_FILE}.d /etc/my.cnf.d 26 | fi 27 | 28 | # setup directory for data 29 | mkdir -p /var/lib/mysql/data 30 | chown -R mysql:0 /var/lib/mysql 31 | restorecon -R /var/lib/mysql 32 | 33 | # Loosen permission bits for group to avoid problems running container with 34 | # arbitrary UID 35 | # When only specifying user, group is 0, that's why /var/lib/mysql must have 36 | # owner mysql.0; that allows to avoid a+rwx for this dir 37 | /usr/libexec/fix-permissions /var/lib/mysql ${MYSQL_CONFIG_FILE}.d ${APP_DATA}/.. 38 | usermod -a -G root mysql 39 | 40 | -------------------------------------------------------------------------------- /test/test_ocp_shared_helm_imagestreams.py: -------------------------------------------------------------------------------- 1 | import os 2 | 3 | import pytest 4 | from pathlib import Path 5 | 6 | from container_ci_suite.helm import HelmChartsAPI 7 | 8 | test_dir = Path(os.path.abspath(os.path.dirname(__file__))) 9 | 10 | 11 | class TestHelmRHELMariadbImageStreams: 12 | 13 | def setup_method(self): 14 | package_name = "redhat-mariadb-imagestreams" 15 | path = test_dir 16 | self.hc_api = HelmChartsAPI(path=path, package_name=package_name, tarball_dir=test_dir, shared_cluster=True) 17 | self.hc_api.clone_helm_chart_repo( 18 | repo_url="https://github.com/sclorg/helm-charts", repo_name="helm-charts", 19 | subdir="charts/redhat" 20 | ) 21 | 22 | def teardown_method(self): 23 | self.hc_api.delete_project() 24 | 25 | @pytest.mark.parametrize( 26 | "version,registry,expected", 27 | [ 28 | ("10.11-el10", "registry.redhat.io/rhel10/mariadb-1011:latest", True), 29 | ("10.11-el9", "registry.redhat.io/rhel9/mariadb-1011:latest", True), 30 | ("10.11-el8", "registry.redhat.io/rhel8/mariadb-1011:latest", True), 31 | ("10.5-el9", "registry.redhat.io/rhel9/mariadb-105:latest", True), 32 | ("10.3-el8", "registry.redhat.io/rhel8/mariadb-103:latest", True), 33 | ("10.5-el8", "registry.redhat.io/rhel8/mariadb-105:latest", True), 34 | ], 35 | ) 36 | def test_package_imagestream(self, version, registry, expected): 37 | assert self.hc_api.helm_package() 38 | assert self.hc_api.helm_installation() 39 | assert self.hc_api.check_imagestreams(version=version, registry=registry) == expected 40 | -------------------------------------------------------------------------------- /root-common/usr/bin/run-mysqld-master: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # This is an entrypoint that runs the MySQL server in the 'master' mode. 4 | # 5 | 6 | export_vars=$(cgroup-limits); export $export_vars 7 | source ${CONTAINER_SCRIPTS_PATH}/common.sh 8 | set -eu 9 | if [[ -v DEBUG_IGNORE_SCRIPT_FAILURES ]]; then 10 | set +e 11 | fi 12 | 13 | export_setting_variables 14 | 15 | log_volume_info $MYSQL_DATADIR 16 | 17 | export MYSQL_RUNNING_AS_MASTER=1 18 | 19 | # The 'server-id' for master needs to be constant 20 | export MYSQL_SERVER_ID=1 21 | log_info "The 'master' server-id is ${MYSQL_SERVER_ID}" 22 | 23 | # pre-init files 24 | process_extending_files ${APP_DATA}/mysql-pre-init/ ${CONTAINER_SCRIPTS_PATH}/pre-init/ 25 | 26 | if [ ! -d "$MYSQL_DATADIR/mysql" ]; then 27 | initialize_database "$@" 28 | else 29 | start_local_mysql "$@" 30 | fi 31 | 32 | log_info 'Setting passwords ...' 33 | [ -f ${CONTAINER_SCRIPTS_PATH}/passwd-change.sh ] && source ${CONTAINER_SCRIPTS_PATH}/passwd-change.sh 34 | 35 | # Setup the 'master' replication on the MySQL server 36 | mysql $mysql_flags <&1 51 | -------------------------------------------------------------------------------- /examples/self-signed-ssl/mysql-certs/server-key.pem: -------------------------------------------------------------------------------- 1 | -----BEGIN PRIVATE KEY----- 2 | MIIEvwIBADANBgkqhkiG9w0BAQEFAASCBKkwggSlAgEAAoIBAQDmNIamOdN13xab 3 | 2fvonUn1Mvsylm6TnL4uCuWClANjicSCMLHKi85Ib9dd2Q9irwIbVJM49hvMiWA1 4 | /XvPPeqSToJ6tMdhfVLe/H5wYZO5IdczxL9f9m5BgKh6R+tgg6tdCqmKBQBsNJEP 5 | z5qBbww28v1WpqOyt0npN7LPFCFoseVR7G3tt9TLZoWrjH7zgdebBZFBEBSwvaPy 6 | MijU8YBcIR5SqodejSmiIdduYLeY4fgVTYlY4UNyWh4CO1MDLW9hwL+zlPt3/Cis 7 | C00tB7lir+NnNQMpGVTY6bgfx3/h4UwYlc43k9qwUxWyDw/2/L1OEE8kKYV6CPKK 8 | obhA361JAgMBAAECggEASsI2FBdlX7sSGYzh7PnfgbyLrTMDN/bIICWzwQMWUqXz 9 | 5h+wLUnXtNh1RWnvQCn7ciq2IOJzxqm6T+5A3d2KpvbOEtFQio1rczTmTtKxaYbe 10 | 31X+nEhoJ+eDTyq5+r7n0LBcvJDBQWKU1WCjGXOZsOKaeSBmuuwhGZbX/73W16uI 11 | S02VUfLJg+8jmd62bmtIwvRl+q2I/1esPT5Bt6QfK2IsjtTDi5up9/N8RHQMSay0 12 | AJlC//c/2kbfqWU54EmsA18pzHroTU2EPWeeBPNB9j3iNG8Qdvd9mF09zmR29KyC 13 | IRD2iEeJLvFvVY6hwCNB18el4QEddE08aZ9MGEKdvQKBgQD3y0CPgNmyjirRZH/+ 14 | ZJcf0mkJOwLqpvkwoCrDWUkPsaTJ4MARzO+oUY4CdiX0PT53rdY9ZZIPTPa1klQK 15 | 7On/UaeZpYrRQTIwhxhC5qjnSvDahOXEahp7PXuaNAz/QA2+5C5NQe3AMiF2cf1X 16 | yjJSsYnaI6tUG5EuMWNMmBcRrwKBgQDt1CjfTxifRw1y2uXdB+bXtD7X1L2sLLa7 17 | Krz9RTgud7vaOXyiuAgIly24aj4lbb3S1L2bfcoEAIx2KIQwQ7xzn20g9YeG/IN9 18 | DxJL+qX+YBANcF+d8DRC5K9YQDZtOouNVIHHT4Ypnm86ZHSZ3cCKmC1UsqhJYnod 19 | r2HuhXjGhwKBgQCXKONSZ0zmErnmEIPQATb7j5TJr7kAwikjU6Gil5XtP/YBvNwO 20 | P9E3AcE6mS5gBvhTc7VMsOhf8xhQ/VnNbGb2fK5cGVNMgZQHbHINZb5Fkj7JXub3 21 | Ya6T3ZbII9aF42I/P91K/dv2Md6d7b2ZT1xRe8JXUwkR/tsarcAgmmsAOwKBgQDf 22 | u+gbc9hw9rHDLAR0c9uJbupztpIcqA/bcfBKv1SD+mXBfLUwirocAsSjKWd/ZIbg 23 | EPyyi5qBO1boTWNV2FMv3noWOIUfyuuTuZr32TtRW2OekOmStgckKuh9uCK7jQj9 24 | ktNoAfrvqjlvEFPU8BUTDOgQNuYz6y2AQZ56ehvNfwKBgQCOp4BI5Y4eJX1X/EGF 25 | SiAqBhEarzhfbH7L60QAA3GfQH3LvgXy9eiDNjpeqOBmrrvJDiXhkLDEu/Gz0QGL 26 | SLBz0GkDbWChP2488mSHlJLc/hI0fjdOv7CxDNFdbNmbVIFd9hvPmNgN0JhaLoU/ 27 | Ue0ipybriEZJR9TLglybRNkYlw== 28 | -----END PRIVATE KEY----- 29 | -------------------------------------------------------------------------------- /root-common/usr/share/container-scripts/mysql/init/50-passwd-change.sh: -------------------------------------------------------------------------------- 1 | password_change() { 2 | log_info 'Setting passwords ...' 3 | 4 | # Set the password for MySQL user and root everytime this container is started. 5 | # This allows to change the password by editing the deployment configuration. 6 | if [[ -v MYSQL_USER && -v MYSQL_PASSWORD ]]; then 7 | local user_maches=$(echo "SELECT COUNT(*) AS found FROM mysql.user WHERE user='${MYSQL_USER}' AND Host='%' \G" | mysql $mysql_flags) 8 | if ! echo "${user_maches}" | grep -q 'found: 1' ; then 9 | log_info "WARNING: User ${MYSQL_USER} does not exist in database. Password not changed." 10 | else 11 | mysql $mysql_flags < "10.0" ] ; then 24 | mysql $mysql_flags < "10.0" ] ; then 33 | mysql $mysql_flags <&1 61 | -------------------------------------------------------------------------------- /.github/workflows/auto-merge-on-demand.yml: -------------------------------------------------------------------------------- 1 | name: Auto Merge On Demand 2 | on: 3 | issue_comment: 4 | types: 5 | - created 6 | workflow_dispatch: 7 | inputs: 8 | pr-number: 9 | description: 'Pull Request number/s ; when not provided, the workflow will run for all open PRs' 10 | required: true 11 | default: '0' 12 | 13 | permissions: 14 | contents: read 15 | 16 | jobs: 17 | # Get all open PRs 18 | gather-pull-requests: 19 | if: | 20 | github.repository_owner == 'sclorg' 21 | || (contains(github.event.comment.body, '/auto-merge') 22 | && contains(fromJson('["OWNER", "MEMBER"]'), github.event.comment.author_association)) 23 | runs-on: ubuntu-latest 24 | 25 | outputs: 26 | pr-numbers: ${{ steps.get-pr-numbers.outputs.result }} 27 | pr-numbers-manual: ${{ steps.parse-manual-input.outputs.result }} 28 | 29 | steps: 30 | - id: get-pr-numbers 31 | if: inputs.pr-number == '0' 32 | name: Get all open PRs 33 | uses: actions/github-script@v8 34 | with: 35 | # !FIXME: this is not working if there is more than 100 PRs opened 36 | script: | 37 | const { data: pullRequests } = await github.rest.pulls.list({ 38 | owner: context.repo.owner, 39 | repo: context.repo.repo, 40 | state: 'open', 41 | per_page: 100 42 | }); 43 | return pullRequests.map(pr => pr.number); 44 | 45 | - id: parse-manual-input 46 | if: inputs.pr-number != '0' 47 | name: Parse manual input 48 | run: | 49 | # shellcheck disable=SC2086 50 | echo "result="[ ${{ github.event.issue.number }} ]"" >> $GITHUB_OUTPUT 51 | shell: bash 52 | 53 | validate-pr: 54 | name: 'Validation of Pull Request #${{ matrix.pr-number }}' 55 | needs: [ gather-pull-requests ] 56 | runs-on: ubuntu-latest 57 | 58 | strategy: 59 | fail-fast: false 60 | matrix: 61 | pr-number: ${{ inputs.pr-number == 0 && fromJSON(needs.gather-pull-requests.outputs.pr-numbers) || fromJSON(needs.gather-pull-requests.outputs.pr-numbers-manual) }} 62 | 63 | permissions: 64 | # required for merging PRs 65 | contents: write 66 | # required for PR comments and setting labels 67 | pull-requests: write 68 | 69 | steps: 70 | - name: Auto Merge wrapper 71 | uses: sclorg/auto-merge-wrapper@v1 72 | with: 73 | pr-number: ${{ matrix.pr-number }} 74 | token: ${{ secrets.GITHUB_TOKEN }} 75 | -------------------------------------------------------------------------------- /.github/workflows/build-and-push.yml: -------------------------------------------------------------------------------- 1 | name: Build and push images to Quay.io registry 2 | on: 3 | push: 4 | branches: 5 | - master 6 | schedule: 7 | - cron: '0 1 * * 3' 8 | 9 | jobs: 10 | build-and-push: 11 | if: github.repository_owner == 'sclorg' 12 | runs-on: ubuntu-latest 13 | strategy: 14 | fail-fast: false 15 | matrix: 16 | include: 17 | - dockerfile: "10.11/Dockerfile.c9s" 18 | docker_context: "10.11" 19 | registry_namespace: "sclorg" 20 | quayio_username: "QUAY_IMAGE_SCLORG_BUILDER_USERNAME" 21 | quayio_token: "QUAY_IMAGE_SCLORG_BUILDER_TOKEN" 22 | tag: "c9s" 23 | image_name: "mariadb-1011-c9s" 24 | 25 | - dockerfile: "10.11/Dockerfile.c10s" 26 | docker_context: "10.11" 27 | registry_namespace: "sclorg" 28 | quayio_username: "QUAY_IMAGE_SCLORG_BUILDER_USERNAME" 29 | quayio_token: "QUAY_IMAGE_SCLORG_BUILDER_TOKEN" 30 | tag: "c10s" 31 | image_name: "mariadb-1011-c10s" 32 | 33 | - dockerfile: "10.5/Dockerfile.c9s" 34 | docker_context: "10.5" 35 | registry_namespace: "sclorg" 36 | quayio_username: "QUAY_IMAGE_SCLORG_BUILDER_USERNAME" 37 | quayio_token: "QUAY_IMAGE_SCLORG_BUILDER_TOKEN" 38 | tag: "c9s" 39 | image_name: "mariadb-105-c9s" 40 | 41 | - dockerfile: "10.5/Dockerfile.fedora" 42 | docker_context: "10.5" 43 | registry_namespace: "fedora" 44 | quayio_username: "QUAY_IMAGE_FEDORA_BUILDER_USERNAME" 45 | quayio_token: "QUAY_IMAGE_FEDORA_BUILDER_TOKEN" 46 | tag: "fedora" 47 | image_name: "mariadb-105" 48 | 49 | - dockerfile: "10.11/Dockerfile.fedora" 50 | docker_context: "10.11" 51 | registry_namespace: "fedora" 52 | quayio_username: "QUAY_IMAGE_FEDORA_BUILDER_USERNAME" 53 | quayio_token: "QUAY_IMAGE_FEDORA_BUILDER_TOKEN" 54 | tag: "fedora" 55 | image_name: "mariadb-1011" 56 | 57 | - dockerfile: "11.8/Dockerfile.fedora" 58 | docker_context: "11.8" 59 | registry_namespace: "fedora" 60 | quayio_username: "QUAY_IMAGE_FEDORA_BUILDER_USERNAME" 61 | quayio_token: "QUAY_IMAGE_FEDORA_BUILDER_TOKEN" 62 | tag: "fedora" 63 | image_name: "mariadb-118" 64 | 65 | 66 | steps: 67 | - name: Build and push to quay.io registry 68 | uses: sclorg/build-and-push-action@v4 69 | with: 70 | registry: "quay.io" 71 | registry_namespace: ${{ matrix.registry_namespace }} 72 | registry_username: ${{ secrets[matrix.quayio_username] }} 73 | registry_token: ${{ secrets[matrix.quayio_token] }} 74 | dockerfile: ${{ matrix.dockerfile }} 75 | tag: ${{ matrix.tag }} 76 | image_name: ${{ matrix.image_name }} 77 | readme: "${{ matrix.docker_context }}/README.md" 78 | quay_application_token: ${{ secrets.QUAY_IMAGE_SCLORG_UPDATE_DESC }} 79 | -------------------------------------------------------------------------------- /10.3/Dockerfile.rhel8: -------------------------------------------------------------------------------- 1 | FROM ubi8/s2i-core 2 | 3 | # MariaDB image for OpenShift. 4 | # 5 | # Volumes: 6 | # * /var/lib/mysql/data - Datastore for MariaDB 7 | # Environment: 8 | # * $MYSQL_USER - Database user name 9 | # * $MYSQL_PASSWORD - User's password 10 | # * $MYSQL_DATABASE - Name of the database to create 11 | # * $MYSQL_ROOT_PASSWORD (Optional) - Password for the 'root' MySQL account 12 | 13 | ENV MYSQL_VERSION=10.3 \ 14 | APP_DATA=/opt/app-root/src \ 15 | HOME=/var/lib/mysql \ 16 | SUMMARY="MariaDB 10.3 SQL database server" \ 17 | DESCRIPTION="MariaDB is a multi-user, multi-threaded SQL database server. The container \ 18 | image provides a containerized packaging of the MariaDB mysqld daemon and client application. \ 19 | The mysqld server daemon accepts connections from clients and provides access to content from \ 20 | MariaDB databases on behalf of the clients." 21 | 22 | LABEL summary="$SUMMARY" \ 23 | description="$DESCRIPTION" \ 24 | io.k8s.description="$DESCRIPTION" \ 25 | io.k8s.display-name="MariaDB 10.3" \ 26 | io.openshift.expose-services="3306:mysql" \ 27 | io.openshift.tags="database,mysql,mariadb,mariadb103,mariadb-103" \ 28 | com.redhat.component="mariadb-103-container" \ 29 | name="rhel8/mariadb-103" \ 30 | version="1" \ 31 | usage="podman run -d -e MYSQL_USER=user -e MYSQL_PASSWORD=pass -e MYSQL_DATABASE=db -p 3306:3306 rhel8/mariadb-103" \ 32 | maintainer="SoftwareCollections.org " 33 | 34 | EXPOSE 3306 35 | 36 | # This image must forever use UID 27 for mysql user so our volumes are 37 | # safe in the future. This should *never* change, the last test is there 38 | # to make sure of that. 39 | RUN yum -y module enable mariadb:$MYSQL_VERSION && \ 40 | INSTALL_PKGS="policycoreutils rsync tar gettext hostname groff-base mariadb-server" && \ 41 | yum install -y --setopt=tsflags=nodocs $INSTALL_PKGS && \ 42 | rpm -V $INSTALL_PKGS && \ 43 | /usr/libexec/mysqld -V | grep -qe "$MYSQL_VERSION\." && echo "Found VERSION $MYSQL_VERSION" && \ 44 | yum -y clean all --enablerepo='*' && \ 45 | mkdir -p /var/lib/mysql/data && chown -R mysql.0 /var/lib/mysql && \ 46 | test "$(id mysql)" = "uid=27(mysql) gid=27(mysql) groups=27(mysql)" 47 | 48 | # Get prefix path and path to scripts rather than hard-code them in scripts 49 | ENV CONTAINER_SCRIPTS_PATH=/usr/share/container-scripts/mysql \ 50 | MYSQL_PREFIX=/usr 51 | 52 | COPY 10.3/root-common / 53 | COPY 10.3/s2i-common/bin/ $STI_SCRIPTS_PATH 54 | COPY 10.3/root / 55 | 56 | # Hard links are not supported in Testing Farm approach during sync to guest 57 | # operation system. Therefore tests are failing on error 58 | # /usr/libexec/s2i/run no such file or directory 59 | RUN ln -s /bin/run-mysqld $STI_SCRIPTS_PATH/run 60 | 61 | # this is needed due to issues with squash 62 | # when this directory gets rm'd by the container-setup 63 | # script. 64 | # Also reset permissions of filesystem to default values 65 | RUN rm -rf /etc/my.cnf.d/* && \ 66 | /usr/libexec/container-setup && \ 67 | rpm-file-permissions 68 | 69 | USER 27 70 | 71 | ENTRYPOINT ["container-entrypoint"] 72 | CMD ["run-mysqld"] 73 | -------------------------------------------------------------------------------- /10.5/Dockerfile.rhel8: -------------------------------------------------------------------------------- 1 | FROM ubi8/s2i-core 2 | 3 | # MariaDB image for OpenShift. 4 | # 5 | # Volumes: 6 | # * /var/lib/mysql/data - Datastore for MariaDB 7 | # Environment: 8 | # * $MYSQL_USER - Database user name 9 | # * $MYSQL_PASSWORD - User's password 10 | # * $MYSQL_DATABASE - Name of the database to create 11 | # * $MYSQL_ROOT_PASSWORD (Optional) - Password for the 'root' MySQL account 12 | 13 | ENV MYSQL_VERSION=10.5 \ 14 | APP_DATA=/opt/app-root/src \ 15 | HOME=/var/lib/mysql \ 16 | SUMMARY="MariaDB 10.5 SQL database server" \ 17 | DESCRIPTION="MariaDB is a multi-user, multi-threaded SQL database server. The container \ 18 | image provides a containerized packaging of the MariaDB mysqld daemon and client application. \ 19 | The mysqld server daemon accepts connections from clients and provides access to content from \ 20 | MariaDB databases on behalf of the clients." 21 | 22 | LABEL summary="$SUMMARY" \ 23 | description="$DESCRIPTION" \ 24 | io.k8s.description="$DESCRIPTION" \ 25 | io.k8s.display-name="MariaDB 10.5" \ 26 | io.openshift.expose-services="3306:mysql" \ 27 | io.openshift.tags="database,mysql,mariadb,mariadb105,mariadb-105" \ 28 | com.redhat.component="mariadb-105-container" \ 29 | name="rhel8/mariadb-105" \ 30 | version="1" \ 31 | usage="podman run -d -e MYSQL_USER=user -e MYSQL_PASSWORD=pass -e MYSQL_DATABASE=db -p 3306:3306 rhel8/mariadb-105" \ 32 | maintainer="SoftwareCollections.org " 33 | 34 | EXPOSE 3306 35 | 36 | # This image must forever use UID 27 for mysql user so our volumes are 37 | # safe in the future. This should *never* change, the last test is there 38 | # to make sure of that. 39 | RUN yum -y module enable mariadb:$MYSQL_VERSION && \ 40 | INSTALL_PKGS="policycoreutils rsync tar gettext hostname groff-base mariadb-server" && \ 41 | yum install -y --setopt=tsflags=nodocs $INSTALL_PKGS && \ 42 | rpm -V $INSTALL_PKGS && \ 43 | /usr/libexec/mysqld -V | grep -qe "$MYSQL_VERSION\." && echo "Found VERSION $MYSQL_VERSION" && \ 44 | yum -y clean all --enablerepo='*' && \ 45 | mkdir -p /var/lib/mysql/data && chown -R mysql.0 /var/lib/mysql && \ 46 | test "$(id mysql)" = "uid=27(mysql) gid=27(mysql) groups=27(mysql)" 47 | 48 | # Get prefix path and path to scripts rather than hard-code them in scripts 49 | ENV CONTAINER_SCRIPTS_PATH=/usr/share/container-scripts/mysql \ 50 | MYSQL_PREFIX=/usr 51 | 52 | COPY 10.5/root-common / 53 | COPY 10.5/s2i-common/bin/ $STI_SCRIPTS_PATH 54 | COPY 10.5/root / 55 | 56 | # Hard links are not supported in Testing Farm approach during sync to guest 57 | # operation system. Therefore tests are failing on error 58 | # /usr/libexec/s2i/run no such file or directory 59 | RUN ln -s /usr/bin/run-mysqld $STI_SCRIPTS_PATH/run 60 | 61 | # this is needed due to issues with squash 62 | # when this directory gets rm'd by the container-setup 63 | # script. 64 | # Also reset permissions of filesystem to default values 65 | RUN rm -rf /etc/my.cnf.d/* && \ 66 | /usr/libexec/container-setup && \ 67 | rpm-file-permissions 68 | 69 | USER 27 70 | 71 | ENTRYPOINT ["container-entrypoint"] 72 | CMD ["run-mysqld"] 73 | -------------------------------------------------------------------------------- /10.11/Dockerfile.rhel8: -------------------------------------------------------------------------------- 1 | FROM ubi8/s2i-core 2 | 3 | # MariaDB image for OpenShift. 4 | # 5 | # Volumes: 6 | # * /var/lib/mysql/data - Datastore for MariaDB 7 | # Environment: 8 | # * $MYSQL_USER - Database user name 9 | # * $MYSQL_PASSWORD - User's password 10 | # * $MYSQL_DATABASE - Name of the database to create 11 | # * $MYSQL_ROOT_PASSWORD (Optional) - Password for the 'root' MySQL account 12 | 13 | ENV MYSQL_VERSION=10.11 \ 14 | APP_DATA=/opt/app-root/src \ 15 | HOME=/var/lib/mysql \ 16 | SUMMARY="MariaDB 10.11 SQL database server" \ 17 | DESCRIPTION="MariaDB is a multi-user, multi-threaded SQL database server. The container \ 18 | image provides a containerized packaging of the MariaDB mysqld daemon and client application. \ 19 | The mysqld server daemon accepts connections from clients and provides access to content from \ 20 | MariaDB databases on behalf of the clients." 21 | 22 | LABEL summary="$SUMMARY" \ 23 | description="$DESCRIPTION" \ 24 | io.k8s.description="$DESCRIPTION" \ 25 | io.k8s.display-name="MariaDB 10.11" \ 26 | io.openshift.expose-services="3306:mysql" \ 27 | io.openshift.tags="database,mysql,mariadb,mariadb1011,mariadb-1011" \ 28 | com.redhat.component="mariadb-1011-container" \ 29 | name="rhel8/mariadb-1011" \ 30 | version="1" \ 31 | usage="podman run -d -e MYSQL_USER=user -e MYSQL_PASSWORD=pass -e MYSQL_DATABASE=db -p 3306:3306 rhel8/mariadb-1011" \ 32 | maintainer="SoftwareCollections.org " 33 | 34 | EXPOSE 3306 35 | 36 | # This image must forever use UID 27 for mysql user so our volumes are 37 | # safe in the future. This should *never* change, the last test is there 38 | # to make sure of that. 39 | RUN yum -y module enable mariadb:$MYSQL_VERSION && \ 40 | INSTALL_PKGS="policycoreutils rsync tar gettext hostname groff-base mariadb-server" && \ 41 | yum install -y --setopt=tsflags=nodocs $INSTALL_PKGS && \ 42 | rpm -V $INSTALL_PKGS && \ 43 | /usr/libexec/mysqld -V | grep -qe "$MYSQL_VERSION\." && echo "Found VERSION $MYSQL_VERSION" && \ 44 | yum -y clean all --enablerepo='*' && \ 45 | mkdir -p /var/lib/mysql/data && chown -R mysql:root /var/lib/mysql && \ 46 | test "$(id mysql)" = "uid=27(mysql) gid=27(mysql) groups=27(mysql)" 47 | 48 | # Get prefix path and path to scripts rather than hard-code them in scripts 49 | ENV CONTAINER_SCRIPTS_PATH=/usr/share/container-scripts/mysql \ 50 | MYSQL_PREFIX=/usr 51 | 52 | COPY 10.11/root-common / 53 | COPY 10.11/s2i-common/bin/ $STI_SCRIPTS_PATH 54 | COPY 10.11/root / 55 | 56 | # Hard links are not supported in Testing Farm approach during sync to guest 57 | # operation system. Therefore tests are failing on error 58 | # /usr/libexec/s2i/run no such file or directory 59 | RUN ln -s /usr/bin/run-mysqld $STI_SCRIPTS_PATH/run 60 | 61 | # this is needed due to issues with squash 62 | # when this directory gets rm'd by the container-setup 63 | # script. 64 | # Also reset permissions of filesystem to default values 65 | RUN rm -rf /etc/my.cnf.d/* && \ 66 | /usr/libexec/container-setup && \ 67 | rpm-file-permissions 68 | 69 | USER 27 70 | 71 | ENTRYPOINT ["container-entrypoint"] 72 | CMD ["run-mysqld"] 73 | -------------------------------------------------------------------------------- /10.11/Dockerfile.rhel10: -------------------------------------------------------------------------------- 1 | FROM ubi10/s2i-core 2 | 3 | # MariaDB image for OpenShift. 4 | # 5 | # Volumes: 6 | # * /var/lib/mysql/data - Datastore for MariaDB 7 | # Environment: 8 | # * $MYSQL_USER - Database user name 9 | # * $MYSQL_PASSWORD - User's password 10 | # * $MYSQL_DATABASE - Name of the database to create 11 | # * $MYSQL_ROOT_PASSWORD (Optional) - Password for the 'root' MySQL account 12 | 13 | # Standalone ENV call so these values can be re-used in the other ENV calls 14 | ENV MYSQL_VERSION=10.11 \ 15 | MYSQL_SHORT_VERSION=1011 16 | 17 | ENV VERSION="${MYSQL_VERSION}" \ 18 | APP_DATA=/opt/app-root/src \ 19 | HOME=/var/lib/mysql \ 20 | NAME=mariadb \ 21 | SUMMARY="MariaDB ${MYSQL_VERSION} SQL database server" \ 22 | DESCRIPTION="MariaDB is a multi-user, multi-threaded SQL database server. The container \ 23 | image provides a containerized packaging of the MariaDB mysqld daemon and client application. \ 24 | The mysqld server daemon accepts connections from clients and provides access to content from \ 25 | MariaDB databases on behalf of the clients." 26 | 27 | LABEL summary="${SUMMARY}" \ 28 | description="${DESCRIPTION}" \ 29 | io.k8s.description="${DESCRIPTION}" \ 30 | io.k8s.display-name="MariaDB ${MYSQL_VERSION}" \ 31 | io.openshift.expose-services="3306:mysql" \ 32 | io.openshift.tags="database,mysql,${NAME},${NAME}${MYSQL_SHORT_VERSION},${NAME}-${MYSQL_SHORT_VERSION}" \ 33 | com.redhat.component="${NAME}-${MYSQL_SHORT_VERSION}-container" \ 34 | name="rhel10/${NAME}-${MYSQL_SHORT_VERSION}" \ 35 | com.redhat.license_terms="https://www.redhat.com/en/about/red-hat-end-user-license-agreements#rhel" \ 36 | usage="podman run -d -e MYSQL_USER=user -e MYSQL_PASSWORD=pass -e MYSQL_DATABASE=db -p 3306:3306 rhel10/${NAME}-${MYSQL_SHORT_VERSION}" \ 37 | maintainer="SoftwareCollections.org " 38 | 39 | EXPOSE 3306 40 | 41 | # This image must forever use UID 27 for mysql user so our volumes are 42 | # safe in the future. This should *never* change, the last test is there 43 | # to make sure of that. 44 | RUN INSTALL_PKGS="policycoreutils rsync tar xz gettext hostname groff-base" && \ 45 | dnf install -y --setopt=tsflags=nodocs ${INSTALL_PKGS} ${NAME}${MYSQL_VERSION}-server && \ 46 | /usr/libexec/mysqld -V | grep -qe "${MYSQL_VERSION}\." && echo "Found VERSION ${MYSQL_VERSION}" && \ 47 | dnf -y clean all --enablerepo='*' && \ 48 | mkdir -p ${HOME}/data && chown -R mysql:root ${HOME} && \ 49 | test "$(id mysql)" = "uid=27(mysql) gid=27(mysql) groups=27(mysql)" 50 | 51 | # Get prefix path and path to scripts rather than hard-code them in scripts 52 | ENV CONTAINER_SCRIPTS_PATH=/usr/share/container-scripts/mysql \ 53 | MYSQL_PREFIX=/usr 54 | 55 | COPY ${MYSQL_VERSION}/root-common / 56 | COPY ${MYSQL_VERSION}/s2i-common/bin/ ${STI_SCRIPTS_PATH} 57 | COPY ${MYSQL_VERSION}/root / 58 | 59 | # Hard links are not supported in Testing Farm approach during sync to guest 60 | # operation system. Therefore tests are failing on error 61 | # /usr/libexec/s2i/run no such file or directory 62 | RUN ln -s /usr/bin/run-mysqld ${STI_SCRIPTS_PATH}/run 63 | 64 | # this is needed due to issues with squash 65 | # when this directory gets rm'd by the container-setup 66 | # script. 67 | # Also reset permissions of filesystem to default values 68 | RUN rm -rf /etc/my.cnf.d/* && \ 69 | /usr/libexec/container-setup && \ 70 | rpm-file-permissions 71 | 72 | USER 27 73 | 74 | ENTRYPOINT ["container-entrypoint"] 75 | CMD ["run-mysqld"] 76 | -------------------------------------------------------------------------------- /11.8/Dockerfile.rhel10: -------------------------------------------------------------------------------- 1 | FROM ubi10/s2i-core 2 | 3 | # MariaDB image for OpenShift. 4 | # 5 | # Volumes: 6 | # * /var/lib/mysql/data - Datastore for MariaDB 7 | # Environment: 8 | # * $MYSQL_USER - Database user name 9 | # * $MYSQL_PASSWORD - User's password 10 | # * $MYSQL_DATABASE - Name of the database to create 11 | # * $MYSQL_ROOT_PASSWORD (Optional) - Password for the 'root' MySQL account 12 | 13 | # Standalone ENV call so these values can be re-used in the other ENV calls 14 | ENV MYSQL_VERSION=11.8 \ 15 | MYSQL_SHORT_VERSION=118 16 | 17 | ENV VERSION="${MYSQL_VERSION}" \ 18 | APP_DATA=/opt/app-root/src \ 19 | HOME=/var/lib/mysql \ 20 | NAME=mariadb \ 21 | SUMMARY="MariaDB ${MYSQL_VERSION} SQL database server" \ 22 | DESCRIPTION="MariaDB is a multi-user, multi-threaded SQL database server. The container \ 23 | image provides a containerized packaging of the MariaDB mysqld daemon and client application. \ 24 | The mysqld server daemon accepts connections from clients and provides access to content from \ 25 | MariaDB databases on behalf of the clients." 26 | 27 | LABEL summary="${SUMMARY}" \ 28 | description="${DESCRIPTION}" \ 29 | io.k8s.description="${DESCRIPTION}" \ 30 | io.k8s.display-name="MariaDB ${MYSQL_VERSION}" \ 31 | io.openshift.expose-services="3306:mysql" \ 32 | io.openshift.tags="database,mysql,${NAME},${NAME}${MYSQL_SHORT_VERSION},${NAME}-${MYSQL_SHORT_VERSION}" \ 33 | com.redhat.component="${NAME}-${MYSQL_SHORT_VERSION}-container" \ 34 | name="rhel10/${NAME}-${MYSQL_SHORT_VERSION}" \ 35 | version="1" \ 36 | com.redhat.license_terms="https://www.redhat.com/en/about/red-hat-end-user-license-agreements#rhel" \ 37 | usage="podman run -d -e MYSQL_USER=user -e MYSQL_PASSWORD=pass -e MYSQL_DATABASE=db -p 3306:3306 rhel10/${NAME}-${MYSQL_SHORT_VERSION}" \ 38 | maintainer="SoftwareCollections.org " 39 | 40 | EXPOSE 3306 41 | 42 | # This image must forever use UID 27 for mysql user so our volumes are 43 | # safe in the future. This should *never* change, the last test is there 44 | # to make sure of that. 45 | RUN INSTALL_PKGS="policycoreutils rsync tar xz gettext hostname groff-base" && \ 46 | dnf install -y --setopt=tsflags=nodocs ${INSTALL_PKGS} ${NAME}${MYSQL_VERSION}-server && \ 47 | /usr/libexec/mysqld -V | grep -qe "${MYSQL_VERSION}\." && echo "Found VERSION ${MYSQL_VERSION}" && \ 48 | dnf -y clean all --enablerepo='*' && \ 49 | mkdir -p ${HOME}/data && chown -R mysql:root ${HOME} && \ 50 | test "$(id mysql)" = "uid=27(mysql) gid=27(mysql) groups=27(mysql)" 51 | 52 | # Get prefix path and path to scripts rather than hard-code them in scripts 53 | ENV CONTAINER_SCRIPTS_PATH=/usr/share/container-scripts/mysql \ 54 | MYSQL_PREFIX=/usr 55 | 56 | COPY ${MYSQL_VERSION}/root-common / 57 | COPY ${MYSQL_VERSION}/s2i-common/bin/ ${STI_SCRIPTS_PATH} 58 | COPY ${MYSQL_VERSION}/root / 59 | 60 | # Hard links are not supported in Testing Farm approach during sync to guest 61 | # operation system. Therefore tests are failing on error 62 | # /usr/libexec/s2i/run no such file or directory 63 | RUN ln -s /usr/bin/run-mysqld ${STI_SCRIPTS_PATH}/run 64 | 65 | # this is needed due to issues with squash 66 | # when this directory gets rm'd by the container-setup 67 | # script. 68 | # Also reset permissions of filesystem to default values 69 | RUN rm -rf /etc/my.cnf.d/* && \ 70 | /usr/libexec/container-setup && \ 71 | rpm-file-permissions 72 | 73 | USER 27 74 | 75 | ENTRYPOINT ["container-entrypoint"] 76 | CMD ["run-mysqld"] 77 | -------------------------------------------------------------------------------- /10.5/Dockerfile.rhel9: -------------------------------------------------------------------------------- 1 | FROM ubi9/s2i-core 2 | 3 | # MariaDB image for OpenShift. 4 | # 5 | # Volumes: 6 | # * /var/lib/mysql/data - Datastore for MariaDB 7 | # Environment: 8 | # * $MYSQL_USER - Database user name 9 | # * $MYSQL_PASSWORD - User's password 10 | # * $MYSQL_DATABASE - Name of the database to create 11 | # * $MYSQL_ROOT_PASSWORD (Optional) - Password for the 'root' MySQL account 12 | 13 | # Standalone ENV call so these values can be re-used in the other ENV calls 14 | ENV MYSQL_VERSION=10.5 \ 15 | MYSQL_SHORT_VERSION=105 16 | 17 | ENV VERSION="${MYSQL_VERSION}" \ 18 | APP_DATA=/opt/app-root/src \ 19 | HOME=/var/lib/mysql \ 20 | NAME=mariadb \ 21 | SUMMARY="MariaDB ${MYSQL_VERSION} SQL database server" \ 22 | DESCRIPTION="MariaDB is a multi-user, multi-threaded SQL database server. The container \ 23 | image provides a containerized packaging of the MariaDB mysqld daemon and client application. \ 24 | The mysqld server daemon accepts connections from clients and provides access to content from \ 25 | MariaDB databases on behalf of the clients." 26 | 27 | LABEL summary="${SUMMARY}" \ 28 | description="${DESCRIPTION}" \ 29 | io.k8s.description="${DESCRIPTION}" \ 30 | io.k8s.display-name="MariaDB ${MYSQL_VERSION}" \ 31 | io.openshift.expose-services="3306:mysql" \ 32 | io.openshift.tags="database,mysql,${NAME},${NAME}${MYSQL_SHORT_VERSION},${NAME}-${MYSQL_SHORT_VERSION}" \ 33 | com.redhat.component="${NAME}-${MYSQL_SHORT_VERSION}-container" \ 34 | name="rhel9/${NAME}-${MYSQL_SHORT_VERSION}" \ 35 | version="1" \ 36 | com.redhat.license_terms="https://www.redhat.com/en/about/red-hat-end-user-license-agreements#rhel" \ 37 | usage="podman run -d -e MYSQL_USER=user -e MYSQL_PASSWORD=pass -e MYSQL_DATABASE=db -p 3306:3306 rhel9/${NAME}-${MYSQL_SHORT_VERSION}" \ 38 | maintainer="SoftwareCollections.org " 39 | 40 | EXPOSE 3306 41 | 42 | # This image must forever use UID 27 for mysql user so our volumes are 43 | # safe in the future. This should *never* change, the last test is there 44 | # to make sure of that. 45 | RUN INSTALL_PKGS="policycoreutils rsync tar gettext hostname groff-base ${NAME}-server" && \ 46 | yum install -y --setopt=tsflags=nodocs ${INSTALL_PKGS} && \ 47 | rpm -V ${INSTALL_PKGS} && \ 48 | /usr/libexec/mysqld -V | grep -qe "${MYSQL_VERSION}\." && echo "Found VERSION ${MYSQL_VERSION}" && \ 49 | yum -y clean all --enablerepo='*' && \ 50 | mkdir -p ${HOME}/data && chown -R mysql.0 ${HOME} && \ 51 | test "$(id mysql)" = "uid=27(mysql) gid=27(mysql) groups=27(mysql)" 52 | 53 | # Get prefix path and path to scripts rather than hard-code them in scripts 54 | ENV CONTAINER_SCRIPTS_PATH=/usr/share/container-scripts/mysql \ 55 | MYSQL_PREFIX=/usr 56 | 57 | COPY ${MYSQL_VERSION}/root-common / 58 | COPY ${MYSQL_VERSION}/s2i-common/bin/ ${STI_SCRIPTS_PATH} 59 | COPY ${MYSQL_VERSION}/root / 60 | 61 | # Hard links are not supported in Testing Farm approach during sync to guest 62 | # operation system. Therefore tests are failing on error 63 | # /usr/libexec/s2i/run no such file or directory 64 | RUN ln -s /usr/bin/run-mysqld ${STI_SCRIPTS_PATH}/run 65 | 66 | # this is needed due to issues with squash 67 | # when this directory gets rm'd by the container-setup 68 | # script. 69 | # Also reset permissions of filesystem to default values 70 | RUN rm -rf /etc/my.cnf.d/* && \ 71 | /usr/libexec/container-setup && \ 72 | rpm-file-permissions 73 | 74 | USER 27 75 | 76 | ENTRYPOINT ["container-entrypoint"] 77 | CMD ["run-mysqld"] 78 | -------------------------------------------------------------------------------- /11.8/Dockerfile.c10s: -------------------------------------------------------------------------------- 1 | FROM quay.io/sclorg/s2i-core-c10s:c10s 2 | 3 | # MariaDB image for OpenShift. 4 | # 5 | # Volumes: 6 | # * /var/lib/mysql/data - Datastore for MariaDB 7 | # Environment: 8 | # * $MYSQL_USER - Database user name 9 | # * $MYSQL_PASSWORD - User's password 10 | # * $MYSQL_DATABASE - Name of the database to create 11 | # * $MYSQL_ROOT_PASSWORD (Optional) - Password for the 'root' MySQL account 12 | 13 | # Standalone ENV call so these values can be re-used in the other ENV calls 14 | ENV MYSQL_VERSION=11.8 \ 15 | MYSQL_SHORT_VERSION=118 16 | 17 | ENV VERSION="${MYSQL_VERSION}" \ 18 | APP_DATA=/opt/app-root/src \ 19 | HOME=/var/lib/mysql \ 20 | NAME=mariadb \ 21 | ARCH=x86_64 \ 22 | SUMMARY="MariaDB ${MYSQL_VERSION} SQL database server" \ 23 | DESCRIPTION="MariaDB is a multi-user, multi-threaded SQL database server. The container \ 24 | image provides a containerized packaging of the MariaDB mysqld daemon and client application. \ 25 | The mysqld server daemon accepts connections from clients and provides access to content from \ 26 | MariaDB databases on behalf of the clients." 27 | 28 | LABEL summary="${SUMMARY}" \ 29 | description="${DESCRIPTION}" \ 30 | io.k8s.description="${DESCRIPTION}" \ 31 | io.k8s.display-name="MariaDB ${MYSQL_VERSION}" \ 32 | io.openshift.expose-services="3306:mysql" \ 33 | io.openshift.tags="database,mysql,${NAME},${NAME}${MYSQL_SHORT_VERSION},${NAME}-${MYSQL_SHORT_VERSION}" \ 34 | com.redhat.component="${NAME}-${MYSQL_SHORT_VERSION}-container" \ 35 | name="sclorg/${NAME}-${MYSQL_SHORT_VERSION}-c10s" \ 36 | version="1" \ 37 | com.redhat.license_terms="https://www.redhat.com/en/about/red-hat-end-user-license-agreements#rhel" \ 38 | usage="podman run -d -e MYSQL_USER=user -e MYSQL_PASSWORD=pass -e MYSQL_DATABASE=db -p 3306:3306 quay.io/sclorg/${NAME}-${MYSQL_SHORT_VERSION}-c10s" \ 39 | maintainer="SoftwareCollections.org " 40 | 41 | EXPOSE 3306 42 | 43 | # This image must forever use UID 27 for mysql user so our volumes are 44 | # safe in the future. This should *never* change, the last test is there 45 | # to make sure of that. 46 | RUN INSTALL_PKGS="policycoreutils rsync tar xz gettext hostname groff-base" && \ 47 | dnf install -y --setopt=tsflags=nodocs ${INSTALL_PKGS} ${NAME}${MYSQL_VERSION}-server && \ 48 | /usr/libexec/mysqld -V | grep -qe "${MYSQL_VERSION}\." && echo "Found VERSION ${MYSQL_VERSION}" && \ 49 | dnf -y clean all --enablerepo='*' && \ 50 | mkdir -p ${HOME}/data && chown -R mysql:root ${HOME} && \ 51 | test "$(id mysql)" = "uid=27(mysql) gid=27(mysql) groups=27(mysql)" 52 | 53 | # Get prefix path and path to scripts rather than hard-code them in scripts 54 | ENV CONTAINER_SCRIPTS_PATH=/usr/share/container-scripts/mysql \ 55 | MYSQL_PREFIX=/usr 56 | 57 | COPY ${MYSQL_VERSION}/root-common / 58 | COPY ${MYSQL_VERSION}/s2i-common/bin/ ${STI_SCRIPTS_PATH} 59 | COPY ${MYSQL_VERSION}/root / 60 | 61 | # Hard links are not supported in Testing Farm approach during sync to guest 62 | # operation system. Therefore tests are failing on error 63 | # /usr/libexec/s2i/run no such file or directory 64 | RUN ln -s /usr/bin/run-mysqld ${STI_SCRIPTS_PATH}/run 65 | 66 | # this is needed due to issues with squash 67 | # when this directory gets rm'd by the container-setup 68 | # script. 69 | # Also reset permissions of filesystem to default values 70 | RUN rm -rf /etc/my.cnf.d/* && \ 71 | /usr/libexec/container-setup && \ 72 | rpm-file-permissions 73 | 74 | USER 27 75 | 76 | ENTRYPOINT ["container-entrypoint"] 77 | CMD ["run-mysqld"] 78 | -------------------------------------------------------------------------------- /10.11/Dockerfile.c10s: -------------------------------------------------------------------------------- 1 | FROM quay.io/sclorg/s2i-core-c10s:c10s 2 | 3 | # MariaDB image for OpenShift. 4 | # 5 | # Volumes: 6 | # * /var/lib/mysql/data - Datastore for MariaDB 7 | # Environment: 8 | # * $MYSQL_USER - Database user name 9 | # * $MYSQL_PASSWORD - User's password 10 | # * $MYSQL_DATABASE - Name of the database to create 11 | # * $MYSQL_ROOT_PASSWORD (Optional) - Password for the 'root' MySQL account 12 | 13 | # Standalone ENV call so these values can be re-used in the other ENV calls 14 | ENV MYSQL_VERSION=10.11 \ 15 | MYSQL_SHORT_VERSION=1011 16 | 17 | ENV VERSION="${MYSQL_VERSION}" \ 18 | APP_DATA=/opt/app-root/src \ 19 | HOME=/var/lib/mysql \ 20 | NAME=mariadb \ 21 | ARCH=x86_64 \ 22 | SUMMARY="MariaDB ${MYSQL_VERSION} SQL database server" \ 23 | DESCRIPTION="MariaDB is a multi-user, multi-threaded SQL database server. The container \ 24 | image provides a containerized packaging of the MariaDB mysqld daemon and client application. \ 25 | The mysqld server daemon accepts connections from clients and provides access to content from \ 26 | MariaDB databases on behalf of the clients." 27 | 28 | LABEL summary="${SUMMARY}" \ 29 | description="${DESCRIPTION}" \ 30 | io.k8s.description="${DESCRIPTION}" \ 31 | io.k8s.display-name="MariaDB ${MYSQL_VERSION}" \ 32 | io.openshift.expose-services="3306:mysql" \ 33 | io.openshift.tags="database,mysql,${NAME},${NAME}${MYSQL_SHORT_VERSION},${NAME}-${MYSQL_SHORT_VERSION}" \ 34 | com.redhat.component="${NAME}-${MYSQL_SHORT_VERSION}-container" \ 35 | name="sclorg/${NAME}-${MYSQL_SHORT_VERSION}-c10s" \ 36 | version="1" \ 37 | com.redhat.license_terms="https://www.redhat.com/en/about/red-hat-end-user-license-agreements#rhel" \ 38 | usage="podman run -d -e MYSQL_USER=user -e MYSQL_PASSWORD=pass -e MYSQL_DATABASE=db -p 3306:3306 quay.io/sclorg/${NAME}-${MYSQL_SHORT_VERSION}-c10s" \ 39 | maintainer="SoftwareCollections.org " 40 | 41 | EXPOSE 3306 42 | 43 | # This image must forever use UID 27 for mysql user so our volumes are 44 | # safe in the future. This should *never* change, the last test is there 45 | # to make sure of that. 46 | RUN INSTALL_PKGS="policycoreutils rsync tar xz gettext hostname groff-base" && \ 47 | dnf install -y --setopt=tsflags=nodocs ${INSTALL_PKGS} ${NAME}${MYSQL_VERSION}-server && \ 48 | /usr/libexec/mysqld -V | grep -qe "${MYSQL_VERSION}\." && echo "Found VERSION ${MYSQL_VERSION}" && \ 49 | dnf -y clean all --enablerepo='*' && \ 50 | mkdir -p ${HOME}/data && chown -R mysql:root ${HOME} && \ 51 | test "$(id mysql)" = "uid=27(mysql) gid=27(mysql) groups=27(mysql)" 52 | 53 | # Get prefix path and path to scripts rather than hard-code them in scripts 54 | ENV CONTAINER_SCRIPTS_PATH=/usr/share/container-scripts/mysql \ 55 | MYSQL_PREFIX=/usr 56 | 57 | COPY ${MYSQL_VERSION}/root-common / 58 | COPY ${MYSQL_VERSION}/s2i-common/bin/ ${STI_SCRIPTS_PATH} 59 | COPY ${MYSQL_VERSION}/root / 60 | 61 | # Hard links are not supported in Testing Farm approach during sync to guest 62 | # operation system. Therefore tests are failing on error 63 | # /usr/libexec/s2i/run no such file or directory 64 | RUN ln -s /usr/bin/run-mysqld ${STI_SCRIPTS_PATH}/run 65 | 66 | # this is needed due to issues with squash 67 | # when this directory gets rm'd by the container-setup 68 | # script. 69 | # Also reset permissions of filesystem to default values 70 | RUN rm -rf /etc/my.cnf.d/* && \ 71 | /usr/libexec/container-setup && \ 72 | rpm-file-permissions 73 | 74 | USER 27 75 | 76 | ENTRYPOINT ["container-entrypoint"] 77 | CMD ["run-mysqld"] 78 | -------------------------------------------------------------------------------- /11.8/Dockerfile.rhel9: -------------------------------------------------------------------------------- 1 | FROM ubi9/s2i-core 2 | 3 | # MariaDB image for OpenShift. 4 | # 5 | # Volumes: 6 | # * /var/lib/mysql/data - Datastore for MariaDB 7 | # Environment: 8 | # * $MYSQL_USER - Database user name 9 | # * $MYSQL_PASSWORD - User's password 10 | # * $MYSQL_DATABASE - Name of the database to create 11 | # * $MYSQL_ROOT_PASSWORD (Optional) - Password for the 'root' MySQL account 12 | 13 | # Standalone ENV call so these values can be re-used in the other ENV calls 14 | ENV MYSQL_VERSION=11.8 \ 15 | MYSQL_SHORT_VERSION=118 16 | 17 | ENV VERSION="${MYSQL_VERSION}" \ 18 | APP_DATA=/opt/app-root/src \ 19 | HOME=/var/lib/mysql \ 20 | NAME=mariadb \ 21 | SUMMARY="MariaDB ${MYSQL_VERSION} SQL database server" \ 22 | DESCRIPTION="MariaDB is a multi-user, multi-threaded SQL database server. The container \ 23 | image provides a containerized packaging of the MariaDB mysqld daemon and client application. \ 24 | The mysqld server daemon accepts connections from clients and provides access to content from \ 25 | MariaDB databases on behalf of the clients." 26 | 27 | LABEL summary="${SUMMARY}" \ 28 | description="${DESCRIPTION}" \ 29 | io.k8s.description="${DESCRIPTION}" \ 30 | io.k8s.display-name="MariaDB ${MYSQL_VERSION}" \ 31 | io.openshift.expose-services="3306:mysql" \ 32 | io.openshift.tags="database,mysql,${NAME},${NAME}${MYSQL_SHORT_VERSION},${NAME}-${MYSQL_SHORT_VERSION}" \ 33 | com.redhat.component="${NAME}-${MYSQL_SHORT_VERSION}-container" \ 34 | name="rhel9/${NAME}-${MYSQL_SHORT_VERSION}" \ 35 | version="1" \ 36 | com.redhat.license_terms="https://www.redhat.com/en/about/red-hat-end-user-license-agreements#rhel" \ 37 | usage="podman run -d -e MYSQL_USER=user -e MYSQL_PASSWORD=pass -e MYSQL_DATABASE=db -p 3306:3306 rhel9/${NAME}-${MYSQL_SHORT_VERSION}" \ 38 | maintainer="SoftwareCollections.org " 39 | 40 | EXPOSE 3306 41 | 42 | # This image must forever use UID 27 for mysql user so our volumes are 43 | # safe in the future. This should *never* change, the last test is there 44 | # to make sure of that. 45 | RUN yum -y module enable ${NAME}:${MYSQL_VERSION} && \ 46 | INSTALL_PKGS="policycoreutils rsync tar gettext hostname groff-base ${NAME}-server" && \ 47 | yum install -y --setopt=tsflags=nodocs ${INSTALL_PKGS} && \ 48 | rpm -V ${INSTALL_PKGS} && \ 49 | /usr/libexec/mysqld -V | grep -qe "${MYSQL_VERSION}\." && echo "Found VERSION ${MYSQL_VERSION}" && \ 50 | yum -y clean all --enablerepo='*' && \ 51 | mkdir -p ${HOME}/data && chown -R mysql:root ${HOME} && \ 52 | test "$(id mysql)" = "uid=27(mysql) gid=27(mysql) groups=27(mysql)" 53 | 54 | # Get prefix path and path to scripts rather than hard-code them in scripts 55 | ENV CONTAINER_SCRIPTS_PATH=/usr/share/container-scripts/mysql \ 56 | MYSQL_PREFIX=/usr 57 | 58 | COPY ${MYSQL_VERSION}/root-common / 59 | COPY ${MYSQL_VERSION}/s2i-common/bin/ ${STI_SCRIPTS_PATH} 60 | COPY ${MYSQL_VERSION}/root / 61 | 62 | # Hard links are not supported in Testing Farm approach during sync to guest 63 | # operation system. Therefore tests are failing on error 64 | # /usr/libexec/s2i/run no such file or directory 65 | RUN ln -s /usr/bin/run-mysqld ${STI_SCRIPTS_PATH}/run 66 | 67 | # this is needed due to issues with squash 68 | # when this directory gets rm'd by the container-setup 69 | # script. 70 | # Also reset permissions of filesystem to default values 71 | RUN rm -rf /etc/my.cnf.d/* && \ 72 | /usr/libexec/container-setup && \ 73 | rpm-file-permissions 74 | 75 | USER 27 76 | 77 | ENTRYPOINT ["container-entrypoint"] 78 | CMD ["run-mysqld"] 79 | -------------------------------------------------------------------------------- /10.11/Dockerfile.rhel9: -------------------------------------------------------------------------------- 1 | FROM ubi9/s2i-core 2 | 3 | # MariaDB image for OpenShift. 4 | # 5 | # Volumes: 6 | # * /var/lib/mysql/data - Datastore for MariaDB 7 | # Environment: 8 | # * $MYSQL_USER - Database user name 9 | # * $MYSQL_PASSWORD - User's password 10 | # * $MYSQL_DATABASE - Name of the database to create 11 | # * $MYSQL_ROOT_PASSWORD (Optional) - Password for the 'root' MySQL account 12 | 13 | # Standalone ENV call so these values can be re-used in the other ENV calls 14 | ENV MYSQL_VERSION=10.11 \ 15 | MYSQL_SHORT_VERSION=1011 16 | 17 | ENV VERSION="${MYSQL_VERSION}" \ 18 | APP_DATA=/opt/app-root/src \ 19 | HOME=/var/lib/mysql \ 20 | NAME=mariadb \ 21 | SUMMARY="MariaDB ${MYSQL_VERSION} SQL database server" \ 22 | DESCRIPTION="MariaDB is a multi-user, multi-threaded SQL database server. The container \ 23 | image provides a containerized packaging of the MariaDB mysqld daemon and client application. \ 24 | The mysqld server daemon accepts connections from clients and provides access to content from \ 25 | MariaDB databases on behalf of the clients." 26 | 27 | LABEL summary="${SUMMARY}" \ 28 | description="${DESCRIPTION}" \ 29 | io.k8s.description="${DESCRIPTION}" \ 30 | io.k8s.display-name="MariaDB ${MYSQL_VERSION}" \ 31 | io.openshift.expose-services="3306:mysql" \ 32 | io.openshift.tags="database,mysql,${NAME},${NAME}${MYSQL_SHORT_VERSION},${NAME}-${MYSQL_SHORT_VERSION}" \ 33 | com.redhat.component="${NAME}-${MYSQL_SHORT_VERSION}-container" \ 34 | name="rhel9/${NAME}-${MYSQL_SHORT_VERSION}" \ 35 | version="1" \ 36 | com.redhat.license_terms="https://www.redhat.com/en/about/red-hat-end-user-license-agreements#rhel" \ 37 | usage="podman run -d -e MYSQL_USER=user -e MYSQL_PASSWORD=pass -e MYSQL_DATABASE=db -p 3306:3306 rhel9/${NAME}-${MYSQL_SHORT_VERSION}" \ 38 | maintainer="SoftwareCollections.org " 39 | 40 | EXPOSE 3306 41 | 42 | # This image must forever use UID 27 for mysql user so our volumes are 43 | # safe in the future. This should *never* change, the last test is there 44 | # to make sure of that. 45 | RUN yum -y module enable ${NAME}:${MYSQL_VERSION} && \ 46 | INSTALL_PKGS="policycoreutils rsync tar gettext hostname groff-base ${NAME}-server" && \ 47 | yum install -y --setopt=tsflags=nodocs ${INSTALL_PKGS} && \ 48 | rpm -V ${INSTALL_PKGS} && \ 49 | /usr/libexec/mysqld -V | grep -qe "${MYSQL_VERSION}\." && echo "Found VERSION ${MYSQL_VERSION}" && \ 50 | yum -y clean all --enablerepo='*' && \ 51 | mkdir -p ${HOME}/data && chown -R mysql:root ${HOME} && \ 52 | test "$(id mysql)" = "uid=27(mysql) gid=27(mysql) groups=27(mysql)" 53 | 54 | # Get prefix path and path to scripts rather than hard-code them in scripts 55 | ENV CONTAINER_SCRIPTS_PATH=/usr/share/container-scripts/mysql \ 56 | MYSQL_PREFIX=/usr 57 | 58 | COPY ${MYSQL_VERSION}/root-common / 59 | COPY ${MYSQL_VERSION}/s2i-common/bin/ ${STI_SCRIPTS_PATH} 60 | COPY ${MYSQL_VERSION}/root / 61 | 62 | # Hard links are not supported in Testing Farm approach during sync to guest 63 | # operation system. Therefore tests are failing on error 64 | # /usr/libexec/s2i/run no such file or directory 65 | RUN ln -s /usr/bin/run-mysqld ${STI_SCRIPTS_PATH}/run 66 | 67 | # this is needed due to issues with squash 68 | # when this directory gets rm'd by the container-setup 69 | # script. 70 | # Also reset permissions of filesystem to default values 71 | RUN rm -rf /etc/my.cnf.d/* && \ 72 | /usr/libexec/container-setup && \ 73 | rpm-file-permissions 74 | 75 | USER 27 76 | 77 | ENTRYPOINT ["container-entrypoint"] 78 | CMD ["run-mysqld"] 79 | -------------------------------------------------------------------------------- /10.5/Dockerfile.c9s: -------------------------------------------------------------------------------- 1 | FROM quay.io/sclorg/s2i-core-c9s:c9s 2 | 3 | # MariaDB image for OpenShift. 4 | # 5 | # Volumes: 6 | # * /var/lib/mysql/data - Datastore for MariaDB 7 | # Environment: 8 | # * $MYSQL_USER - Database user name 9 | # * $MYSQL_PASSWORD - User's password 10 | # * $MYSQL_DATABASE - Name of the database to create 11 | # * $MYSQL_ROOT_PASSWORD (Optional) - Password for the 'root' MySQL account 12 | 13 | # Standalone ENV call so these values can be re-used in the other ENV calls 14 | ENV MYSQL_VERSION=10.5 \ 15 | MYSQL_SHORT_VERSION=105 16 | 17 | ENV VERSION="${MYSQL_VERSION}" \ 18 | APP_DATA=/opt/app-root/src \ 19 | HOME=/var/lib/mysql \ 20 | NAME=mariadb \ 21 | SUMMARY="MariaDB ${MYSQL_VERSION} SQL database server" \ 22 | DESCRIPTION="MariaDB is a multi-user, multi-threaded SQL database server. The container \ 23 | image provides a containerized packaging of the MariaDB mysqld daemon and client application. \ 24 | The mysqld server daemon accepts connections from clients and provides access to content from \ 25 | MariaDB databases on behalf of the clients." 26 | 27 | LABEL summary="${SUMMARY}" \ 28 | description="${DESCRIPTION}" \ 29 | io.k8s.description="${DESCRIPTION}" \ 30 | io.k8s.display-name="MariaDB ${MYSQL_VERSION}" \ 31 | io.openshift.expose-services="3306:mysql" \ 32 | io.openshift.tags="database,mysql,${NAME},${NAME}${MYSQL_SHORT_VERSION},${NAME}-${MYSQL_SHORT_VERSION}" \ 33 | com.redhat.component="${NAME}-${MYSQL_SHORT_VERSION}-container" \ 34 | name="sclorg/${NAME}-${MYSQL_SHORT_VERSION}-c9s" \ 35 | version="1" \ 36 | com.redhat.license_terms="https://www.redhat.com/en/about/red-hat-end-user-license-agreements#rhel" \ 37 | usage="podman run -d -e MYSQL_USER=user -e MYSQL_PASSWORD=pass -e MYSQL_DATABASE=db -p 3306:3306 quay.io/sclorg/${NAME}-${MYSQL_SHORT_VERSION}-c9s" \ 38 | maintainer="SoftwareCollections.org " 39 | 40 | EXPOSE 3306 41 | 42 | # This image must forever use UID 27 for mysql user so our volumes are 43 | # safe in the future. This should *never* change, the last test is there 44 | # to make sure of that. 45 | RUN yum -y module disable ${NAME} && \ 46 | INSTALL_PKGS="policycoreutils rsync tar gettext hostname groff-base ${NAME}-server" && \ 47 | yum install -y --setopt=tsflags=nodocs ${INSTALL_PKGS} && \ 48 | rpm -V ${INSTALL_PKGS} && \ 49 | /usr/libexec/mysqld -V | grep -qe "${MYSQL_VERSION}\." && echo "Found VERSION ${MYSQL_VERSION}" && \ 50 | yum -y clean all --enablerepo='*' && \ 51 | mkdir -p ${HOME}/data && chown -R mysql.0 ${HOME} && \ 52 | test "$(id mysql)" = "uid=27(mysql) gid=27(mysql) groups=27(mysql)" 53 | 54 | # Get prefix path and path to scripts rather than hard-code them in scripts 55 | ENV CONTAINER_SCRIPTS_PATH=/usr/share/container-scripts/mysql \ 56 | MYSQL_PREFIX=/usr 57 | 58 | COPY ${MYSQL_VERSION}/root-common / 59 | COPY ${MYSQL_VERSION}/s2i-common/bin/ ${STI_SCRIPTS_PATH} 60 | COPY ${MYSQL_VERSION}/root / 61 | 62 | # Hard links are not supported in Testing Farm approach during sync to guest 63 | # operation system. Therefore tests are failing on error 64 | # /usr/libexec/s2i/run no such file or directory 65 | RUN ln -s /usr/bin/run-mysqld ${STI_SCRIPTS_PATH}/run 66 | 67 | # this is needed due to issues with squash 68 | # when this directory gets rm'd by the container-setup 69 | # script. 70 | # Also reset permissions of filesystem to default values 71 | RUN rm -rf /etc/my.cnf.d/* && \ 72 | /usr/libexec/container-setup && \ 73 | rpm-file-permissions 74 | 75 | USER 27 76 | 77 | ENTRYPOINT ["container-entrypoint"] 78 | CMD ["run-mysqld"] 79 | -------------------------------------------------------------------------------- /11.8/Dockerfile.c9s: -------------------------------------------------------------------------------- 1 | FROM quay.io/sclorg/s2i-core-c9s:c9s 2 | 3 | # MariaDB image for OpenShift. 4 | # 5 | # Volumes: 6 | # * /var/lib/mysql/data - Datastore for MariaDB 7 | # Environment: 8 | # * $MYSQL_USER - Database user name 9 | # * $MYSQL_PASSWORD - User's password 10 | # * $MYSQL_DATABASE - Name of the database to create 11 | # * $MYSQL_ROOT_PASSWORD (Optional) - Password for the 'root' MySQL account 12 | 13 | # Standalone ENV call so these values can be re-used in the other ENV calls 14 | ENV MYSQL_VERSION=11.8 \ 15 | MYSQL_SHORT_VERSION=118 16 | 17 | ENV VERSION="${MYSQL_VERSION}" \ 18 | APP_DATA=/opt/app-root/src \ 19 | HOME=/var/lib/mysql \ 20 | NAME=mariadb \ 21 | SUMMARY="MariaDB ${MYSQL_VERSION} SQL database server" \ 22 | DESCRIPTION="MariaDB is a multi-user, multi-threaded SQL database server. The container \ 23 | image provides a containerized packaging of the MariaDB mysqld daemon and client application. \ 24 | The mysqld server daemon accepts connections from clients and provides access to content from \ 25 | MariaDB databases on behalf of the clients." 26 | 27 | LABEL summary="${SUMMARY}" \ 28 | description="${DESCRIPTION}" \ 29 | io.k8s.description="${DESCRIPTION}" \ 30 | io.k8s.display-name="MariaDB ${MYSQL_VERSION}" \ 31 | io.openshift.expose-services="3306:mysql" \ 32 | io.openshift.tags="database,mysql,${NAME},${NAME}${MYSQL_SHORT_VERSION},${NAME}-${MYSQL_SHORT_VERSION}" \ 33 | com.redhat.component="${NAME}-${MYSQL_SHORT_VERSION}-container" \ 34 | name="sclorg/${NAME}-${MYSQL_SHORT_VERSION}-c9s" \ 35 | version="1" \ 36 | com.redhat.license_terms="https://www.redhat.com/en/about/red-hat-end-user-license-agreements#rhel" \ 37 | usage="podman run -d -e MYSQL_USER=user -e MYSQL_PASSWORD=pass -e MYSQL_DATABASE=db -p 3306:3306 quay.io/sclorg/${NAME}-${MYSQL_SHORT_VERSION}-c9s" \ 38 | maintainer="SoftwareCollections.org " 39 | 40 | EXPOSE 3306 41 | 42 | # This image must forever use UID 27 for mysql user so our volumes are 43 | # safe in the future. This should *never* change, the last test is there 44 | # to make sure of that. 45 | RUN yum -y module enable ${NAME}:${MYSQL_VERSION} && \ 46 | INSTALL_PKGS="policycoreutils rsync tar gettext hostname groff-base ${NAME}-server" && \ 47 | yum install -y --setopt=tsflags=nodocs ${INSTALL_PKGS} && \ 48 | rpm -V ${INSTALL_PKGS} && \ 49 | /usr/libexec/mysqld -V | grep -qe "${MYSQL_VERSION}\." && echo "Found VERSION ${MYSQL_VERSION}" && \ 50 | yum -y clean all --enablerepo='*' && \ 51 | mkdir -p ${HOME}/data && chown -R mysql:root ${HOME} && \ 52 | test "$(id mysql)" = "uid=27(mysql) gid=27(mysql) groups=27(mysql)" 53 | 54 | # Get prefix path and path to scripts rather than hard-code them in scripts 55 | ENV CONTAINER_SCRIPTS_PATH=/usr/share/container-scripts/mysql \ 56 | MYSQL_PREFIX=/usr 57 | 58 | COPY ${MYSQL_VERSION}/root-common / 59 | COPY ${MYSQL_VERSION}/s2i-common/bin/ ${STI_SCRIPTS_PATH} 60 | COPY ${MYSQL_VERSION}/root / 61 | 62 | # Hard links are not supported in Testing Farm approach during sync to guest 63 | # operation system. Therefore tests are failing on error 64 | # /usr/libexec/s2i/run no such file or directory 65 | RUN ln -s /usr/bin/run-mysqld ${STI_SCRIPTS_PATH}/run 66 | 67 | # this is needed due to issues with squash 68 | # when this directory gets rm'd by the container-setup 69 | # script. 70 | # Also reset permissions of filesystem to default values 71 | RUN rm -rf /etc/my.cnf.d/* && \ 72 | /usr/libexec/container-setup && \ 73 | rpm-file-permissions 74 | 75 | USER 27 76 | 77 | ENTRYPOINT ["container-entrypoint"] 78 | CMD ["run-mysqld"] 79 | -------------------------------------------------------------------------------- /10.11/Dockerfile.c9s: -------------------------------------------------------------------------------- 1 | FROM quay.io/sclorg/s2i-core-c9s:c9s 2 | 3 | # MariaDB image for OpenShift. 4 | # 5 | # Volumes: 6 | # * /var/lib/mysql/data - Datastore for MariaDB 7 | # Environment: 8 | # * $MYSQL_USER - Database user name 9 | # * $MYSQL_PASSWORD - User's password 10 | # * $MYSQL_DATABASE - Name of the database to create 11 | # * $MYSQL_ROOT_PASSWORD (Optional) - Password for the 'root' MySQL account 12 | 13 | # Standalone ENV call so these values can be re-used in the other ENV calls 14 | ENV MYSQL_VERSION=10.11 \ 15 | MYSQL_SHORT_VERSION=1011 16 | 17 | ENV VERSION="${MYSQL_VERSION}" \ 18 | APP_DATA=/opt/app-root/src \ 19 | HOME=/var/lib/mysql \ 20 | NAME=mariadb \ 21 | SUMMARY="MariaDB ${MYSQL_VERSION} SQL database server" \ 22 | DESCRIPTION="MariaDB is a multi-user, multi-threaded SQL database server. The container \ 23 | image provides a containerized packaging of the MariaDB mysqld daemon and client application. \ 24 | The mysqld server daemon accepts connections from clients and provides access to content from \ 25 | MariaDB databases on behalf of the clients." 26 | 27 | LABEL summary="${SUMMARY}" \ 28 | description="${DESCRIPTION}" \ 29 | io.k8s.description="${DESCRIPTION}" \ 30 | io.k8s.display-name="MariaDB ${MYSQL_VERSION}" \ 31 | io.openshift.expose-services="3306:mysql" \ 32 | io.openshift.tags="database,mysql,${NAME},${NAME}${MYSQL_SHORT_VERSION},${NAME}-${MYSQL_SHORT_VERSION}" \ 33 | com.redhat.component="${NAME}-${MYSQL_SHORT_VERSION}-container" \ 34 | name="sclorg/${NAME}-${MYSQL_SHORT_VERSION}-c9s" \ 35 | version="1" \ 36 | com.redhat.license_terms="https://www.redhat.com/en/about/red-hat-end-user-license-agreements#rhel" \ 37 | usage="podman run -d -e MYSQL_USER=user -e MYSQL_PASSWORD=pass -e MYSQL_DATABASE=db -p 3306:3306 quay.io/sclorg/${NAME}-${MYSQL_SHORT_VERSION}-c9s" \ 38 | maintainer="SoftwareCollections.org " 39 | 40 | EXPOSE 3306 41 | 42 | # This image must forever use UID 27 for mysql user so our volumes are 43 | # safe in the future. This should *never* change, the last test is there 44 | # to make sure of that. 45 | RUN yum -y module enable ${NAME}:${MYSQL_VERSION} && \ 46 | INSTALL_PKGS="policycoreutils rsync tar gettext hostname groff-base ${NAME}-server" && \ 47 | yum install -y --setopt=tsflags=nodocs ${INSTALL_PKGS} && \ 48 | rpm -V ${INSTALL_PKGS} && \ 49 | /usr/libexec/mysqld -V | grep -qe "${MYSQL_VERSION}\." && echo "Found VERSION ${MYSQL_VERSION}" && \ 50 | yum -y clean all --enablerepo='*' && \ 51 | mkdir -p ${HOME}/data && chown -R mysql:root ${HOME} && \ 52 | test "$(id mysql)" = "uid=27(mysql) gid=27(mysql) groups=27(mysql)" 53 | 54 | # Get prefix path and path to scripts rather than hard-code them in scripts 55 | ENV CONTAINER_SCRIPTS_PATH=/usr/share/container-scripts/mysql \ 56 | MYSQL_PREFIX=/usr 57 | 58 | COPY ${MYSQL_VERSION}/root-common / 59 | COPY ${MYSQL_VERSION}/s2i-common/bin/ ${STI_SCRIPTS_PATH} 60 | COPY ${MYSQL_VERSION}/root / 61 | 62 | # Hard links are not supported in Testing Farm approach during sync to guest 63 | # operation system. Therefore tests are failing on error 64 | # /usr/libexec/s2i/run no such file or directory 65 | RUN ln -s /usr/bin/run-mysqld ${STI_SCRIPTS_PATH}/run 66 | 67 | # this is needed due to issues with squash 68 | # when this directory gets rm'd by the container-setup 69 | # script. 70 | # Also reset permissions of filesystem to default values 71 | RUN rm -rf /etc/my.cnf.d/* && \ 72 | /usr/libexec/container-setup && \ 73 | rpm-file-permissions 74 | 75 | USER 27 76 | 77 | ENTRYPOINT ["container-entrypoint"] 78 | CMD ["run-mysqld"] 79 | -------------------------------------------------------------------------------- /root-common/usr/share/container-scripts/mysql/pre-init/20-validate-variables.sh: -------------------------------------------------------------------------------- 1 | function usage() { 2 | [ $# == 1 ] && echo "error: $1" 3 | echo "You must either specify the following environment variables:" 4 | echo " MYSQL_USER (regex: '$mysql_identifier_regex')" 5 | echo " MYSQL_PASSWORD (regex: '$mysql_password_regex')" 6 | echo " MYSQL_DATABASE (regex: '$mysql_identifier_regex')" 7 | echo "Or the following environment variable:" 8 | echo " MYSQL_ROOT_PASSWORD (regex: '$mysql_password_regex')" 9 | echo "Or both." 10 | echo "Optional Settings:" 11 | echo " MYSQL_LOWER_CASE_TABLE_NAMES (default: 0)" 12 | echo " MYSQL_LOG_QUERIES_ENABLED (default: 0)" 13 | echo " MYSQL_MAX_CONNECTIONS (default: 151)" 14 | echo " MYSQL_FT_MIN_WORD_LEN (default: 4)" 15 | echo " MYSQL_FT_MAX_WORD_LEN (default: 20)" 16 | echo " MYSQL_AIO (default: 1)" 17 | echo " MYSQL_KEY_BUFFER_SIZE (default: 32M or 10% of available memory)" 18 | echo " MYSQL_MAX_ALLOWED_PACKET (default: 200M)" 19 | echo " MYSQL_TABLE_OPEN_CACHE (default: 400)" 20 | echo " MYSQL_SORT_BUFFER_SIZE (default: 256K)" 21 | echo " MYSQL_READ_BUFFER_SIZE (default: 8M or 5% of available memory)" 22 | echo " MYSQL_INNODB_BUFFER_POOL_SIZE (default: 32M or 50% of available memory)" 23 | echo " MYSQL_INNODB_LOG_FILE_SIZE (default: 8M or 15% of available memory)" 24 | echo " MYSQL_INNODB_LOG_BUFFER_SIZE (default: 8M or 15% of available memory)" 25 | echo 26 | echo "For more information, see https://github.com/sclorg/mariadb-container" 27 | exit 1 28 | } 29 | 30 | function validate_variables() { 31 | # Check basic sanity of specified variables 32 | if [[ -v MYSQL_USER && -v MYSQL_PASSWORD ]]; then 33 | [[ "$MYSQL_USER" =~ $mysql_identifier_regex ]] || usage "Invalid MySQL username" 34 | [ ${#MYSQL_USER} -le 80 ] || usage "MySQL username too long (maximum 80 characters)" 35 | [[ "$MYSQL_PASSWORD" =~ $mysql_password_regex ]] || usage "Invalid password" 36 | user_specified=1 37 | fi 38 | 39 | if [ -v MYSQL_ROOT_PASSWORD ]; then 40 | [[ "$MYSQL_ROOT_PASSWORD" =~ $mysql_password_regex ]] || usage "Invalid root password" 41 | root_specified=1 42 | fi 43 | 44 | # If MYSQL_USER == "root", we have a special case 45 | if [[ "${user_specified:-0}" == "1" && "$MYSQL_USER" == "root" ]]; then 46 | if [[ "${root_specified:-0}" == "1" ]]; then 47 | usage "When setting MYSQL_USER to 'root' you can only set either MYSQL_PASSWORD or MYSQL_ROOT_PASSWORD" 48 | fi 49 | # We will now behave as if MYSQL_USER was not specified 50 | export MYSQL_ROOT_PASSWORD="$MYSQL_PASSWORD" 51 | export -n MYSQL_USER 52 | export -n MYSQL_PASSWORD 53 | user_specified=0 54 | root_specified=1 55 | fi 56 | 57 | # Either combination of user/pass/db or root password is ok 58 | if [[ "${user_specified:-0}" == "0" && "${root_specified:-0}" == "0" ]]; then 59 | usage 60 | fi 61 | 62 | # If the root user is not specified, database name is required 63 | if [[ "${root_specified:-0}" == "0" ]]; then 64 | [ -v MYSQL_DATABASE ] || usage "You need to specify database name or root password" 65 | fi 66 | 67 | if [ -v MYSQL_DATABASE ]; then 68 | [[ "$MYSQL_DATABASE" =~ $mysql_identifier_regex ]] || usage "Invalid database name" 69 | [ ${#MYSQL_DATABASE} -le 64 ] || usage "Database name too long (maximum 64 characters)" 70 | fi 71 | 72 | # Specifically check of incomplete specification 73 | if [[ -v MYSQL_USER || -v MYSQL_PASSWORD || -v MYSQL_DATABASE ]] && \ 74 | [[ "${user_specified:-0}" == "0" ]]; then 75 | usage 76 | fi 77 | } 78 | 79 | if ! [ -v MYSQL_RUNNING_AS_SLAVE ] ; then 80 | validate_variables 81 | fi 82 | -------------------------------------------------------------------------------- /imagestreams/mariadb-centos.json: -------------------------------------------------------------------------------- 1 | { 2 | "kind": "ImageStream", 3 | "apiVersion": "image.openshift.io/v1", 4 | "metadata": { 5 | "name": "mariadb", 6 | "annotations": { 7 | "openshift.io/display-name": "MariaDB" 8 | } 9 | }, 10 | "spec": { 11 | "tags": [ 12 | { 13 | "name": "10.5-el9", 14 | "annotations": { 15 | "openshift.io/display-name": "MariaDB 10.5 (CentOS Stream 9)", 16 | "openshift.io/provider-display-name": "Red Hat, Inc.", 17 | "description": "Provides a MariaDB 10.5 database on CentOS Stream 9. For more information about using this database image, including OpenShift considerations, see https://github.com/sclorg/mariadb-container/tree/master/10.5/README.md.", 18 | "iconClass": "icon-mariadb", 19 | "tags": "database,mariadb", 20 | "version": "10.5" 21 | }, 22 | "from": { 23 | "kind": "DockerImage", 24 | "name": "quay.io/sclorg/mariadb-105-c9s:latest" 25 | }, 26 | "referencePolicy": { 27 | "type": "Local" 28 | } 29 | }, 30 | { 31 | "name": "10.11-el9", 32 | "annotations": { 33 | "openshift.io/display-name": "MariaDB 10.11 (CentOS Stream 9)", 34 | "openshift.io/provider-display-name": "Red Hat, Inc.", 35 | "description": "Provides a MariaDB 10.11 database on CentOS Stream 9. For more information about using this database image, including OpenShift considerations, see https://github.com/sclorg/mariadb-container/tree/master/10.11/README.md.", 36 | "iconClass": "icon-mariadb", 37 | "tags": "database,mariadb", 38 | "version": "10.11" 39 | }, 40 | "from": { 41 | "kind": "DockerImage", 42 | "name": "quay.io/sclorg/mariadb-1011-c9s:latest" 43 | }, 44 | "referencePolicy": { 45 | "type": "Local" 46 | } 47 | }, 48 | { 49 | "name": "10.11-el10", 50 | "annotations": { 51 | "openshift.io/display-name": "MariaDB 10.11 (CentOS Stream 10)", 52 | "openshift.io/provider-display-name": "Red Hat, Inc.", 53 | "description": "Provides a MariaDB 10.11 database on CentOS Stream 10. For more information about using this database image, including OpenShift considerations, see https://github.com/sclorg/mariadb-container/tree/master/10.11/README.md.", 54 | "iconClass": "icon-mariadb", 55 | "tags": "database,mariadb", 56 | "version": "10.11" 57 | }, 58 | "from": { 59 | "kind": "DockerImage", 60 | "name": "quay.io/sclorg/mariadb-1011-c10s:latest" 61 | }, 62 | "referencePolicy": { 63 | "type": "Local" 64 | } 65 | }, 66 | { 67 | "name": "latest", 68 | "annotations": { 69 | "openshift.io/display-name": "MariaDB 10.11 (Latest)", 70 | "openshift.io/provider-display-name": "Red Hat, Inc.", 71 | "description": "Provides a MariaDB 10.11 database on CentOS Stream 9. For more information about using this database image, including OpenShift considerations, see https://github.com/sclorg/mariadb-container/tree/master/10.11/README.md.\n\nWARNING: By selecting this tag, your application will automatically update to use the latest version available on OpenShift, including major version updates.\n", 72 | "iconClass": "icon-mariadb", 73 | "tags": "database,mariadb", 74 | "version": "10.11" 75 | }, 76 | "from": { 77 | "kind": "ImageStreamTag", 78 | "name": "10.11-el9" 79 | }, 80 | "referencePolicy": { 81 | "type": "Local" 82 | } 83 | } 84 | ] 85 | } 86 | } 87 | -------------------------------------------------------------------------------- /10.11/Dockerfile.fedora: -------------------------------------------------------------------------------- 1 | FROM quay.io/fedora/s2i-core:42 2 | 3 | # MariaDB image for OpenShift. 4 | # 5 | # Volumes: 6 | # * /var/lib/mysql/data - Datastore for MariaDB 7 | # Environment: 8 | # * $MYSQL_USER - Database user name 9 | # * $MYSQL_PASSWORD - User's password 10 | # * $MYSQL_DATABASE - Name of the database to create 11 | # * $MYSQL_ROOT_PASSWORD (Optional) - Password for the 'root' MySQL account 12 | 13 | # Standalone ENV call so these values can be re-used in the other ENV calls 14 | ENV MYSQL_VERSION=10.11 \ 15 | MYSQL_SHORT_VERSION=1011 16 | 17 | ENV VERSION="${MYSQL_VERSION}" \ 18 | APP_DATA=/opt/app-root/src \ 19 | HOME=/var/lib/mysql \ 20 | NAME=mariadb \ 21 | ARCH=x86_64 \ 22 | SUMMARY="MariaDB ${MYSQL_VERSION} SQL database server" \ 23 | DESCRIPTION="MariaDB is a multi-user, multi-threaded SQL database server. The container \ 24 | image provides a containerized packaging of the MariaDB mysqld daemon and client application. \ 25 | The mysqld server daemon accepts connections from clients and provides access to content from \ 26 | MariaDB databases on behalf of the clients." 27 | 28 | LABEL summary="${SUMMARY}" \ 29 | description="${DESCRIPTION}" \ 30 | io.k8s.description="${DESCRIPTION}" \ 31 | io.k8s.display-name="MariaDB ${MYSQL_VERSION}" \ 32 | io.openshift.expose-services="3306:mysql" \ 33 | io.openshift.tags="database,mysql,${NAME},${NAME}${MYSQL_SHORT_VERSION},${NAME}-${MYSQL_SHORT_VERSION}" \ 34 | com.redhat.component="${NAME}" \ 35 | name="fedora/${NAME}-${MYSQL_SHORT_VERSION}" \ 36 | version="${MYSQL_VERSION}" \ 37 | usage="podman run -d -e MYSQL_USER=user -e MYSQL_PASSWORD=pass -e MYSQL_DATABASE=db -p 3306:3306 quay.io/fedora/${NAME}-${MYSQL_SHORT_VERSION}" \ 38 | maintainer="SoftwareCollections.org " 39 | 40 | EXPOSE 3306 41 | 42 | # This image must forever use UID 27 for mysql user so our volumes are safe in the future. This should *never* change. 43 | # Instead of relying on the DB server package, we will do the setup ourselves before any package is installed 44 | RUN /usr/sbin/groupadd -g 27 -o -r mysql && \ 45 | /usr/sbin/useradd -M -N -g mysql -o -r -d ${HOME} -s /sbin/nologin -c "MySQL Server" -u 27 mysql && \ 46 | test "$(id mysql)" = "uid=27(mysql) gid=27(mysql) groups=27(mysql)" && \ 47 | INSTALL_PKGS="policycoreutils rsync tar gettext hostname groff-base" && \ 48 | dnf install -y --setopt=tsflags=nodocs --setopt=install_weak_deps=False ${INSTALL_PKGS} ${NAME}${MYSQL_VERSION}-server && \ 49 | /usr/libexec/mysqld -V | grep -qe "${MYSQL_VERSION}\." && echo "Found VERSION ${MYSQL_VERSION}" && \ 50 | dnf -y clean all --enablerepo='*' && \ 51 | mkdir -p ${HOME}/data && chown -R mysql:root ${HOME} && \ 52 | test "$(id mysql)" = "uid=27(mysql) gid=27(mysql) groups=27(mysql)" 53 | 54 | # Get prefix path and path to scripts rather than hard-code them in scripts 55 | ENV CONTAINER_SCRIPTS_PATH=/usr/share/container-scripts/mysql \ 56 | MYSQL_PREFIX=/usr 57 | 58 | COPY ${MYSQL_VERSION}/root-common / 59 | COPY ${MYSQL_VERSION}/s2i-common/bin/ ${STI_SCRIPTS_PATH} 60 | COPY ${MYSQL_VERSION}/root / 61 | 62 | # Hard links are not supported in Testing Farm approach during sync to guest 63 | # operation system. Therefore tests are failing on error 64 | # /usr/libexec/s2i/run no such file or directory 65 | RUN ln -s /usr/bin/run-mysqld ${STI_SCRIPTS_PATH}/run 66 | 67 | # this is needed due to issues with squash 68 | # when this directory gets rm'd by the container-setup 69 | # script. 70 | # Also reset permissions of filesystem to default values 71 | RUN rm -rf /etc/my.cnf.d/* && \ 72 | /usr/libexec/container-setup && \ 73 | rpm-file-permissions 74 | 75 | USER 27 76 | 77 | ENTRYPOINT ["container-entrypoint"] 78 | CMD ["run-mysqld"] 79 | -------------------------------------------------------------------------------- /11.8/Dockerfile.fedora: -------------------------------------------------------------------------------- 1 | FROM quay.io/fedora/s2i-core:42 2 | 3 | # MariaDB image for OpenShift. 4 | # 5 | # Volumes: 6 | # * /var/lib/mysql/data - Datastore for MariaDB 7 | # Environment: 8 | # * $MYSQL_USER - Database user name 9 | # * $MYSQL_PASSWORD - User's password 10 | # * $MYSQL_DATABASE - Name of the database to create 11 | # * $MYSQL_ROOT_PASSWORD (Optional) - Password for the 'root' MySQL account 12 | 13 | # Standalone ENV call so these values can be re-used in the other ENV calls 14 | ENV MYSQL_VERSION=11.8 \ 15 | MYSQL_SHORT_VERSION=118 16 | 17 | ENV VERSION="${MYSQL_VERSION}" \ 18 | APP_DATA=/opt/app-root/src \ 19 | HOME=/var/lib/mysql \ 20 | NAME=mariadb \ 21 | ARCH=x86_64 \ 22 | SUMMARY="MariaDB ${MYSQL_VERSION} SQL database server" \ 23 | DESCRIPTION="MariaDB is a multi-user, multi-threaded SQL database server. The container \ 24 | image provides a containerized packaging of the MariaDB mysqld daemon and client application. \ 25 | The mysqld server daemon accepts connections from clients and provides access to content from \ 26 | MariaDB databases on behalf of the clients." 27 | 28 | LABEL summary="${SUMMARY}" \ 29 | description="${DESCRIPTION}" \ 30 | io.k8s.description="${DESCRIPTION}" \ 31 | io.k8s.display-name="MariaDB ${MYSQL_VERSION}" \ 32 | io.openshift.expose-services="3306:mysql" \ 33 | io.openshift.tags="database,mysql,${NAME},${NAME}${MYSQL_SHORT_VERSION},${NAME}-${MYSQL_SHORT_VERSION}" \ 34 | com.redhat.component="${NAME}" \ 35 | name="fedora/${NAME}-${MYSQL_SHORT_VERSION}" \ 36 | version="${MYSQL_VERSION}" \ 37 | usage="podman run -d -e MYSQL_USER=user -e MYSQL_PASSWORD=pass -e MYSQL_DATABASE=db -p 3306:3306 quay.io/fedora/${NAME}-${MYSQL_SHORT_VERSION}" \ 38 | maintainer="SoftwareCollections.org " 39 | 40 | EXPOSE 3306 41 | 42 | # This image must forever use UID 27 for mysql user so our volumes are safe in the future. This should *never* change. 43 | # Instead of relying on the DB server package, we will do the setup ourselves before any package is installed 44 | RUN /usr/sbin/groupadd -g 27 -o -r mysql && \ 45 | /usr/sbin/useradd -M -N -g mysql -o -r -d ${HOME} -s /sbin/nologin -c "MySQL Server" -u 27 mysql && \ 46 | test "$(id mysql)" = "uid=27(mysql) gid=27(mysql) groups=27(mysql)" && \ 47 | INSTALL_PKGS="policycoreutils rsync tar gettext hostname groff-base" && \ 48 | dnf install -y --setopt=tsflags=nodocs --setopt=install_weak_deps=False ${INSTALL_PKGS} ${NAME}${MYSQL_VERSION}-server && \ 49 | /usr/libexec/mysqld -V | grep -qe "${MYSQL_VERSION}\." && echo "Found VERSION ${MYSQL_VERSION}" && \ 50 | dnf -y clean all --enablerepo='*' && \ 51 | mkdir -p ${HOME}/data && chown -R mysql:root ${HOME} && \ 52 | test "$(id mysql)" = "uid=27(mysql) gid=27(mysql) groups=27(mysql)" 53 | 54 | # Get prefix path and path to scripts rather than hard-code them in scripts 55 | ENV CONTAINER_SCRIPTS_PATH=/usr/share/container-scripts/mysql \ 56 | MYSQL_PREFIX=/usr 57 | 58 | 59 | COPY ${MYSQL_VERSION}/root-common / 60 | COPY ${MYSQL_VERSION}/s2i-common/bin/ ${STI_SCRIPTS_PATH} 61 | COPY ${MYSQL_VERSION}/root / 62 | 63 | # Hard links are not supported in Testing Farm approach during sync to guest 64 | # operation system. Therefore tests are failing on error 65 | # /usr/libexec/s2i/run no such file or directory 66 | RUN ln -s /usr/bin/run-mysqld ${STI_SCRIPTS_PATH}/run 67 | 68 | # this is needed due to issues with squash 69 | # when this directory gets rm'd by the container-setup 70 | # script. 71 | # Also reset permissions of filesystem to default values 72 | RUN rm -rf /etc/my.cnf.d/* && \ 73 | /usr/libexec/container-setup && \ 74 | rpm-file-permissions 75 | 76 | USER 27 77 | 78 | ENTRYPOINT ["container-entrypoint"] 79 | CMD ["run-mysqld"] 80 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | MariaDB SQL Database Server Docker Image 2 | ======================================== 3 | 4 | [![Build and push images to Quay.io registry](https://github.com/sclorg/mariadb-container/actions/workflows/build-and-push.yml/badge.svg)](https://github.com/sclorg/mariadb-container/actions/workflows/build-and-push.yml) 5 | 6 | This repository contains Dockerfiles for MariaDB images for OpenShift and general usage. 7 | Users can choose between RHEL, Fedora and CentOS Stream based images. 8 | 9 | MariaDB container is very similar to the MySQL container available at 10 | [https://github.com/sclorg/mysql-container](https://github.com/sclorg/mysql-container). 11 | 12 | For more information about using these images with OpenShift, please see the 13 | official [OpenShift Documentation](https://docs.okd.io/latest/using_images/db_images/mariadb.html). 14 | 15 | For more information about contributing, see 16 | [the Contribution Guidelines](https://github.com/sclorg/welcome/blob/master/contribution.md). 17 | For more information about concepts used in these podman images, see the 18 | [Landing page](https://github.com/sclorg/welcome). 19 | 20 | 21 | Versions 22 | --------------- 23 | 26 | ||CentOS Stream 9|CentOS Stream 10|Fedora|RHEL 8|RHEL 9|RHEL 10| 27 | |:--|:--:|:--:|:--:|:--:|:--:|:--:| 28 | |10.3||||
`registry.redhat.io/rhel8/mariadb-103`
||| 29 | |10.5|
`quay.io/sclorg/mariadb-105-c9s`
|||
`registry.redhat.io/rhel8/mariadb-105`
|
`registry.redhat.io/rhel9/mariadb-105`
|| 30 | |10.11|
`quay.io/sclorg/mariadb-1011-c9s`
|
`quay.io/sclorg/mariadb-1011-c10s`
|
`quay.io/fedora/mariadb-1011`
|
`registry.redhat.io/rhel8/mariadb-1011`
|
`registry.redhat.io/rhel9/mariadb-1011`
|
`registry.redhat.io/rhel10/mariadb-1011`
| 31 | |11.8|||
`quay.io/fedora/mariadb-118`
|||| 32 | 35 | 36 | Installation 37 | ---------------------- 38 | Choose either the CentOS Stream or RHEL based image: 39 | 40 | * **RHEL based image** 41 | 42 | These images are available in the [Red Hat Container Catalog](https://catalog.redhat.com/en/search?searchType=containers). 43 | To download it, run: 44 | 45 | ``` 46 | $ podman pull registry.redhat.io/rhel10/mariadb-1011 47 | ``` 48 | 49 | To build a RHEL10 based MariaDB image, you need to run Docker build on a properly 50 | subscribed RHEL machine. 51 | 52 | ``` 53 | $ git clone --recursive https://github.com/sclorg/mariadb-container.git 54 | $ cd mariadb-container 55 | $ git submodule update --init 56 | $ make build TARGET=rhel10 VERSIONS=10.11 57 | ``` 58 | 59 | * **CentOS Stream based image** 60 | 61 | This image is available on [Quay.io](https://quay.io/search). 62 | To download it, run: 63 | 64 | ``` 65 | $ podman pull quay.io/sclorg/mariadb-1011-c10s 66 | ``` 67 | 68 | To build a CentOS Stream based MariaDB image from scratch, run: 69 | 70 | ``` 71 | $ git clone --recursive https://github.com/sclorg/mariadb-container.git 72 | $ cd mariadb-container 73 | $ git submodule update --init 74 | $ make build TARGET=c10s VERSIONS=10.11 75 | ``` 76 | 77 | For using other versions of MariaDB, just replace the `10.11` value with a particular version 78 | in the commands above. 79 | 80 | Note: while the installation steps are calling `podman`, you can replace any such calls by `docker` with the same arguments. 81 | 82 | **Notice: By omitting the `VERSIONS` parameter, the build/test action will be performed 83 | on all provided versions of MariaDB, which must be specified in `VERSIONS` variable. 84 | This variable must be set to a list with possible versions (subdirectories).** 85 | 86 | 87 | Usage 88 | --------------------------------- 89 | 90 | For information about usage of Dockerfile for MariaDB 10.3, 91 | see [usage documentation](10.3). 92 | 93 | For information about usage of Dockerfile for MariaDB 10.5, 94 | see [usage documentation](10.5). 95 | 96 | For information about usage of Dockerfile for MariaDB 10.11, 97 | see [usage documentation](10.11). 98 | 99 | Testing 100 | --------------------------------- 101 | 102 | This repository also provides a test framework, which checks basic functionality 103 | of the MariaDB image. 104 | 105 | Users can choose between testing MariaDB based on a RHEL or CentOS Stream image. 106 | 107 | * **RHEL based image** 108 | 109 | To test a RHEL10 based MariaDB image, you need to run the test on a properly 110 | subscribed RHEL machine. 111 | 112 | ``` 113 | $ git clone --recursive https://github.com/sclorg/mariadb-container.git 114 | $ cd mariadb-container 115 | $ git submodule update --init 116 | $ make test TARGET=rhel10 VERSIONS=10.11 117 | ``` 118 | 119 | * **CentOS Stream based image** 120 | 121 | ``` 122 | $ git clone --recursive https://github.com/sclorg/mariadb-container.git 123 | $ cd mariadb-container 124 | $ git submodule update --init 125 | $ make test TARGET=c10s VERSIONS=10.11 126 | ``` 127 | 128 | For using other versions of MariaDB, just replace the `10.11` value with a particular version 129 | in the commands above. 130 | 131 | **Notice: By omitting the `VERSIONS` parameter, the build/test action will be performed 132 | on all provided versions of MariaDB, which must be specified in `VERSIONS` variable. 133 | This variable must be set to a list with possible versions (subdirectories).** 134 | -------------------------------------------------------------------------------- /imagestreams/mariadb-rhel.json: -------------------------------------------------------------------------------- 1 | { 2 | "kind": "ImageStream", 3 | "apiVersion": "image.openshift.io/v1", 4 | "metadata": { 5 | "name": "mariadb", 6 | "annotations": { 7 | "openshift.io/display-name": "MariaDB" 8 | } 9 | }, 10 | "spec": { 11 | "tags": [ 12 | { 13 | "name": "10.3-el8", 14 | "annotations": { 15 | "openshift.io/display-name": "MariaDB 10.3 (RHEL 8)", 16 | "openshift.io/provider-display-name": "Red Hat, Inc.", 17 | "description": "Provides a MariaDB 10.3 database on RHEL 8. For more information about using this database image, including OpenShift considerations, see https://github.com/sclorg/mariadb-container/tree/master/10.3/README.md.", 18 | "iconClass": "icon-mariadb", 19 | "tags": "database,mariadb", 20 | "version": "10.3" 21 | }, 22 | "from": { 23 | "kind": "DockerImage", 24 | "name": "registry.redhat.io/rhel8/mariadb-103:latest" 25 | }, 26 | "referencePolicy": { 27 | "type": "Local" 28 | } 29 | }, 30 | { 31 | "name": "10.5-el8", 32 | "annotations": { 33 | "openshift.io/display-name": "MariaDB 10.5 (RHEL 8)", 34 | "openshift.io/provider-display-name": "Red Hat, Inc.", 35 | "description": "Provides a MariaDB 10.5 database on RHEL 8. For more information about using this database image, including OpenShift considerations, see https://github.com/sclorg/mariadb-container/tree/master/10.5/README.md.", 36 | "iconClass": "icon-mariadb", 37 | "tags": "database,mariadb", 38 | "version": "10.5" 39 | }, 40 | "from": { 41 | "kind": "DockerImage", 42 | "name": "registry.redhat.io/rhel8/mariadb-105:latest" 43 | }, 44 | "referencePolicy": { 45 | "type": "Local" 46 | } 47 | }, 48 | { 49 | "name": "10.11-el8", 50 | "annotations": { 51 | "openshift.io/display-name": "MariaDB 10.11 (RHEL 8)", 52 | "openshift.io/provider-display-name": "Red Hat, Inc.", 53 | "description": "Provides a MariaDB 10.11 database on RHEL 8. For more information about using this database image, including OpenShift considerations, see https://github.com/sclorg/mariadb-container/tree/master/10.11/README.md.", 54 | "iconClass": "icon-mariadb", 55 | "tags": "database,mariadb", 56 | "version": "10.11" 57 | }, 58 | "from": { 59 | "kind": "DockerImage", 60 | "name": "registry.redhat.io/rhel8/mariadb-1011:latest" 61 | }, 62 | "referencePolicy": { 63 | "type": "Local" 64 | } 65 | }, 66 | { 67 | "name": "10.5-el9", 68 | "annotations": { 69 | "openshift.io/display-name": "MariaDB 10.5 (RHEL 9)", 70 | "openshift.io/provider-display-name": "Red Hat, Inc.", 71 | "description": "Provides a MariaDB 10.5 database on RHEL 9. For more information about using this database image, including OpenShift considerations, see https://github.com/sclorg/mariadb-container/tree/master/10.5/README.md.", 72 | "iconClass": "icon-mariadb", 73 | "tags": "database,mariadb", 74 | "version": "10.5" 75 | }, 76 | "from": { 77 | "kind": "DockerImage", 78 | "name": "registry.redhat.io/rhel9/mariadb-105:latest" 79 | }, 80 | "referencePolicy": { 81 | "type": "Local" 82 | } 83 | }, 84 | { 85 | "name": "10.11-el9", 86 | "annotations": { 87 | "openshift.io/display-name": "MariaDB 10.11 (RHEL 9)", 88 | "openshift.io/provider-display-name": "Red Hat, Inc.", 89 | "description": "Provides a MariaDB 10.11 database on RHEL 9. For more information about using this database image, including OpenShift considerations, see https://github.com/sclorg/mariadb-container/tree/master/10.11/README.md.", 90 | "iconClass": "icon-mariadb", 91 | "tags": "database,mariadb", 92 | "version": "10.11" 93 | }, 94 | "from": { 95 | "kind": "DockerImage", 96 | "name": "registry.redhat.io/rhel9/mariadb-1011:latest" 97 | }, 98 | "referencePolicy": { 99 | "type": "Local" 100 | } 101 | }, 102 | { 103 | "name": "10.11-el10", 104 | "annotations": { 105 | "openshift.io/display-name": "MariaDB 10.11 (RHEL 10)", 106 | "openshift.io/provider-display-name": "Red Hat, Inc.", 107 | "description": "Provides a MariaDB 10.11 database on RHEL 10. For more information about using this database image, including OpenShift considerations, see https://github.com/sclorg/mariadb-container/tree/master/10.11/README.md.", 108 | "iconClass": "icon-mariadb", 109 | "tags": "database,mariadb", 110 | "version": "10.11" 111 | }, 112 | "from": { 113 | "kind": "DockerImage", 114 | "name": "registry.redhat.io/rhel10/mariadb-1011:latest" 115 | }, 116 | "referencePolicy": { 117 | "type": "Local" 118 | } 119 | }, 120 | { 121 | "name": "latest", 122 | "annotations": { 123 | "openshift.io/display-name": "MariaDB 10.11 (Latest)", 124 | "openshift.io/provider-display-name": "Red Hat, Inc.", 125 | "description": "Provides a MariaDB 10.11 database on RHEL 9. For more information about using this database image, including OpenShift considerations, see https://github.com/sclorg/mariadb-container/tree/master/10.11/README.md.\n\nWARNING: By selecting this tag, your application will automatically update to use the latest version available on OpenShift, including major version updates.\n", 126 | "iconClass": "icon-mariadb", 127 | "tags": "database,mariadb", 128 | "version": "10.11" 129 | }, 130 | "from": { 131 | "kind": "ImageStreamTag", 132 | "name": "10.11-el9" 133 | }, 134 | "referencePolicy": { 135 | "type": "Local" 136 | } 137 | } 138 | ] 139 | } 140 | } 141 | -------------------------------------------------------------------------------- /imagestreams/mariadb-rhel-aarch64.json: -------------------------------------------------------------------------------- 1 | { 2 | "kind": "ImageStream", 3 | "apiVersion": "image.openshift.io/v1", 4 | "metadata": { 5 | "name": "mariadb", 6 | "annotations": { 7 | "openshift.io/display-name": "MariaDB" 8 | } 9 | }, 10 | "spec": { 11 | "tags": [ 12 | { 13 | "name": "10.3-el8", 14 | "annotations": { 15 | "openshift.io/display-name": "MariaDB 10.3 (RHEL 8)", 16 | "openshift.io/provider-display-name": "Red Hat, Inc.", 17 | "description": "Provides a MariaDB 10.3 database on RHEL 8. For more information about using this database image, including OpenShift considerations, see https://github.com/sclorg/mariadb-container/tree/master/10.3/README.md.", 18 | "iconClass": "icon-mariadb", 19 | "tags": "database,mariadb", 20 | "version": "10.3" 21 | }, 22 | "from": { 23 | "kind": "DockerImage", 24 | "name": "registry.redhat.io/rhel8/mariadb-103:latest" 25 | }, 26 | "referencePolicy": { 27 | "type": "Local" 28 | } 29 | }, 30 | { 31 | "name": "10.5-el8", 32 | "annotations": { 33 | "openshift.io/display-name": "MariaDB 10.5 (RHEL 8)", 34 | "openshift.io/provider-display-name": "Red Hat, Inc.", 35 | "description": "Provides a MariaDB 10.5 database on RHEL 8. For more information about using this database image, including OpenShift considerations, see https://github.com/sclorg/mariadb-container/tree/master/10.5/README.md.", 36 | "iconClass": "icon-mariadb", 37 | "tags": "database,mariadb", 38 | "version": "10.5" 39 | }, 40 | "from": { 41 | "kind": "DockerImage", 42 | "name": "registry.redhat.io/rhel8/mariadb-105:latest" 43 | }, 44 | "referencePolicy": { 45 | "type": "Local" 46 | } 47 | }, 48 | { 49 | "name": "10.11-el8", 50 | "annotations": { 51 | "openshift.io/display-name": "MariaDB 10.11 (RHEL 8)", 52 | "openshift.io/provider-display-name": "Red Hat, Inc.", 53 | "description": "Provides a MariaDB 10.11 database on RHEL 8. For more information about using this database image, including OpenShift considerations, see https://github.com/sclorg/mariadb-container/tree/master/10.11/README.md.", 54 | "iconClass": "icon-mariadb", 55 | "tags": "database,mariadb", 56 | "version": "10.11" 57 | }, 58 | "from": { 59 | "kind": "DockerImage", 60 | "name": "registry.redhat.io/rhel8/mariadb-1011:latest" 61 | }, 62 | "referencePolicy": { 63 | "type": "Local" 64 | } 65 | }, 66 | { 67 | "name": "10.5-el9", 68 | "annotations": { 69 | "openshift.io/display-name": "MariaDB 10.5 (RHEL 9)", 70 | "openshift.io/provider-display-name": "Red Hat, Inc.", 71 | "description": "Provides a MariaDB 10.5 database on RHEL 9. For more information about using this database image, including OpenShift considerations, see https://github.com/sclorg/mariadb-container/tree/master/10.5/README.md.", 72 | "iconClass": "icon-mariadb", 73 | "tags": "database,mariadb", 74 | "version": "10.5" 75 | }, 76 | "from": { 77 | "kind": "DockerImage", 78 | "name": "registry.redhat.io/rhel9/mariadb-105:latest" 79 | }, 80 | "referencePolicy": { 81 | "type": "Local" 82 | } 83 | }, 84 | { 85 | "name": "10.11-el9", 86 | "annotations": { 87 | "openshift.io/display-name": "MariaDB 10.11 (RHEL 9)", 88 | "openshift.io/provider-display-name": "Red Hat, Inc.", 89 | "description": "Provides a MariaDB 10.11 database on RHEL 9. For more information about using this database image, including OpenShift considerations, see https://github.com/sclorg/mariadb-container/tree/master/10.11/README.md.", 90 | "iconClass": "icon-mariadb", 91 | "tags": "database,mariadb", 92 | "version": "10.11" 93 | }, 94 | "from": { 95 | "kind": "DockerImage", 96 | "name": "registry.redhat.io/rhel9/mariadb-1011:latest" 97 | }, 98 | "referencePolicy": { 99 | "type": "Local" 100 | } 101 | }, 102 | { 103 | "name": "10.11-el10", 104 | "annotations": { 105 | "openshift.io/display-name": "MariaDB 10.11 (RHEL 10)", 106 | "openshift.io/provider-display-name": "Red Hat, Inc.", 107 | "description": "Provides a MariaDB 10.11 database on RHEL 10. For more information about using this database image, including OpenShift considerations, see https://github.com/sclorg/mariadb-container/tree/master/10.11/README.md.", 108 | "iconClass": "icon-mariadb", 109 | "tags": "database,mariadb", 110 | "version": "10.11" 111 | }, 112 | "from": { 113 | "kind": "DockerImage", 114 | "name": "registry.redhat.io/rhel10/mariadb-1011:latest" 115 | }, 116 | "referencePolicy": { 117 | "type": "Local" 118 | } 119 | }, 120 | { 121 | "name": "latest", 122 | "annotations": { 123 | "openshift.io/display-name": "MariaDB 10.11 (Latest)", 124 | "openshift.io/provider-display-name": "Red Hat, Inc.", 125 | "description": "Provides a MariaDB 10.11 database on RHEL 9. For more information about using this database image, including OpenShift considerations, see https://github.com/sclorg/mariadb-container/tree/master/10.11/README.md.\n\nWARNING: By selecting this tag, your application will automatically update to use the latest version available on OpenShift, including major version updates.\n", 126 | "iconClass": "icon-mariadb", 127 | "tags": "database,mariadb", 128 | "version": "10.11" 129 | }, 130 | "from": { 131 | "kind": "ImageStreamTag", 132 | "name": "10.11-el9" 133 | }, 134 | "referencePolicy": { 135 | "type": "Local" 136 | } 137 | } 138 | ] 139 | } 140 | } 141 | -------------------------------------------------------------------------------- /root-common/usr/share/container-scripts/mysql/init/40-datadir-action.sh: -------------------------------------------------------------------------------- 1 | upstream_upgrade_info() { 2 | echo -n "For upstream documentation about upgrading, see: " 3 | case ${MYSQL_VERSION} in 4 | 10.3) echo "https://mariadb.com/docs/server/server-management/install-and-upgrade-mariadb/upgrading/mariadb-community-server-upgrade-paths/upgrading-to-unmaintained-mariadb-releases/upgrading-from-mariadb-102-to-mariadb-103" ;; 5 | 10.5) echo "https://mariadb.com/docs/server/server-management/install-and-upgrade-mariadb/upgrading/mariadb-community-server-upgrade-paths/upgrading-to-unmaintained-mariadb-releases/upgrading-from-mariadb-103-to-mariadb-104" 6 | echo "https://mariadb.com/docs/server/server-management/install-and-upgrade-mariadb/upgrading/mariadb-community-server-upgrade-paths/upgrading-to-unmaintained-mariadb-releases/upgrading-from-mariadb-10-4-to-mariadb-10-5" ;; 7 | 10.11) echo "https://mariadb.com/docs/server/server-management/install-and-upgrade-mariadb/upgrading/mariadb-community-server-upgrade-paths/upgrading-from-mariadb-10-5-to-mariadb-10-6" 8 | echo "https://mariadb.com/docs/server/server-management/install-and-upgrade-mariadb/upgrading/mariadb-community-server-upgrade-paths/upgrading-from-mariadb-10-6-to-mariadb-10-11" ;; 9 | # TODO: Uncomment when 11.8 is released 10 | # 11.8) echo "https://mariadb.com/docs/server/server-management/install-and-upgrade-mariadb/upgrading/mariadb-community-server-upgrade-paths/upgrading-from-mariadb-10-11-to-mariadb-11-4" 11 | # echo "https://mariadb.com/docs/server/server-management/install-and-upgrade-mariadb/upgrading/mariadb-community-server-upgrade-paths/upgrading-from-mariadb-11-4-to-mariadb-11-8" ;; 12 | *) echo "Unexpected or unsupported version '${MYSQL_VERSION}'" ; return 1 ;; 13 | esac 14 | } 15 | 16 | check_datadir_version() { 17 | local datadir="$1" 18 | local datadir_version=$(get_datadir_version "$datadir") 19 | local mysqld_version=$(mysqld_compat_version) 20 | local datadir_version_dot=$(number2version "${datadir_version}") 21 | local mysqld_version_dot=$(number2version "${mysqld_version}") 22 | 23 | for datadir_action in ${MYSQL_DATADIR_ACTION//,/ } ; do 24 | log_info "Running datadir action: ${datadir_action}" 25 | case ${datadir_action} in 26 | upgrade-auto|upgrade-warn) 27 | if [ -z "${datadir_version}" ] || [ "${datadir_version}" -eq 0 ] ; then 28 | # Writing the info file, since historically it was not written 29 | log_warn "Version of the data could not be determined."\ 30 | "It is because the file mysql_upgrade_info is missing in the data directory, which"\ 31 | "is most probably because it was not created when initialization of data directory."\ 32 | "In order to allow seamless updates to the next higher version in the future,"\ 33 | "the file mysql_upgrade_info will be created."\ 34 | "If the data directory was created with a different version than ${mysqld_version_dot},"\ 35 | "it is required to run this container with the MYSQL_DATADIR_ACTION environment variable"\ 36 | "set to 'force', or run 'mysql_upgrade' utility manually; the mysql_upgrade tool"\ 37 | "checks the tables and creates such a file as well. $(upstream_upgrade_info)" 38 | write_mysql_upgrade_info_file "${MYSQL_DATADIR}" 39 | continue 40 | # This is currently a dead-code, but should be enabled after the mysql_upgrade_info 41 | # file gets to the deployments (after few months most of the deployments should already have the file) 42 | log_warn "Version of the data could not be determined."\ 43 | "Running such a container is risky."\ 44 | "The current daemon version is ${mysqld_version_dot}."\ 45 | "If you are not sure whether the data directory is compatible with the current"\ 46 | "version ${mysqld_version_dot}, restore the data from a back-up."\ 47 | "If restoring from a back-up is not possible, create a file 'mysql_upgrade_info'"\ 48 | "that includes version information (${mysqld_version_dot} in this case) in the root"\ 49 | "of the data directory."\ 50 | "In order to create the 'mysql_upgrade_info' file, either run this container with"\ 51 | "the MYSQL_DATADIR_ACTION environment variable set to 'force', or run 'mysql_upgrade' utility"\ 52 | "manually; the mysql_upgrade tool checks the tables and creates such a file as well."\ 53 | "That will enable correct upgrade check in the future. $(upstream_upgrade_info)" 54 | fi 55 | 56 | if [ "${datadir_version}" -eq "${mysqld_version}" ] ; then 57 | log_info "MySQL server version check passed, both server and data directory"\ 58 | "are version ${mysqld_version_dot}." 59 | continue 60 | fi 61 | 62 | if [ $(( ${datadir_version} + 1 )) -eq "${mysqld_version}" ] || [ "${datadir_version}" -eq 505 -a "${mysqld_version}" -eq 1000 ] || \ 63 | [ "${datadir_version}" -eq 1003 -a "${mysqld_version}" -eq 1005 ] || [ "${datadir_version}" -eq 1005 -a "${mysqld_version}" -eq 1011 ] || [ "${datadir_version}" -eq 1011 -a "${mysqld_version}" -eq 1108 ] ; then 64 | 65 | log_warn "MySQL server is version ${mysqld_version_dot} and datadir is version"\ 66 | "${datadir_version_dot}, which is a compatible combination." 67 | if [ "${MYSQL_DATADIR_ACTION}" == 'upgrade-auto' ] ; then 68 | log_info "The data directory will be upgraded automatically from ${datadir_version_dot}"\ 69 | "to version ${mysqld_version_dot}. $(upstream_upgrade_info)" 70 | log_and_run mysql_upgrade ${mysql_flags} 71 | else 72 | log_warn "Automatic upgrade is not turned on, proceed with the upgrade."\ 73 | "In order to upgrade the data directory, run this container with the MYSQL_DATADIR_ACTION"\ 74 | "environment variable set to 'upgrade-auto' or run mysql_upgrade manually. $(upstream_upgrade_info)" 75 | fi 76 | else 77 | log_warn "MySQL server is version ${mysqld_version_dot} and datadir is version"\ 78 | "${datadir_version_dot}, which are incompatible. Remember, that upgrade is only supported"\ 79 | "by upstream from previous version and it is not allowed to skip versions. $(upstream_upgrade_info)" 80 | if [ "${datadir_version}" -gt "${mysqld_version}" ] ; then 81 | log_warn "Downgrading to the lower version is not supported. Consider"\ 82 | "dumping data and load them again into a fresh instance. $(upstream_upgrade_info)" 83 | fi 84 | log_warn "Consider restoring the database from a back-up. To ignore this"\ 85 | "warning, set 'MYSQL_DATADIR_ACTION' variable to 'upgrade-force', but this may result in data corruption. $(upstream_upgrade_info)" 86 | return 1 87 | fi 88 | ;; 89 | 90 | upgrade-force) 91 | log_and_run mysql_upgrade ${mysql_flags} --force 92 | ;; 93 | 94 | optimize) 95 | log_and_run mysqlcheck ${mysql_flags} --optimize --all-databases --force 96 | ;; 97 | 98 | analyze) 99 | log_and_run mysqlcheck ${mysql_flags} --analyze --all-databases --force 100 | ;; 101 | 102 | disable) 103 | log_info "Nothing is done about the data directory." 104 | ;; 105 | *) 106 | log_warn "Unknown value of MYSQL_DATADIR_ACTION variable: '${MYSQL_DATADIR_ACTION}', ignoring." 107 | ;; 108 | esac 109 | done 110 | } 111 | 112 | check_datadir_version "${MYSQL_DATADIR}" 113 | 114 | unset -f check_datadir_version upstream_upgrade_info 115 | 116 | 117 | -------------------------------------------------------------------------------- /test/test-lib-mysql.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # Functions for tests for the MariaDB image in OpenShift. 4 | # 5 | # IMAGE_NAME specifies a name of the candidate image used for testing. 6 | # The image has to be available before this script is executed. 7 | # 8 | 9 | THISDIR=$(dirname ${BASH_SOURCE[0]}) 10 | 11 | source "${THISDIR}/test-lib.sh" 12 | source "${THISDIR}/test-lib-openshift.sh" 13 | source "${THISDIR}/test-lib-remote-openshift.sh" 14 | 15 | function check_mysql_os_service_connection() { 16 | local util_image_name="${1}" ; shift 17 | local service_name="${1}" ; shift 18 | local user="${1}" ; shift 19 | local pass="${1}" ; shift 20 | local timeout="${1:-60}" ; shift || : 21 | local pod_ip=$(ct_os_get_service_ip ${service_name}) 22 | 23 | : " Service ${service_name} check ..." 24 | 25 | local cmd="echo 'SELECT 42 as testval\g' | mysql --connect-timeout=15 -h ${pod_ip} -u${user} -p${pass}" 26 | local expected_value='^42' 27 | local output 28 | local ret 29 | SECONDS=0 30 | 31 | echo -n "Waiting for ${service_name} service becoming ready ..." 32 | while true ; do 33 | output=$(docker run --rm ${util_image_name} bash -c "${cmd}" || :) 34 | echo "${output}" | grep -qe "${expected_value}" && ret=0 || ret=1 35 | if [ ${ret} -eq 0 ] ; then 36 | echo " PASS" 37 | return 0 38 | fi 39 | echo -n "." 40 | [ ${SECONDS} -gt ${timeout} ] && break 41 | sleep 3 42 | done 43 | echo " FAIL" 44 | return 1 45 | } 46 | 47 | function test_mysql_pure_image() { 48 | local image_name=${1:-quay.io/sclorg/mariadb-105-c9s} 49 | local image_name_no_namespace=${image_name##*/} 50 | local service_name="${image_name_no_namespace%%:*}-testing" 51 | 52 | ct_os_new_project 53 | # Create a specific imagestream tag for the image so that oc cannot use anything else 54 | ct_os_upload_image "v3" "${image_name}" "$image_name_no_namespace" 55 | 56 | ct_os_deploy_pure_image "$image_name_no_namespace" \ 57 | --name "${service_name}" \ 58 | --env MYSQL_ROOT_PASSWORD=test 59 | 60 | ct_os_wait_pod_ready "${service_name}" 60 61 | check_mysql_os_service_connection "${image_name}" "${service_name}" root test 62 | 63 | ct_os_delete_project 64 | } 65 | 66 | function test_mysql_template() { 67 | local image_name=${1:-quay.io/sclorg/mariadb-105-c9s} 68 | local image_name_no_namespace=${image_name##*/} 69 | local service_name="${image_name_no_namespace%%:*}-testing" 70 | 71 | ct_os_new_project 72 | ct_os_upload_image "v3" "${image_name}" "mariadb:$VERSION" 73 | 74 | ct_os_deploy_template_image ${THISDIR}/mariadb-ephemeral-template.json \ 75 | NAMESPACE="$(oc project -q)" \ 76 | MARIADB_VERSION="$VERSION" \ 77 | DATABASE_SERVICE_NAME="${service_name}" \ 78 | MYSQL_USER=testu \ 79 | MYSQL_PASSWORD=testp \ 80 | MYSQL_DATABASE=testdb 81 | 82 | ct_os_wait_pod_ready "${service_name}" 60 83 | check_mysql_os_service_connection "${image_name}" "${service_name}" testu testp 84 | 85 | ct_os_delete_project 86 | } 87 | 88 | function test_mysql_s2i() { 89 | local image_name=${1:-quay.io/sclorg/mariadb-105-c9s} 90 | local app=${2:-https://github.com/sclorg/mariadb-container.git} 91 | local context_dir=${3:-test/test-app} 92 | local image_name_no_namespace=${image_name##*/} 93 | local service_name="${image_name_no_namespace%%:*}-testing" 94 | 95 | ct_os_new_project 96 | # Create a specific imagestream tag for the image so that oc cannot use anything else 97 | ct_os_upload_image "v3" "${image_name}" "$image_name_no_namespace" 98 | 99 | ct_os_deploy_s2i_image "$image_name_no_namespace" "${app}" \ 100 | --context-dir="${context_dir}" \ 101 | --name "${service_name}" \ 102 | --env MYSQL_ROOT_PASSWORD=test \ 103 | --env MYSQL_OPERATIONS_USER=testo \ 104 | --env MYSQL_OPERATIONS_PASSWORD=testo \ 105 | --env MYSQL_DATABASE=testopdb \ 106 | --env MYSQL_USER=testnormal \ 107 | --env MYSQL_PASSWORD=testnormal 108 | 109 | ct_os_wait_pod_ready "${service_name}" 60 110 | check_mysql_os_service_connection "${image_name}" "${service_name}" testo testo 120 111 | 112 | ct_os_delete_project 113 | } 114 | 115 | function test_mariadb_integration() { 116 | local service_name=mariadb 117 | TEMPLATES="mariadb-ephemeral-template.json 118 | mariadb-persistent-template.json" 119 | SHORT_VERSION="${VERSION//.}" 120 | # MariaDB-103 exists only for RHEL8 and MariaDB exists only for all versions so let's use version 10.5 121 | namespace_image="${OS}/mariadb-1011" 122 | # Check if the current version is already GA 123 | # This directory is cloned from TMT plan repo 'sclorg-tmt-plans' 124 | local devel_file="/root/sclorg-tmt-plans/devel_images" 125 | if [ -f "${devel_file}" ]; then 126 | if grep -q "${OS}=mariadb-container=${VERSION}" "$devel_file" ; then 127 | echo "This version is currently developed, so skipping this test." 128 | return 129 | fi 130 | fi 131 | for template in $TEMPLATES; do 132 | ct_os_test_template_app_func "${IMAGE_NAME}" \ 133 | "${THISDIR}/${template}" \ 134 | "${service_name}" \ 135 | "ct_os_check_cmd_internal 'registry.redhat.io/${namespace_image}' '${service_name}-testing' \"echo 'SELECT 42 as testval\g' | mysql --connect-timeout=15 -h testdb -utestu -ptestp\" '^42' 120" \ 136 | "-p MARIADB_VERSION=${VERSION} \ 137 | -p DATABASE_SERVICE_NAME="${service_name}-testing" \ 138 | -p MYSQL_USER=testu \ 139 | -p MYSQL_PASSWORD=testp \ 140 | -p MYSQL_DATABASE=testdb" 141 | done 142 | } 143 | 144 | # Check the imagestream 145 | function test_mariadb_imagestream() { 146 | local tag="-el8" 147 | if [ "${OS}" == "rhel9" ]; then 148 | tag="-el9" 149 | elif [ "${OS}" == "rhel10" ]; then 150 | tag="-el10" 151 | fi 152 | 153 | # Check if the current version is already GA 154 | # This directory is cloned from TMT plan repo 'sclorg-tmt-plans' 155 | local devel_file="/root/sclorg-tmt-plans/devel_images" 156 | if [ -f "${devel_file}" ]; then 157 | if grep -q "${OS}=mariadb-container=${VERSION}" "$devel_file" ; then 158 | echo "This version is currently developed, so skipping this test." 159 | return 160 | fi 161 | fi 162 | TEMPLATES="mariadb-ephemeral-template.json 163 | mariadb-persistent-template.json" 164 | for template in $TEMPLATES; do 165 | ct_os_test_image_stream_template "${THISDIR}/imagestreams/mariadb-${OS//[0-9]/}.json" "${THISDIR}/examples/${template}" mariadb "-p MARIADB_VERSION=${VERSION}${tag}" 166 | done 167 | } 168 | 169 | function test_mariadb_template() { 170 | # Check if the current version is already GA 171 | # This directory is cloned from TMT plan repo 'sclorg-tmt-plans' 172 | local devel_file="/root/sclorg-tmt-plans/devel_images" 173 | if [ -f "${devel_file}" ]; then 174 | if grep -q "${OS}=mariadb-container=${VERSION}" "$devel_file" ; then 175 | echo "This version is currently developed, so skipping this test." 176 | return 177 | fi 178 | fi 179 | TEMPLATES="mariadb-ephemeral-template.json 180 | mariadb-persistent-template.json" 181 | for template in $TEMPLATES; do 182 | ct_os_test_image_stream_template "${THISDIR}/imagestreams/mariadb-${OS//[0-9]/}.json" "${THISDIR}/examples/${template}" mariadb 183 | done 184 | } 185 | 186 | 187 | # Check the latest imagestreams 188 | function run_latest_imagestreams() { 189 | # Check if the current version is already GA 190 | # This directory is cloned from TMT plan repo 'sclorg-tmt-plans' 191 | local devel_file="/root/sclorg-tmt-plans/devel_images" 192 | if [ -f "${devel_file}" ]; then 193 | if grep -q "${OS}=mariadb-container=${VERSION}" "$devel_file" ; then 194 | echo "This version is currently developed, so skipping this test." 195 | return 196 | fi 197 | fi 198 | local result=1 199 | # Switch to root directory of a container 200 | echo "Testing the latest version in imagestreams" 201 | pushd "${THISDIR}/../.." >/dev/null || return 1 202 | ct_check_latest_imagestreams 203 | result=$? 204 | popd >/dev/null || return 1 205 | return $result 206 | } 207 | # vim: set tabstop=2:shiftwidth=2:expandtab: 208 | -------------------------------------------------------------------------------- /examples/mariadb-ephemeral-template.json: -------------------------------------------------------------------------------- 1 | { 2 | "kind": "Template", 3 | "apiVersion": "template.openshift.io/v1", 4 | "metadata": { 5 | "name": "mariadb-ephemeral", 6 | "annotations": { 7 | "openshift.io/display-name": "MariaDB (Ephemeral)", 8 | "description": "MariaDB database service, without persistent storage. For more information about using this template, including OpenShift considerations, see https://github.com/sclorg/mariadb-container/blob/master/10.3/root/usr/share/container-scripts/mysql/README.md.\n\nWARNING: Any data stored will be lost upon pod destruction. Only use this template for testing", 9 | "iconClass": "icon-mariadb", 10 | "tags": "database,mariadb", 11 | "openshift.io/long-description": "This template provides a standalone MariaDB server with a database created. The database is not stored on persistent storage, so any restart of the service will result in all data being lost. The database name, username, and password are chosen via parameters when provisioning this service.", 12 | "openshift.io/provider-display-name": "Red Hat, Inc.", 13 | "openshift.io/documentation-url": "https://github.com/sclorg/mariadb-container/blob/master/10.3/root/usr/share/container-scripts/mysql/README.md", 14 | "openshift.io/support-url": "https://access.redhat.com" 15 | } 16 | }, 17 | "message": "The following service(s) have been created in your project: ${DATABASE_SERVICE_NAME}.\n\n Username: ${MYSQL_USER}\n Password: ${MYSQL_PASSWORD}\n Database Name: ${MYSQL_DATABASE}\n Connection URL: mysql://${DATABASE_SERVICE_NAME}:3306/\n\nFor more information about using this template, including OpenShift considerations, see https://github.com/sclorg/mariadb-container/blob/master/10.3/root/usr/share/container-scripts/mysql/README.md.", 18 | "labels": { 19 | "app.openshift.io/runtime": "mariadb", 20 | "template": "mariadb-ephemeral-template" 21 | }, 22 | "objects": [ 23 | { 24 | "kind": "Secret", 25 | "apiVersion": "v1", 26 | "metadata": { 27 | "name": "${DATABASE_SERVICE_NAME}", 28 | "annotations": { 29 | "template.openshift.io/expose-username": "{.data['database-user']}", 30 | "template.openshift.io/expose-password": "{.data['database-password']}", 31 | "template.openshift.io/expose-root_password": "{.data['database-root-password']}", 32 | "template.openshift.io/expose-database_name": "{.data['database-name']}" 33 | } 34 | }, 35 | "stringData" : { 36 | "database-user" : "${MYSQL_USER}", 37 | "database-password" : "${MYSQL_PASSWORD}", 38 | "database-root-password" : "${MYSQL_ROOT_PASSWORD}", 39 | "database-name" : "${MYSQL_DATABASE}" 40 | } 41 | }, 42 | { 43 | "kind": "Service", 44 | "apiVersion": "v1", 45 | "metadata": { 46 | "name": "${DATABASE_SERVICE_NAME}", 47 | "annotations": { 48 | "template.openshift.io/expose-uri": "mysql://{.spec.clusterIP}:{.spec.ports[?(.name==\"mariadb\")].port}" 49 | } 50 | }, 51 | "spec": { 52 | "ports": [ 53 | { 54 | "name": "mariadb", 55 | "port": 3306 56 | } 57 | ], 58 | "selector": { 59 | "name": "${DATABASE_SERVICE_NAME}" 60 | } 61 | } 62 | }, 63 | { 64 | "kind": "Deployment", 65 | "apiVersion": "apps/v1", 66 | "metadata": { 67 | "name": "${DATABASE_SERVICE_NAME}", 68 | "annotations": { 69 | "template.alpha.openshift.io/wait-for-ready": "true", 70 | "image.openshift.io/triggers": "[{\"from\":{\"kind\":\"ImageStreamTag\",\"name\":\"mariadb:${MARIADB_VERSION}\"},\"fieldPath\": \"spec.template.spec.containers[0].image\"}]" 71 | } 72 | }, 73 | "spec": { 74 | "strategy": { 75 | "type": "Recreate" 76 | }, 77 | "replicas": 1, 78 | "selector": { 79 | "matchLabels": { 80 | "name": "${DATABASE_SERVICE_NAME}" 81 | } 82 | }, 83 | "template": { 84 | "metadata": { 85 | "labels": { 86 | "name": "${DATABASE_SERVICE_NAME}" 87 | } 88 | }, 89 | "spec": { 90 | "containers": [ 91 | { 92 | "name": "mariadb", 93 | "image": " ", 94 | "ports": [ 95 | { 96 | "containerPort": 3306 97 | } 98 | ], 99 | "readinessProbe": { 100 | "timeoutSeconds": 1, 101 | "initialDelaySeconds": 5, 102 | "exec": { 103 | "command": [ "/bin/sh", "-i", "-c", 104 | "MYSQL_PWD=\"$MYSQL_PASSWORD\" mysqladmin -u $MYSQL_USER ping"] 105 | } 106 | }, 107 | "livenessProbe": { 108 | "timeoutSeconds": 1, 109 | "initialDelaySeconds": 30, 110 | "exec": { 111 | "command": [ "/bin/sh", "-i", "-c", 112 | "MYSQL_PWD=\"$MYSQL_PASSWORD\" mysqladmin -u $MYSQL_USER ping"] 113 | } 114 | }, 115 | "env": [ 116 | { 117 | "name": "MYSQL_USER", 118 | "valueFrom": { 119 | "secretKeyRef" : { 120 | "name" : "${DATABASE_SERVICE_NAME}", 121 | "key" : "database-user" 122 | } 123 | } 124 | }, 125 | { 126 | "name": "MYSQL_PASSWORD", 127 | "valueFrom": { 128 | "secretKeyRef" : { 129 | "name" : "${DATABASE_SERVICE_NAME}", 130 | "key" : "database-password" 131 | } 132 | } 133 | }, 134 | { 135 | "name": "MYSQL_ROOT_PASSWORD", 136 | "valueFrom": { 137 | "secretKeyRef" : { 138 | "name" : "${DATABASE_SERVICE_NAME}", 139 | "key" : "database-root-password" 140 | } 141 | } 142 | }, 143 | { 144 | "name": "MYSQL_DATABASE", 145 | "valueFrom": { 146 | "secretKeyRef" : { 147 | "name" : "${DATABASE_SERVICE_NAME}", 148 | "key" : "database-name" 149 | } 150 | } 151 | } 152 | ], 153 | "resources": { 154 | "limits": { 155 | "memory": "${MEMORY_LIMIT}" 156 | } 157 | }, 158 | "volumeMounts": [ 159 | { 160 | "name": "${DATABASE_SERVICE_NAME}-data", 161 | "mountPath": "/var/lib/mysql/data" 162 | } 163 | ], 164 | "imagePullPolicy": "IfNotPresent" 165 | } 166 | ], 167 | "volumes": [ 168 | { 169 | "name": "${DATABASE_SERVICE_NAME}-data", 170 | "emptyDir": { 171 | "medium": "" 172 | } 173 | } 174 | ] 175 | } 176 | } 177 | } 178 | } 179 | ], 180 | "parameters": [ 181 | { 182 | "name": "MEMORY_LIMIT", 183 | "displayName": "Memory Limit", 184 | "description": "Maximum amount of memory the container can use.", 185 | "value": "512Mi", 186 | "required": true 187 | }, 188 | { 189 | "name": "NAMESPACE", 190 | "displayName": "Namespace", 191 | "description": "The OpenShift Namespace where the ImageStream resides.", 192 | "value": "openshift" 193 | }, 194 | { 195 | "name": "DATABASE_SERVICE_NAME", 196 | "displayName": "Database Service Name", 197 | "description": "The name of the OpenShift Service exposed for the database.", 198 | "value": "mariadb", 199 | "required": true 200 | }, 201 | { 202 | "name": "MYSQL_USER", 203 | "displayName": "MariaDB Connection Username", 204 | "description": "Username for MariaDB user that will be used for accessing the database.", 205 | "generate": "expression", 206 | "from": "user[A-Z0-9]{3}", 207 | "required": true 208 | }, 209 | { 210 | "name": "MYSQL_PASSWORD", 211 | "displayName": "MariaDB Connection Password", 212 | "description": "Password for the MariaDB connection user.", 213 | "generate": "expression", 214 | "from": "[a-zA-Z0-9]{16}", 215 | "required": true 216 | }, 217 | { 218 | "name": "MYSQL_ROOT_PASSWORD", 219 | "displayName": "MariaDB root Password", 220 | "description": "Password for the MariaDB root user.", 221 | "generate": "expression", 222 | "from": "[a-zA-Z0-9]{16}", 223 | "required": true 224 | }, 225 | { 226 | "name": "MYSQL_DATABASE", 227 | "displayName": "MariaDB Database Name", 228 | "description": "Name of the MariaDB database accessed.", 229 | "value": "sampledb", 230 | "required": true 231 | }, 232 | { 233 | "name": "MARIADB_VERSION", 234 | "displayName": "Version of MariaDB Image", 235 | "description": "Version of MariaDB image to be used (10.3-el8, 10.5-el8, 10.5-el9, 10.11-el8, 10.11-el9, 10.11-el10, or latest).", 236 | "value": "10.11-el10", 237 | "required": true 238 | } 239 | ] 240 | } 241 | -------------------------------------------------------------------------------- /examples/mariadb-persistent-template.json: -------------------------------------------------------------------------------- 1 | { 2 | "kind": "Template", 3 | "apiVersion": "template.openshift.io/v1", 4 | "metadata": { 5 | "name": "mariadb-persistent", 6 | "annotations": { 7 | "openshift.io/display-name": "MariaDB", 8 | "description": "MariaDB database service, with persistent storage. For more information about using this template, including OpenShift considerations, see https://github.com/sclorg/mariadb-container/blob/master/10.3/root/usr/share/container-scripts/mysql/README.md.\n\nNOTE: Scaling to more than one replica is not supported. You must have persistent volumes available in your cluster to use this template.", 9 | "iconClass": "icon-mariadb", 10 | "tags": "database,mariadb", 11 | "openshift.io/long-description": "This template provides a standalone MariaDB server with a database created. The database is stored on persistent storage. The database name, username, and password are chosen via parameters when provisioning this service.", 12 | "openshift.io/provider-display-name": "Red Hat, Inc.", 13 | "openshift.io/documentation-url": "https://github.com/sclorg/mariadb-container/blob/master/10.3/root/usr/share/container-scripts/mysql/README.md", 14 | "openshift.io/support-url": "https://access.redhat.com" 15 | } 16 | }, 17 | "message": "The following service(s) have been created in your project: ${DATABASE_SERVICE_NAME}.\n\n Username: ${MYSQL_USER}\n Password: ${MYSQL_PASSWORD}\n Database Name: ${MYSQL_DATABASE}\n Connection URL: mysql://${DATABASE_SERVICE_NAME}:3306/\n\nFor more information about using this template, including OpenShift considerations, see https://github.com/sclorg/mariadb-container/blob/master/10.3/root/usr/share/container-scripts/mysql/README.md.", 18 | "labels": { 19 | "app.openshift.io/runtime": "mariadb", 20 | "template": "mariadb-persistent-template" 21 | }, 22 | "objects": [ 23 | { 24 | "kind": "Secret", 25 | "apiVersion": "v1", 26 | "metadata": { 27 | "name": "${DATABASE_SERVICE_NAME}", 28 | "annotations": { 29 | "template.openshift.io/expose-username": "{.data['database-user']}", 30 | "template.openshift.io/expose-password": "{.data['database-password']}", 31 | "template.openshift.io/expose-root_password": "{.data['database-root-password']}", 32 | "template.openshift.io/expose-database_name": "{.data['database-name']}" 33 | } 34 | }, 35 | "stringData" : { 36 | "database-user" : "${MYSQL_USER}", 37 | "database-password" : "${MYSQL_PASSWORD}", 38 | "database-root-password" : "${MYSQL_ROOT_PASSWORD}", 39 | "database-name" : "${MYSQL_DATABASE}" 40 | } 41 | }, 42 | { 43 | "kind": "Service", 44 | "apiVersion": "v1", 45 | "metadata": { 46 | "name": "${DATABASE_SERVICE_NAME}", 47 | "annotations": { 48 | "template.openshift.io/expose-uri": "mysql://{.spec.clusterIP}:{.spec.ports[?(.name==\"mariadb\")].port}" 49 | } 50 | }, 51 | "spec": { 52 | "ports": [ 53 | { 54 | "name": "mariadb", 55 | "port": 3306 56 | } 57 | ], 58 | "selector": { 59 | "name": "${DATABASE_SERVICE_NAME}" 60 | } 61 | } 62 | }, 63 | { 64 | "kind": "PersistentVolumeClaim", 65 | "apiVersion": "v1", 66 | "metadata": { 67 | "name": "${DATABASE_SERVICE_NAME}" 68 | }, 69 | "spec": { 70 | "accessModes": [ 71 | "ReadWriteOnce" 72 | ], 73 | "resources": { 74 | "requests": { 75 | "storage": "${VOLUME_CAPACITY}" 76 | } 77 | } 78 | } 79 | }, 80 | { 81 | "kind": "Deployment", 82 | "apiVersion": "apps/v1", 83 | "metadata": { 84 | "name": "${DATABASE_SERVICE_NAME}", 85 | "annotations": { 86 | "template.alpha.openshift.io/wait-for-ready": "true", 87 | "image.openshift.io/triggers": "[{\"from\":{\"kind\":\"ImageStreamTag\",\"name\":\"mariadb:${MARIADB_VERSION}\"},\"fieldPath\": \"spec.template.spec.containers[0].image\"}]" 88 | } 89 | }, 90 | "spec": { 91 | "strategy": { 92 | "type": "Recreate" 93 | }, 94 | "replicas": 1, 95 | "selector": { 96 | "matchLabels": { 97 | "name": "${DATABASE_SERVICE_NAME}" 98 | } 99 | }, 100 | "template": { 101 | "metadata": { 102 | "labels": { 103 | "name": "${DATABASE_SERVICE_NAME}" 104 | } 105 | }, 106 | "spec": { 107 | "containers": [ 108 | { 109 | "name": "mariadb", 110 | "image": " ", 111 | "ports": [ 112 | { 113 | "containerPort": 3306 114 | } 115 | ], 116 | "readinessProbe": { 117 | "timeoutSeconds": 1, 118 | "initialDelaySeconds": 5, 119 | "exec": { 120 | "command": [ "/bin/sh", "-i", "-c", 121 | "MYSQL_PWD=\"$MYSQL_PASSWORD\" mysqladmin -u $MYSQL_USER ping"] 122 | } 123 | }, 124 | "livenessProbe": { 125 | "timeoutSeconds": 1, 126 | "initialDelaySeconds": 30, 127 | "exec": { 128 | "command": [ "/bin/sh", "-i", "-c", 129 | "MYSQL_PWD=\"$MYSQL_PASSWORD\" mysqladmin -u $MYSQL_USER ping"] 130 | } 131 | }, 132 | "env": [ 133 | { 134 | "name": "MYSQL_USER", 135 | "valueFrom": { 136 | "secretKeyRef" : { 137 | "name" : "${DATABASE_SERVICE_NAME}", 138 | "key" : "database-user" 139 | } 140 | } 141 | }, 142 | { 143 | "name": "MYSQL_PASSWORD", 144 | "valueFrom": { 145 | "secretKeyRef" : { 146 | "name" : "${DATABASE_SERVICE_NAME}", 147 | "key" : "database-password" 148 | } 149 | } 150 | }, 151 | { 152 | "name": "MYSQL_ROOT_PASSWORD", 153 | "valueFrom": { 154 | "secretKeyRef" : { 155 | "name" : "${DATABASE_SERVICE_NAME}", 156 | "key" : "database-root-password" 157 | } 158 | } 159 | }, 160 | { 161 | "name": "MYSQL_DATABASE", 162 | "valueFrom": { 163 | "secretKeyRef" : { 164 | "name" : "${DATABASE_SERVICE_NAME}", 165 | "key" : "database-name" 166 | } 167 | } 168 | } 169 | ], 170 | "resources": { 171 | "limits": { 172 | "memory": "${MEMORY_LIMIT}" 173 | } 174 | }, 175 | "volumeMounts": [ 176 | { 177 | "name": "${DATABASE_SERVICE_NAME}-data", 178 | "mountPath": "/var/lib/mysql/data" 179 | } 180 | ], 181 | "imagePullPolicy": "IfNotPresent" 182 | } 183 | ], 184 | "volumes": [ 185 | { 186 | "name": "${DATABASE_SERVICE_NAME}-data", 187 | "persistentVolumeClaim": { 188 | "claimName": "${DATABASE_SERVICE_NAME}" 189 | } 190 | } 191 | ] 192 | } 193 | } 194 | } 195 | } 196 | ], 197 | "parameters": [ 198 | { 199 | "name": "MEMORY_LIMIT", 200 | "displayName": "Memory Limit", 201 | "description": "Maximum amount of memory the container can use.", 202 | "value": "512Mi", 203 | "required": true 204 | }, 205 | { 206 | "name": "NAMESPACE", 207 | "displayName": "Namespace", 208 | "description": "The OpenShift Namespace where the ImageStream resides.", 209 | "value": "openshift" 210 | }, 211 | { 212 | "name": "DATABASE_SERVICE_NAME", 213 | "displayName": "Database Service Name", 214 | "description": "The name of the OpenShift Service exposed for the database.", 215 | "value": "mariadb", 216 | "required": true 217 | }, 218 | { 219 | "name": "MYSQL_USER", 220 | "displayName": "MariaDB Connection Username", 221 | "description": "Username for MariaDB user that will be used for accessing the database.", 222 | "generate": "expression", 223 | "from": "user[A-Z0-9]{3}", 224 | "required": true 225 | }, 226 | { 227 | "name": "MYSQL_PASSWORD", 228 | "displayName": "MariaDB Connection Password", 229 | "description": "Password for the MariaDB connection user.", 230 | "generate": "expression", 231 | "from": "[a-zA-Z0-9]{16}", 232 | "required": true 233 | }, 234 | { 235 | "name": "MYSQL_ROOT_PASSWORD", 236 | "displayName": "MariaDB root Password", 237 | "description": "Password for the MariaDB root user.", 238 | "generate": "expression", 239 | "from": "[a-zA-Z0-9]{16}", 240 | "required": true 241 | }, 242 | { 243 | "name": "MYSQL_DATABASE", 244 | "displayName": "MariaDB Database Name", 245 | "description": "Name of the MariaDB database accessed.", 246 | "value": "sampledb", 247 | "required": true 248 | }, 249 | { 250 | "name": "MARIADB_VERSION", 251 | "displayName": "Version of MariaDB Image", 252 | "description": "Version of MariaDB image to be used (10.3-el8, 10.5-el8, 10.5-el9, 10.11-el8, 10.11-el9, 10.11-el10, or latest).", 253 | "value": "10.11-el10", 254 | "required": true 255 | }, 256 | { 257 | "name": "VOLUME_CAPACITY", 258 | "displayName": "Volume Capacity", 259 | "description": "Volume space available for data, e.g. 512Mi, 2Gi.", 260 | "value": "1Gi", 261 | "required": true 262 | } 263 | ] 264 | } 265 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | 2 | Apache License 3 | Version 2.0, January 2004 4 | http://www.apache.org/licenses/ 5 | 6 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 7 | 8 | 1. Definitions. 9 | 10 | "License" shall mean the terms and conditions for use, reproduction, 11 | and distribution as defined by Sections 1 through 9 of this document. 12 | 13 | "Licensor" shall mean the copyright owner or entity authorized by 14 | the copyright owner that is granting the License. 15 | 16 | "Legal Entity" shall mean the union of the acting entity and all 17 | other entities that control, are controlled by, or are under common 18 | control with that entity. For the purposes of this definition, 19 | "control" means (i) the power, direct or indirect, to cause the 20 | direction or management of such entity, whether by contract or 21 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 22 | outstanding shares, or (iii) beneficial ownership of such entity. 23 | 24 | "You" (or "Your") shall mean an individual or Legal Entity 25 | exercising permissions granted by this License. 26 | 27 | "Source" form shall mean the preferred form for making modifications, 28 | including but not limited to software source code, documentation 29 | source, and configuration files. 30 | 31 | "Object" form shall mean any form resulting from mechanical 32 | transformation or translation of a Source form, including but 33 | not limited to compiled object code, generated documentation, 34 | and conversions to other media types. 35 | 36 | "Work" shall mean the work of authorship, whether in Source or 37 | Object form, made available under the License, as indicated by a 38 | copyright notice that is included in or attached to the work 39 | (an example is provided in the Appendix below). 40 | 41 | "Derivative Works" shall mean any work, whether in Source or Object 42 | form, that is based on (or derived from) the Work and for which the 43 | editorial revisions, annotations, elaborations, or other modifications 44 | represent, as a whole, an original work of authorship. For the purposes 45 | of this License, Derivative Works shall not include works that remain 46 | separable from, or merely link (or bind by name) to the interfaces of, 47 | the Work and Derivative Works thereof. 48 | 49 | "Contribution" shall mean any work of authorship, including 50 | the original version of the Work and any modifications or additions 51 | to that Work or Derivative Works thereof, that is intentionally 52 | submitted to Licensor for inclusion in the Work by the copyright owner 53 | or by an individual or Legal Entity authorized to submit on behalf of 54 | the copyright owner. For the purposes of this definition, "submitted" 55 | means any form of electronic, verbal, or written communication sent 56 | to the Licensor or its representatives, including but not limited to 57 | communication on electronic mailing lists, source code control systems, 58 | and issue tracking systems that are managed by, or on behalf of, the 59 | Licensor for the purpose of discussing and improving the Work, but 60 | excluding communication that is conspicuously marked or otherwise 61 | designated in writing by the copyright owner as "Not a Contribution." 62 | 63 | "Contributor" shall mean Licensor and any individual or Legal Entity 64 | on behalf of whom a Contribution has been received by Licensor and 65 | subsequently incorporated within the Work. 66 | 67 | 2. Grant of Copyright License. Subject to the terms and conditions of 68 | this License, each Contributor hereby grants to You a perpetual, 69 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 70 | copyright license to reproduce, prepare Derivative Works of, 71 | publicly display, publicly perform, sublicense, and distribute the 72 | Work and such Derivative Works in Source or Object form. 73 | 74 | 3. Grant of Patent License. Subject to the terms and conditions of 75 | this License, each Contributor hereby grants to You a perpetual, 76 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 77 | (except as stated in this section) patent license to make, have made, 78 | use, offer to sell, sell, import, and otherwise transfer the Work, 79 | where such license applies only to those patent claims licensable 80 | by such Contributor that are necessarily infringed by their 81 | Contribution(s) alone or by combination of their Contribution(s) 82 | with the Work to which such Contribution(s) was submitted. If You 83 | institute patent litigation against any entity (including a 84 | cross-claim or counterclaim in a lawsuit) alleging that the Work 85 | or a Contribution incorporated within the Work constitutes direct 86 | or contributory patent infringement, then any patent licenses 87 | granted to You under this License for that Work shall terminate 88 | as of the date such litigation is filed. 89 | 90 | 4. Redistribution. You may reproduce and distribute copies of the 91 | Work or Derivative Works thereof in any medium, with or without 92 | modifications, and in Source or Object form, provided that You 93 | meet the following conditions: 94 | 95 | (a) You must give any other recipients of the Work or 96 | Derivative Works a copy of this License; and 97 | 98 | (b) You must cause any modified files to carry prominent notices 99 | stating that You changed the files; and 100 | 101 | (c) You must retain, in the Source form of any Derivative Works 102 | that You distribute, all copyright, patent, trademark, and 103 | attribution notices from the Source form of the Work, 104 | excluding those notices that do not pertain to any part of 105 | the Derivative Works; and 106 | 107 | (d) If the Work includes a "NOTICE" text file as part of its 108 | distribution, then any Derivative Works that You distribute must 109 | include a readable copy of the attribution notices contained 110 | within such NOTICE file, excluding those notices that do not 111 | pertain to any part of the Derivative Works, in at least one 112 | of the following places: within a NOTICE text file distributed 113 | as part of the Derivative Works; within the Source form or 114 | documentation, if provided along with the Derivative Works; or, 115 | within a display generated by the Derivative Works, if and 116 | wherever such third-party notices normally appear. The contents 117 | of the NOTICE file are for informational purposes only and 118 | do not modify the License. You may add Your own attribution 119 | notices within Derivative Works that You distribute, alongside 120 | or as an addendum to the NOTICE text from the Work, provided 121 | that such additional attribution notices cannot be construed 122 | as modifying the License. 123 | 124 | You may add Your own copyright statement to Your modifications and 125 | may provide additional or different license terms and conditions 126 | for use, reproduction, or distribution of Your modifications, or 127 | for any such Derivative Works as a whole, provided Your use, 128 | reproduction, and distribution of the Work otherwise complies with 129 | the conditions stated in this License. 130 | 131 | 5. Submission of Contributions. Unless You explicitly state otherwise, 132 | any Contribution intentionally submitted for inclusion in the Work 133 | by You to the Licensor shall be under the terms and conditions of 134 | this License, without any additional terms or conditions. 135 | Notwithstanding the above, nothing herein shall supersede or modify 136 | the terms of any separate license agreement you may have executed 137 | with Licensor regarding such Contributions. 138 | 139 | 6. Trademarks. This License does not grant permission to use the trade 140 | names, trademarks, service marks, or product names of the Licensor, 141 | except as required for reasonable and customary use in describing the 142 | origin of the Work and reproducing the content of the NOTICE file. 143 | 144 | 7. Disclaimer of Warranty. Unless required by applicable law or 145 | agreed to in writing, Licensor provides the Work (and each 146 | Contributor provides its Contributions) on an "AS IS" BASIS, 147 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 148 | implied, including, without limitation, any warranties or conditions 149 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 150 | PARTICULAR PURPOSE. You are solely responsible for determining the 151 | appropriateness of using or redistributing the Work and assume any 152 | risks associated with Your exercise of permissions under this License. 153 | 154 | 8. Limitation of Liability. In no event and under no legal theory, 155 | whether in tort (including negligence), contract, or otherwise, 156 | unless required by applicable law (such as deliberate and grossly 157 | negligent acts) or agreed to in writing, shall any Contributor be 158 | liable to You for damages, including any direct, indirect, special, 159 | incidental, or consequential damages of any character arising as a 160 | result of this License or out of the use or inability to use the 161 | Work (including but not limited to damages for loss of goodwill, 162 | work stoppage, computer failure or malfunction, or any and all 163 | other commercial damages or losses), even if such Contributor 164 | has been advised of the possibility of such damages. 165 | 166 | 9. Accepting Warranty or Additional Liability. While redistributing 167 | the Work or Derivative Works thereof, You may choose to offer, 168 | and charge a fee for, acceptance of support, warranty, indemnity, 169 | or other liability obligations and/or rights consistent with this 170 | License. However, in accepting such obligations, You may act only 171 | on Your own behalf and on Your sole responsibility, not on behalf 172 | of any other Contributor, and only if You agree to indemnify, 173 | defend, and hold each Contributor harmless for any liability 174 | incurred by, or claims asserted against, such Contributor by reason 175 | of your accepting any such warranty or additional liability. 176 | 177 | END OF TERMS AND CONDITIONS 178 | 179 | APPENDIX: How to apply the Apache License to your work. 180 | 181 | To apply the Apache License to your work, attach the following 182 | boilerplate notice, with the fields enclosed by brackets "[]" 183 | replaced with your own identifying information. (Don't include 184 | the brackets!) The text should be enclosed in the appropriate 185 | comment syntax for the file format. We also recommend that a 186 | file or class name and description of purpose be included on the 187 | same "printed page" as the copyright notice for easier 188 | identification within third-party archives. 189 | 190 | Copyright [yyyy] [name of copyright owner] 191 | 192 | Licensed under the Apache License, Version 2.0 (the "License"); 193 | you may not use this file except in compliance with the License. 194 | You may obtain a copy of the License at 195 | 196 | http://www.apache.org/licenses/LICENSE-2.0 197 | 198 | Unless required by applicable law or agreed to in writing, software 199 | distributed under the License is distributed on an "AS IS" BASIS, 200 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 201 | See the License for the specific language governing permissions and 202 | limitations under the License. 203 | -------------------------------------------------------------------------------- /root-common/usr/share/container-scripts/mysql/common.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | source ${CONTAINER_SCRIPTS_PATH}/helpers.sh 4 | 5 | # Data directory where MySQL database files live. The data subdirectory is here 6 | # because .bashrc and my.cnf both live in /var/lib/mysql/ and we don't want a 7 | # volume to override it. 8 | export MYSQL_DATADIR=/var/lib/mysql/data 9 | 10 | # Configuration settings. 11 | export MYSQL_DEFAULTS_FILE=${MYSQL_DEFAULTS_FILE:-/etc/my.cnf} 12 | 13 | function export_setting_variables() { 14 | export MYSQL_BINLOG_FORMAT=${MYSQL_BINLOG_FORMAT:-STATEMENT} 15 | export MYSQL_LOWER_CASE_TABLE_NAMES=${MYSQL_LOWER_CASE_TABLE_NAMES:-0} 16 | export MYSQL_LOG_QUERIES_ENABLED=${MYSQL_LOG_QUERIES_ENABLED:-0} 17 | export MYSQL_MAX_CONNECTIONS=${MYSQL_MAX_CONNECTIONS:-151} 18 | export MYSQL_FT_MIN_WORD_LEN=${MYSQL_FT_MIN_WORD_LEN:-4} 19 | export MYSQL_FT_MAX_WORD_LEN=${MYSQL_FT_MAX_WORD_LEN:-20} 20 | export MYSQL_AIO=${MYSQL_AIO:-1} 21 | export MYSQL_MAX_ALLOWED_PACKET=${MYSQL_MAX_ALLOWED_PACKET:-200M} 22 | export MYSQL_TABLE_OPEN_CACHE=${MYSQL_TABLE_OPEN_CACHE:-400} 23 | export MYSQL_SORT_BUFFER_SIZE=${MYSQL_SORT_BUFFER_SIZE:-256K} 24 | 25 | # Export memory limit variables and calculate limits 26 | local export_vars=$(cgroup-limits) && export $export_vars || exit 1 27 | if [ -n "${NO_MEMORY_LIMIT:-}" -o -z "${MEMORY_LIMIT_IN_BYTES:-}" ]; then 28 | export MYSQL_KEY_BUFFER_SIZE=${MYSQL_KEY_BUFFER_SIZE:-32M} 29 | export MYSQL_READ_BUFFER_SIZE=${MYSQL_READ_BUFFER_SIZE:-8M} 30 | export MYSQL_INNODB_BUFFER_POOL_SIZE=${MYSQL_INNODB_BUFFER_POOL_SIZE:-32M} 31 | export MYSQL_INNODB_LOG_FILE_SIZE=${MYSQL_INNODB_LOG_FILE_SIZE:-8M} 32 | export MYSQL_INNODB_LOG_BUFFER_SIZE=${MYSQL_INNODB_LOG_BUFFER_SIZE:-8M} 33 | else 34 | export MYSQL_KEY_BUFFER_SIZE=${MYSQL_KEY_BUFFER_SIZE:-$((MEMORY_LIMIT_IN_BYTES/1024/1024/10))M} 35 | export MYSQL_READ_BUFFER_SIZE=${MYSQL_READ_BUFFER_SIZE:-$((MEMORY_LIMIT_IN_BYTES/1024/1024/20))M} 36 | export MYSQL_INNODB_BUFFER_POOL_SIZE=${MYSQL_INNODB_BUFFER_POOL_SIZE:-$((MEMORY_LIMIT_IN_BYTES/1024/1024/2))M} 37 | # We are multiplying by 15 first and dividing by 100 later so we get as much 38 | # precision as possible with whole numbers. Result is 15% of memory. 39 | export MYSQL_INNODB_LOG_FILE_SIZE=${MYSQL_INNODB_LOG_FILE_SIZE:-$((MEMORY_LIMIT_IN_BYTES*15/1024/1024/100))M} 40 | export MYSQL_INNODB_LOG_BUFFER_SIZE=${MYSQL_INNODB_LOG_BUFFER_SIZE:-$((MEMORY_LIMIT_IN_BYTES*15/1024/1024/100))M} 41 | fi 42 | export MYSQL_DATADIR_ACTION=${MYSQL_DATADIR_ACTION:-upgrade-warn} 43 | } 44 | 45 | # this stores whether the database was initialized from empty datadir 46 | export MYSQL_DATADIR_FIRST_INIT=false 47 | 48 | # Be paranoid and stricter than we should be. 49 | # https://dev.mysql.com/doc/refman/en/identifiers.html 50 | mysql_identifier_regex='^[a-zA-Z0-9_]+$' 51 | mysql_password_regex='^[a-zA-Z0-9_~!@#$%^&*()-=<>,.?;:|]+$' 52 | 53 | # Variables that are used to connect to local mysql during initialization 54 | mysql_flags="-u root --socket=/tmp/mysql.sock" 55 | admin_flags="--defaults-file=$MYSQL_DEFAULTS_FILE $mysql_flags" 56 | 57 | # Make sure env variables don't propagate to mysqld process. 58 | function unset_env_vars() { 59 | log_info 'Cleaning up environment variables MYSQL_USER, MYSQL_PASSWORD, MYSQL_DATABASE and MYSQL_ROOT_PASSWORD ...' 60 | unset MYSQL_USER MYSQL_PASSWORD MYSQL_DATABASE MYSQL_ROOT_PASSWORD 61 | } 62 | 63 | # Poll until MySQL responds to our ping. 64 | function wait_for_mysql() { 65 | pid=$1 ; shift 66 | 67 | while true; do 68 | if [ -d "/proc/$pid" ]; then 69 | mysqladmin $admin_flags ping &>/dev/null && log_info "MySQL started successfully" && return 0 70 | else 71 | return 1 72 | fi 73 | log_info "Waiting for MySQL to start ..." 74 | sleep 1 75 | done 76 | } 77 | 78 | # Start local MySQL server with a defaults file 79 | function start_local_mysql() { 80 | log_info 'Starting MySQL server with disabled networking ...' 81 | ${MYSQL_PREFIX}/libexec/mysqld \ 82 | --defaults-file=$MYSQL_DEFAULTS_FILE \ 83 | --skip-networking --socket=/tmp/mysql.sock "$@" & 84 | mysql_pid=$! 85 | wait_for_mysql $mysql_pid 86 | } 87 | 88 | # Shutdown mysql flushing privileges 89 | function shutdown_local_mysql() { 90 | log_info 'Shutting down MySQL ...' 91 | mysqladmin $admin_flags flush-privileges shutdown 92 | } 93 | 94 | # Initialize the MySQL database (create user accounts and the initial database) 95 | function initialize_database() { 96 | log_info 'Initializing database ...' 97 | log_info 'Running mysql_install_db ...' 98 | # Using --rpm since we need mysql_install_db behaves as in RPM 99 | # Using --auth-root-authentication-method=normal because we are not root in the container 100 | # Using --skip-test-db because the anonymous users are not recomended in the production databases. With this option no test database and no anonymous users will be created (GH issue #198) 101 | mysql_install_db --rpm --datadir=$MYSQL_DATADIR --auth-root-authentication-method=normal --skip-test-db 102 | start_local_mysql "$@" 103 | 104 | # Running mysql_upgrade creates the mysql_upgrade_info file in the data dir, 105 | # which is necessary to detect which version of the mysqld daemon created the data. 106 | # Checking empty file should not take longer than a second and one extra check should not harm. 107 | mysql_upgrade ${admin_flags} 108 | 109 | if [ -v MYSQL_RUNNING_AS_SLAVE ]; then 110 | log_info 'Initialization finished' 111 | return 0 112 | fi 113 | 114 | if [ -v MYSQL_RUNNING_AS_MASTER ]; then 115 | # Save master status into a separate database. 116 | STATUS_INFO=$(mysql $admin_flags -e 'SHOW MASTER STATUS\G') 117 | BINLOG_POSITION=$(echo "$STATUS_INFO" | grep 'Position:' | head -n 1 | sed -e 's/^\s*Position: //') 118 | BINLOG_FILE=$(echo "$STATUS_INFO" | grep 'File:' | head -n 1 | sed -e 's/^\s*File: //') 119 | GTID_INFO=$(mysql $admin_flags -e "SELECT BINLOG_GTID_POS('$BINLOG_FILE', '$BINLOG_POSITION') AS gtid_value \G") 120 | GTID_VALUE=$(echo "$GTID_INFO" | grep 'gtid_value:' | head -n 1 | sed -e 's/^\s*gtid_value: //') 121 | 122 | mysqladmin $admin_flags create replication 123 | mysql $admin_flags < "10.0" ] ; then 166 | mysql $mysql_flags </dev/null && log_info "MySQL master is ready" && return 0 195 | sleep 1 196 | done 197 | } 198 | 199 | # get_matched_files finds file for image extending 200 | function get_matched_files() { 201 | local custom_dir default_dir 202 | custom_dir="$1" 203 | default_dir="$2" 204 | files_matched="$3" 205 | find "$default_dir" -maxdepth 1 -type f -name "$files_matched" -printf "%f\n" 206 | [ -d "$custom_dir" ] && find "$custom_dir" -maxdepth 1 -type f -name "$files_matched" -printf "%f\n" 207 | } 208 | 209 | # process_extending_files process extending files in $1 and $2 directories 210 | # - source all *.sh files 211 | # (if there are files with same name source only file from $1) 212 | function process_extending_files() { 213 | local custom_dir default_dir 214 | custom_dir=$1 215 | default_dir=$2 216 | 217 | while read filename ; do 218 | echo "=> sourcing $filename ..." 219 | # Custom file is prefered 220 | if [ -f $custom_dir/$filename ]; then 221 | source $custom_dir/$filename 222 | else 223 | source $default_dir/$filename 224 | fi 225 | done <<<"$(get_matched_files "$custom_dir" "$default_dir" '*.sh' | sort -u)" 226 | } 227 | 228 | # process extending config files in $1 and $2 directories 229 | # - expand variables in *.cnf and copy the files into /etc/my.cnf.d directory 230 | # (if there are files with same name source only file from $1) 231 | function process_extending_config_files() { 232 | local custom_dir default_dir 233 | custom_dir=$1 234 | default_dir=$2 235 | 236 | while read filename ; do 237 | echo "=> sourcing $filename ..." 238 | # Custom file is prefered 239 | if [ -f $custom_dir/$filename ]; then 240 | envsubst < $custom_dir/$filename > /etc/my.cnf.d/$filename 241 | else 242 | envsubst < $default_dir/$filename > /etc/my.cnf.d/$filename 243 | fi 244 | done <<<"$(get_matched_files "$custom_dir" "$default_dir" '*.cnf' | sort -u)" 245 | } 246 | 247 | # Converts string version to the integer format (5.5.33 is converted to 505, 248 | # 10.1.23-MariaDB is converted into 1001, etc. 249 | function version2number() { 250 | local version_major=$(echo "$1" | grep -o -e '^[0-9]*\.[0-9]*') 251 | printf %d%02d ${version_major%%.*} ${version_major##*.} 252 | } 253 | 254 | # Converts the version in format of an integer into major.minor 255 | function number2version() { 256 | local numver=${1} 257 | echo $((numver / 100)).$((numver % 100)) 258 | } 259 | 260 | # Prints version of the mysqld that is currently available (string) 261 | function mysqld_version() { 262 | ${MYSQL_PREFIX}/libexec/mysqld -V | awk '{print $3}' 263 | } 264 | 265 | # Returns version from the daemon in integer format 266 | function mysqld_compat_version() { 267 | version2number $(mysqld_version) 268 | } 269 | 270 | # Returns version from the datadir in the integer format 271 | function get_datadir_version() { 272 | local datadir="$1" 273 | local upgrade_info_file=$(get_mysql_upgrade_info_file "$datadir") 274 | [ -r "$upgrade_info_file" ] || return 275 | local version_text=$(cat "$upgrade_info_file" | head -n 1) 276 | version2number "${version_text}" 277 | } 278 | 279 | # Returns name of the file in the datadir that holds version information about the data 280 | function get_mysql_upgrade_info_file() { 281 | local datadir="$1" 282 | echo "$datadir/mysql_upgrade_info" 283 | } 284 | 285 | # Writes version string of the daemon into mysql_upgrade_info file 286 | # (should be only used when the file is missing and only during limited time; 287 | # once most deployments include this version file, we should leave it on 288 | # scripts to generate the file right after initialization or when upgrading) 289 | function write_mysql_upgrade_info_file() { 290 | local datadir="$1" 291 | local version=$(mysqld_version) 292 | local upgrade_info_file=$(get_mysql_upgrade_info_file "$datadir") 293 | if [ -f "$datadir/mysql_upgrade_info" ] ; then 294 | echo "File ${upgrade_info_file} exists, nothing is done." 295 | else 296 | log_info "Storing version '${version}' information into the data dir '${upgrade_info_file}'" 297 | echo "${version}" > "${upgrade_info_file}" 298 | mysqld_version >"$datadir/mysql_upgrade_info" 299 | fi 300 | } 301 | -------------------------------------------------------------------------------- /10.3/root/usr/share/container-scripts/mysql/README.md: -------------------------------------------------------------------------------- 1 | MariaDB 10.3 SQL Database Server Docker image 2 | ============================================= 3 | 4 | This container image includes MariaDB 10.3 SQL database server for OpenShift and general usage. 5 | The RHEL image is available in the [Red Hat Container Catalog](https://access.redhat.com/containers/), 6 | The resulting image can be run using [podman](https://github.com/containers/libpod). 7 | 8 | Note: while the examples in this README call `podman`, you can replace any such calls by `docker` with the same arguments 9 | 10 | Description 11 | ----------- 12 | 13 | This container image provides a containerized packaging of the MariaDB mysqld daemon 14 | and client application. The mysqld server daemon accepts connections from clients 15 | and provides access to content from MySQL databases on behalf of the clients. 16 | You can find more information on the MariaDB project from the project Web site 17 | (https://mariadb.org/). 18 | 19 | 20 | Usage 21 | ----- 22 | 23 | For this, we will assume that you are using the MariaDB 10.3 container image from the 24 | Red Hat Container Catalog called `rhel8/mariadb-103`. 25 | If you want to set only the mandatory environment variables and not store 26 | the database in a host directory, execute the following command: 27 | 28 | ``` 29 | $ podman run -d --name mariadb_database -e MYSQL_USER=user -e MYSQL_PASSWORD=pass -e MYSQL_DATABASE=db -p 3306:3306 rhel8/mariadb-103 30 | ``` 31 | 32 | This will create a container named `mariadb_database` running MySQL with database 33 | `db` and user with credentials `user:pass`. Port 3306 will be exposed and mapped 34 | to the host. If you want your database to be persistent across container executions, 35 | also add a `-v /host/db/path:/var/lib/mysql/data` argument. This will be the MySQL 36 | data directory. 37 | 38 | If the database directory is not initialized, the entrypoint script will first 39 | run [`mysql_install_db`](https://dev.mysql.com/doc/refman/5.6/en/mysql-install-db.html) 40 | and setup necessary database users and passwords. After the database is initialized, 41 | or if it was already present, `mysqld` is executed and will run as PID 1. You can 42 | stop the detached container by running `podman stop mariadb_database`. 43 | 44 | 45 | Environment variables and volumes 46 | --------------------------------- 47 | 48 | The image recognizes the following environment variables that you can set during 49 | initialization by passing `-e VAR=VALUE` to the Docker run command. 50 | 51 | **`MYSQL_USER`** 52 | User name for MySQL account to be created 53 | 54 | **`MYSQL_PASSWORD`** 55 | Password for the user account 56 | 57 | **`MYSQL_DATABASE`** 58 | Database name 59 | 60 | **`MYSQL_ROOT_PASSWORD`** 61 | Password for the root user (optional) 62 | 63 | **`MYSQL_CHARSET`** 64 | Default character set (optional) 65 | 66 | **`MYSQL_COLLATION`** 67 | Default collation (optional) 68 | 69 | 70 | The following environment variables influence the MySQL configuration file. They are all optional. 71 | 72 | **`MYSQL_LOWER_CASE_TABLE_NAMES (default: 0)`** 73 | Sets how the table names are stored and compared 74 | 75 | **`MYSQL_MAX_CONNECTIONS (default: 151)`** 76 | The maximum permitted number of simultaneous client connections 77 | 78 | **`MYSQL_MAX_ALLOWED_PACKET (default: 200M)`** 79 | The maximum size of one packet or any generated/intermediate string 80 | 81 | **`MYSQL_FT_MIN_WORD_LEN (default: 4)`** 82 | The minimum length of the word to be included in a FULLTEXT index 83 | 84 | **`MYSQL_FT_MAX_WORD_LEN (default: 20)`** 85 | The maximum length of the word to be included in a FULLTEXT index 86 | 87 | **`MYSQL_AIO (default: 1)`** 88 | Controls the `innodb_use_native_aio` setting value in case the native AIO is broken. See http://help.directadmin.com/item.php?id=529 89 | 90 | **`MYSQL_TABLE_OPEN_CACHE (default: 400)`** 91 | The number of open tables for all threads 92 | 93 | **`MYSQL_KEY_BUFFER_SIZE (default: 32M or 10% of available memory)`** 94 | The size of the buffer used for index blocks 95 | 96 | **`MYSQL_SORT_BUFFER_SIZE (default: 256K)`** 97 | The size of the buffer used for sorting 98 | 99 | **`MYSQL_READ_BUFFER_SIZE (default: 8M or 5% of available memory)`** 100 | The size of the buffer used for a sequential scan 101 | 102 | **`MYSQL_INNODB_BUFFER_POOL_SIZE (default: 32M or 50% of available memory)`** 103 | The size of the buffer pool where InnoDB caches table and index data 104 | 105 | **`MYSQL_INNODB_LOG_FILE_SIZE (default: 8M or 15% of available memory)`** 106 | The size of each log file in a log group 107 | 108 | **`MYSQL_INNODB_LOG_BUFFER_SIZE (default: 8M or 15% of available memory)`** 109 | The size of the buffer that InnoDB uses to write to the log files on disk 110 | 111 | **`MYSQL_DEFAULTS_FILE (default: /etc/my.cnf)`** 112 | Point to an alternative configuration file 113 | 114 | **`MYSQL_BINLOG_FORMAT (default: statement)`** 115 | Set sets the binlog format, supported values are `row` and `statement` 116 | 117 | **`MYSQL_LOG_QUERIES_ENABLED (default: 0)`** 118 | To enable query logging set this to `1` 119 | 120 | 121 | You can also set the following mount points by passing the `-v /host:/container` flag to Docker. 122 | 123 | **`/var/lib/mysql/data`** 124 | MySQL data directory 125 | 126 | 127 | **Notice: When mouting a directory from the host into the container, ensure that the mounted 128 | directory has the appropriate permissions and that the owner and group of the directory 129 | matches the user UID or name which is running inside the container.** 130 | 131 | 132 | MariaDB auto-tuning 133 | ------------------- 134 | 135 | When the MySQL image is run with the `--memory` parameter set and you didn't 136 | specify value for some parameters, their values will be automatically 137 | calculated based on the available memory. 138 | 139 | **`MYSQL_KEY_BUFFER_SIZE (default: 10%)`** 140 | `key_buffer_size` 141 | 142 | **`MYSQL_READ_BUFFER_SIZE (default: 5%)`** 143 | `read_buffer_size` 144 | 145 | **`MYSQL_INNODB_BUFFER_POOL_SIZE (default: 50%)`** 146 | `innodb_buffer_pool_size` 147 | 148 | **`MYSQL_INNODB_LOG_FILE_SIZE (default: 15%)`** 149 | `innodb_log_file_size` 150 | 151 | **`MYSQL_INNODB_LOG_BUFFER_SIZE (default: 15%)`** 152 | `innodb_log_buffer_size` 153 | 154 | 155 | 156 | MySQL root user 157 | --------------------------------- 158 | The root user has no password set by default, only allowing local connections. 159 | You can set it by setting the `MYSQL_ROOT_PASSWORD` environment variable. This 160 | will allow you to login to the root account remotely. Local connections will 161 | still not require a password. 162 | 163 | To disable remote root access, simply unset `MYSQL_ROOT_PASSWORD` and restart 164 | the container. 165 | 166 | 167 | Changing passwords 168 | ------------------ 169 | 170 | Since passwords are part of the image configuration, the only supported method 171 | to change passwords for the database user (`MYSQL_USER`) and root user is by 172 | changing the environment variables `MYSQL_PASSWORD` and `MYSQL_ROOT_PASSWORD`, 173 | respectively. 174 | 175 | Changing database passwords through SQL statements or any way other than through 176 | the environment variables aforementioned will cause a mismatch between the 177 | values stored in the variables and the actual passwords. Whenever a database 178 | container starts it will reset the passwords to the values stored in the 179 | environment variables. 180 | 181 | 182 | Default my.cnf file 183 | ------------------- 184 | With environment variables we are able to customize a lot of different parameters 185 | or configurations for the mysql bootstrap configurations. If you'd prefer to use 186 | your own configuration file, you can override the `MYSQL_DEFAULTS_FILE` env 187 | variable with the full path of the file you wish to use. For example, the default 188 | location is `/etc/my.cnf` but you can change it to `/etc/mysql/my.cnf` by setting 189 | `MYSQL_DEFAULTS_FILE=/etc/mysql/my.cnf` 190 | 191 | 192 | Extending image 193 | --------------- 194 | This image can be extended in Openshift using the `Source` build strategy or via the standalone 195 | [source-to-image](https://docs.openshift.com/container-platform/4.14/openshift_images/create-images.html#images-create-s2i_create-images) application (where available). 196 | For this, we will assume that you are using the `rhel8/mariadb-103` image, 197 | available via `mariadb:10.3` imagestream tag in Openshift. 198 | 199 | 200 | For example, to build a customized MariaDB database image `my-mariadb-rhel8` 201 | with a configuration from `https://github.com/sclorg/mariadb-container/tree/master/examples/extend-image` run: 202 | 203 | ``` 204 | $ oc new-app mariadb:10.3~https://github.com/sclorg/mariadb-container.git \ 205 | --name my-mariadb-rhel8 \ 206 | --context-dir=examples/extend-image \ 207 | --env MYSQL_OPERATIONS_USER=opuser \ 208 | --env MYSQL_OPERATIONS_PASSWORD=oppass \ 209 | --env MYSQL_DATABASE=opdb \ 210 | --env MYSQL_USER=user \ 211 | --env MYSQL_PASSWORD=pass 212 | ``` 213 | 214 | or via s2i: 215 | 216 | ``` 217 | $ s2i build --context-dir=examples/extend-image https://github.com/sclorg/mariadb-container.git rhel8/mariadb-103 my-mariadb-rhel8 218 | ``` 219 | 220 | The directory passed to Openshift can contain these directories: 221 | 222 | `mysql-cfg/` 223 | When starting the container, files from this directory will be used as 224 | a configuration for the `mysqld` daemon. 225 | `envsubst` command is run on this file to still allow customization of 226 | the image using environmental variables 227 | 228 | `mysql-pre-init/` 229 | Shell scripts (`*.sh`) available in this directory are sourced before 230 | `mysqld` daemon is started. 231 | 232 | `mysql-init/` 233 | Shell scripts (`*.sh`) available in this directory are sourced when 234 | `mysqld` daemon is started locally. In this phase, use `${mysql_flags}` 235 | to connect to the locally running daemon, for example `mysql $mysql_flags < dump.sql` 236 | 237 | Variables that can be used in the scripts provided to s2i: 238 | 239 | `$mysql_flags` 240 | arguments for the `mysql` tool that will connect to the locally running `mysqld` during initialization 241 | 242 | `$MYSQL_RUNNING_AS_MASTER` 243 | variable defined when the container is run with `run-mysqld-master` command 244 | 245 | `$MYSQL_RUNNING_AS_SLAVE` 246 | variable defined when the container is run with `run-mysqld-slave` command 247 | 248 | `$MYSQL_DATADIR_FIRST_INIT` 249 | variable defined when the container was initialized from the empty data dir 250 | 251 | During the s2i build all provided files are copied into `/opt/app-root/src` 252 | directory into the resulting image. If some configuration files are present 253 | in the destination directory, files with the same name are overwritten. 254 | Also only one file with the same name can be used for customization and user 255 | provided files are preferred over default files in 256 | `/usr/share/container-scripts/mysql/`- so it is possible to overwrite them. 257 | 258 | Same configuration directory structure can be used to customize the image 259 | every time the image is started using `podman run`. The directory has to be 260 | mounted into `/opt/app-root/src/` in the image 261 | (`-v ./image-configuration/:/opt/app-root/src/`). 262 | This overwrites customization built into the image. 263 | 264 | 265 | Securing the connection with SSL 266 | -------------------------------- 267 | In order to secure the connection with SSL, use the extending feature described 268 | above. In particular, put the SSL certificates into a separate directory: 269 | 270 | sslapp/mysql-certs/server-cert-selfsigned.pem 271 | sslapp/mysql-certs/server-key.pem 272 | 273 | And then put a separate configuration file into mysql-cfg: 274 | 275 | $> cat sslapp/mysql-cfg/ssl.cnf 276 | [mysqld] 277 | ssl-key=${APP_DATA}/mysql-certs/server-key.pem 278 | ssl-cert=${APP_DATA}/mysql-certs/server-cert-selfsigned.pem 279 | 280 | Such a directory `sslapp` can then be mounted into the container with -v, 281 | or a new container image can be built using s2i. 282 | 283 | 284 | Upgrading and data directory version checking 285 | --------------------------------------------- 286 | 287 | MySQL and MariaDB use versions that consist of three numbers X.Y.Z (e.g. 5.6.23). 288 | For version changes in Z part, the server's binary data format stays compatible and thus no 289 | special upgrade procedure is needed. For upgrades from X.Y to X.Y+1, consider doing manual 290 | steps as described at 291 | https://mariadb.com/kb/en/library/upgrading-from-mariadb-102-to-mariadb-103/ 292 | 293 | Skipping versions like from X.Y to X.Y+2 or downgrading to lower version is not supported; 294 | the only exception is ugrading from MariaDB 5.5 to MariaDB 10.0. 295 | 296 | **Important**: Upgrading to a new version is always risky and users are expected to make a full 297 | back-up of all data before. 298 | 299 | A safer solution to upgrade is to dump all data using `mysqldump` or `mysqldbexport` and then 300 | load the data using `mysql` or `mysqldbimport` into an empty (freshly initialized) database. 301 | 302 | Another way of proceeding with the upgrade is starting the new version of the `mysqld` daemon 303 | and run `mysql_upgrade` right after the start. This so called in-place upgrade is generally 304 | faster for large data directory, but only possible if upgrading from the very previous version, 305 | so skipping versions is not supported. 306 | 307 | This container detects whether the data needs to be upgraded using `mysql_upgrade` and 308 | we can control it by setting `MYSQL_DATADIR_ACTION` variable, which can have one or more of the following values: 309 | 310 | * `upgrade-warn` -- If the data version can be determined and the data come from a different version 311 | of the daemon, a warning is printed but the container starts. This is the default value. 312 | Since historically the version file `mysql_upgrade_info` was not created, when using this option, 313 | the version file is created if not exist, but no `mysql_upgrade` will be called. 314 | However, this automatic creation will be removed after few months, since the version should be 315 | created on most deployments at that point. 316 | * `upgrade-auto` -- `mysql_upgrade` is run at the beginning of the container start, when the local 317 | daemon is running, but only if the data version can be determined and the data come 318 | with the very previous version. A warning is printed if the data come from even older 319 | or newer version. This value effectively enables automatic upgrades, 320 | but it is always risky and users should still back-up all the data before starting the newer container. 321 | Set this option only if you have very good back-ups at any moment and you are fine to fail-over 322 | from the back-up. 323 | * `upgrade-force` -- `mysql_upgrade --force` is run at the beginning of the container start, when the local 324 | daemon is running, no matter what version of the daemon the data come from. 325 | This is also the way to create the missing version file `mysql_upgrade_info` if not present 326 | in the root of the data directory; this file holds information about the version of the data. 327 | 328 | There are also some other actions that you may want to run at the beginning of the container start, 329 | when the local daemon is running, no matter what version of the data is detected: 330 | 331 | * `optimize` -- runs `mysqlcheck --optimize`. It optimizes all the tables. 332 | * `analyze` -- runs `mysqlcheck --analyze`. It analyzes all the tables. 333 | * `disable` -- nothing is done regarding data directory version. 334 | 335 | Multiple values are separated by comma and run in-order, e.g. `MYSQL_DATADIR_ACTION="optimize,analyze"`. 336 | 337 | 338 | Changing the replication binlog_format 339 | -------------------------------------- 340 | Some applications may wish to use `row` binlog_formats (for example, those built 341 | with change-data-capture in mind). The default replication/binlog format is 342 | `statement` but to change it you can set the `MYSQL_BINLOG_FORMAT` environment 343 | variable. For example `MYSQL_BINLOG_FORMAT=row`. Now when you run the database 344 | with `master` replication turned on (ie, set the Docker/container `cmd` to be 345 | `run-mysqld-master`) the binlog will emit the actual data for the rows that change 346 | as opposed to the statements (ie, DML like insert...) that caused the change. 347 | 348 | 349 | Troubleshooting 350 | --------------- 351 | The mysqld deamon in the container logs to the standard output, so the log is available in the container log. The log can be examined by running: 352 | 353 | podman logs 354 | 355 | 356 | See also 357 | -------- 358 | Dockerfile and other sources for this container image are available on 359 | https://github.com/sclorg/mariadb-container. 360 | In that repository, the Dockerfile for RHEL8 is called Dockerfile.rhel8. 361 | -------------------------------------------------------------------------------- /10.5/root/usr/share/container-scripts/mysql/README.md: -------------------------------------------------------------------------------- 1 | MariaDB 10.5 SQL Database Server Docker image 2 | ============================================= 3 | 4 | This container image includes MariaDB 10.5 SQL database server for OpenShift and general usage. 5 | Users can choose between RHEL and CentOS Stream based images. 6 | The RHEL images are available in the [Red Hat Container Catalog](https://access.redhat.com/containers/), 7 | and the CentOS Stream images are available on [Quay.io/sclorg](https://quay.io/organization/sclorg). 8 | The resulting image can be run using [podman](https://github.com/containers/libpod). 9 | 10 | Note: while the examples in this README call `podman`, you can replace any such calls by `docker` with the same arguments 11 | 12 | Description 13 | ----------- 14 | 15 | This container image provides a containerized packaging of the MariaDB mysqld daemon 16 | and client application. The mysqld server daemon accepts connections from clients 17 | and provides access to content from MySQL databases on behalf of the clients. 18 | You can find more information on the MariaDB project from the project Web site 19 | (https://mariadb.org/). 20 | 21 | 22 | Usage 23 | ----- 24 | 25 | For this, we will assume that you are using the MariaDB 10.5 container image from the 26 | Red Hat Container Catalog called `rhel9/mariadb-105`. 27 | If you want to set only the mandatory environment variables and not store 28 | the database in a host directory, execute the following command: 29 | 30 | ``` 31 | $ podman run -d --name mariadb_database -e MYSQL_USER=user -e MYSQL_PASSWORD=pass -e MYSQL_DATABASE=db -p 3306:3306 rhel9/mariadb-105 32 | ``` 33 | 34 | This will create a container named `mariadb_database` running MySQL with database 35 | `db` and user with credentials `user:pass`. Port 3306 will be exposed and mapped 36 | to the host. If you want your database to be persistent across container executions, 37 | also add a `-v /host/db/path:/var/lib/mysql/data` argument. This will be the MySQL 38 | data directory. 39 | 40 | If the database directory is not initialized, the entrypoint script will first 41 | run [`mysql_install_db`](https://dev.mysql.com/doc/refman/5.6/en/mysql-install-db.html) 42 | and setup necessary database users and passwords. After the database is initialized, 43 | or if it was already present, `mysqld` is executed and will run as PID 1. You can 44 | stop the detached container by running `podman stop mariadb_database`. 45 | 46 | 47 | Environment variables and volumes 48 | --------------------------------- 49 | 50 | The image recognizes the following environment variables that you can set during 51 | initialization by passing `-e VAR=VALUE` to the Docker run command. 52 | 53 | **`MYSQL_USER`** 54 | User name for MySQL account to be created 55 | 56 | **`MYSQL_PASSWORD`** 57 | Password for the user account 58 | 59 | **`MYSQL_DATABASE`** 60 | Database name 61 | 62 | **`MYSQL_ROOT_PASSWORD`** 63 | Password for the root user (optional) 64 | 65 | **`MYSQL_CHARSET`** 66 | Default character set (optional) 67 | 68 | **`MYSQL_COLLATION`** 69 | Default collation (optional) 70 | 71 | 72 | The following environment variables influence the MySQL configuration file. They are all optional. 73 | 74 | **`MYSQL_LOWER_CASE_TABLE_NAMES (default: 0)`** 75 | Sets how the table names are stored and compared 76 | 77 | **`MYSQL_MAX_CONNECTIONS (default: 151)`** 78 | The maximum permitted number of simultaneous client connections 79 | 80 | **`MYSQL_MAX_ALLOWED_PACKET (default: 200M)`** 81 | The maximum size of one packet or any generated/intermediate string 82 | 83 | **`MYSQL_FT_MIN_WORD_LEN (default: 4)`** 84 | The minimum length of the word to be included in a FULLTEXT index 85 | 86 | **`MYSQL_FT_MAX_WORD_LEN (default: 20)`** 87 | The maximum length of the word to be included in a FULLTEXT index 88 | 89 | **`MYSQL_AIO (default: 1)`** 90 | Controls the `innodb_use_native_aio` setting value in case the native AIO is broken. See http://help.directadmin.com/item.php?id=529 91 | 92 | **`MYSQL_TABLE_OPEN_CACHE (default: 400)`** 93 | The number of open tables for all threads 94 | 95 | **`MYSQL_KEY_BUFFER_SIZE (default: 32M or 10% of available memory)`** 96 | The size of the buffer used for index blocks 97 | 98 | **`MYSQL_SORT_BUFFER_SIZE (default: 256K)`** 99 | The size of the buffer used for sorting 100 | 101 | **`MYSQL_READ_BUFFER_SIZE (default: 8M or 5% of available memory)`** 102 | The size of the buffer used for a sequential scan 103 | 104 | **`MYSQL_INNODB_BUFFER_POOL_SIZE (default: 32M or 50% of available memory)`** 105 | The size of the buffer pool where InnoDB caches table and index data 106 | 107 | **`MYSQL_INNODB_LOG_FILE_SIZE (default: 8M or 15% of available memory)`** 108 | The size of each log file in a log group 109 | 110 | **`MYSQL_INNODB_LOG_BUFFER_SIZE (default: 8M or 15% of available memory)`** 111 | The size of the buffer that InnoDB uses to write to the log files on disk 112 | 113 | **`MYSQL_DEFAULTS_FILE (default: /etc/my.cnf)`** 114 | Point to an alternative configuration file 115 | 116 | **`MYSQL_BINLOG_FORMAT (default: statement)`** 117 | Set sets the binlog format, supported values are `row` and `statement` 118 | 119 | **`MYSQL_LOG_QUERIES_ENABLED (default: 0)`** 120 | To enable query logging set this to `1` 121 | 122 | 123 | You can also set the following mount points by passing the `-v /host:/container` flag to Docker. 124 | 125 | **`/var/lib/mysql/data`** 126 | MySQL data directory 127 | 128 | 129 | **Notice: When mouting a directory from the host into the container, ensure that the mounted 130 | directory has the appropriate permissions and that the owner and group of the directory 131 | matches the user UID or name which is running inside the container.** 132 | 133 | 134 | MariaDB auto-tuning 135 | ------------------- 136 | 137 | When the MySQL image is run with the `--memory` parameter set and you didn't 138 | specify value for some parameters, their values will be automatically 139 | calculated based on the available memory. 140 | 141 | **`MYSQL_KEY_BUFFER_SIZE (default: 10%)`** 142 | `key_buffer_size` 143 | 144 | **`MYSQL_READ_BUFFER_SIZE (default: 5%)`** 145 | `read_buffer_size` 146 | 147 | **`MYSQL_INNODB_BUFFER_POOL_SIZE (default: 50%)`** 148 | `innodb_buffer_pool_size` 149 | 150 | **`MYSQL_INNODB_LOG_FILE_SIZE (default: 15%)`** 151 | `innodb_log_file_size` 152 | 153 | **`MYSQL_INNODB_LOG_BUFFER_SIZE (default: 15%)`** 154 | `innodb_log_buffer_size` 155 | 156 | 157 | 158 | MySQL root user 159 | --------------------------------- 160 | The root user has no password set by default, only allowing local connections. 161 | You can set it by setting the `MYSQL_ROOT_PASSWORD` environment variable. This 162 | will allow you to login to the root account remotely. Local connections will 163 | still not require a password. 164 | 165 | To disable remote root access, simply unset `MYSQL_ROOT_PASSWORD` and restart 166 | the container. 167 | 168 | 169 | Changing passwords 170 | ------------------ 171 | 172 | Since passwords are part of the image configuration, the only supported method 173 | to change passwords for the database user (`MYSQL_USER`) and root user is by 174 | changing the environment variables `MYSQL_PASSWORD` and `MYSQL_ROOT_PASSWORD`, 175 | respectively. 176 | 177 | Changing database passwords through SQL statements or any way other than through 178 | the environment variables aforementioned will cause a mismatch between the 179 | values stored in the variables and the actual passwords. Whenever a database 180 | container starts it will reset the passwords to the values stored in the 181 | environment variables. 182 | 183 | 184 | Default my.cnf file 185 | ------------------- 186 | With environment variables we are able to customize a lot of different parameters 187 | or configurations for the mysql bootstrap configurations. If you'd prefer to use 188 | your own configuration file, you can override the `MYSQL_DEFAULTS_FILE` env 189 | variable with the full path of the file you wish to use. For example, the default 190 | location is `/etc/my.cnf` but you can change it to `/etc/mysql/my.cnf` by setting 191 | `MYSQL_DEFAULTS_FILE=/etc/mysql/my.cnf` 192 | 193 | 194 | Extending image 195 | --------------- 196 | This image can be extended in Openshift using the `Source` build strategy or via the standalone 197 | [source-to-image](https://docs.openshift.com/container-platform/4.14/openshift_images/create-images.html#images-create-s2i_create-images) application (where available). 198 | For this, we will assume that you are using the `rhel9/mariadb-105` image, 199 | available via `mariadb:10.5` imagestream tag in Openshift. 200 | 201 | 202 | For example, to build a customized MariaDB database image `my-mariadb-rhel9` 203 | with a configuration from `https://github.com/sclorg/mariadb-container/tree/master/examples/extend-image` run: 204 | 205 | ``` 206 | $ oc new-app mariadb:10.5~https://github.com/sclorg/mariadb-container.git \ 207 | --name my-mariadb-rhel9 \ 208 | --context-dir=examples/extend-image \ 209 | --env MYSQL_OPERATIONS_USER=opuser \ 210 | --env MYSQL_OPERATIONS_PASSWORD=oppass \ 211 | --env MYSQL_DATABASE=opdb \ 212 | --env MYSQL_USER=user \ 213 | --env MYSQL_PASSWORD=pass 214 | ``` 215 | 216 | or via s2i: 217 | 218 | ``` 219 | $ s2i build --context-dir=examples/extend-image https://github.com/sclorg/mariadb-container.git rhel9/mariadb-105 my-mariadb-rhel9 220 | ``` 221 | 222 | The directory passed to Openshift can contain these directories: 223 | 224 | `mysql-cfg/` 225 | When starting the container, files from this directory will be used as 226 | a configuration for the `mysqld` daemon. 227 | `envsubst` command is run on this file to still allow customization of 228 | the image using environmental variables 229 | 230 | `mysql-pre-init/` 231 | Shell scripts (`*.sh`) available in this directory are sourced before 232 | `mysqld` daemon is started. 233 | 234 | `mysql-init/` 235 | Shell scripts (`*.sh`) available in this directory are sourced when 236 | `mysqld` daemon is started locally. In this phase, use `${mysql_flags}` 237 | to connect to the locally running daemon, for example `mysql $mysql_flags < dump.sql` 238 | 239 | Variables that can be used in the scripts provided to s2i: 240 | 241 | `$mysql_flags` 242 | arguments for the `mysql` tool that will connect to the locally running `mysqld` during initialization 243 | 244 | `$MYSQL_RUNNING_AS_MASTER` 245 | variable defined when the container is run with `run-mysqld-master` command 246 | 247 | `$MYSQL_RUNNING_AS_SLAVE` 248 | variable defined when the container is run with `run-mysqld-slave` command 249 | 250 | `$MYSQL_DATADIR_FIRST_INIT` 251 | variable defined when the container was initialized from the empty data dir 252 | 253 | During the s2i build all provided files are copied into `/opt/app-root/src` 254 | directory into the resulting image. If some configuration files are present 255 | in the destination directory, files with the same name are overwritten. 256 | Also only one file with the same name can be used for customization and user 257 | provided files are preferred over default files in 258 | `/usr/share/container-scripts/mysql/`- so it is possible to overwrite them. 259 | 260 | Same configuration directory structure can be used to customize the image 261 | every time the image is started using `podman run`. The directory has to be 262 | mounted into `/opt/app-root/src/` in the image 263 | (`-v ./image-configuration/:/opt/app-root/src/`). 264 | This overwrites customization built into the image. 265 | 266 | 267 | Securing the connection with SSL 268 | -------------------------------- 269 | In order to secure the connection with SSL, use the extending feature described 270 | above. In particular, put the SSL certificates into a separate directory: 271 | 272 | sslapp/mysql-certs/server-cert-selfsigned.pem 273 | sslapp/mysql-certs/server-key.pem 274 | 275 | And then put a separate configuration file into mysql-cfg: 276 | 277 | $> cat sslapp/mysql-cfg/ssl.cnf 278 | [mysqld] 279 | ssl-key=${APP_DATA}/mysql-certs/server-key.pem 280 | ssl-cert=${APP_DATA}/mysql-certs/server-cert-selfsigned.pem 281 | 282 | Such a directory `sslapp` can then be mounted into the container with -v, 283 | or a new container image can be built using s2i. 284 | 285 | 286 | Upgrading and data directory version checking 287 | --------------------------------------------- 288 | 289 | MySQL and MariaDB use versions that consist of three numbers X.Y.Z (e.g. 5.6.23). 290 | For version changes in Z part, the server's binary data format stays compatible and thus no 291 | special upgrade procedure is needed. For upgrades from X.Y to X.Y+1, consider doing manual 292 | steps as described at 293 | https://mariadb.com/kb/en/library/upgrading-from-mariadb-104-to-mariadb-105/ 294 | 295 | Skipping versions like from X.Y to X.Y+2 or downgrading to lower version is not supported; 296 | the only exception is ugrading from MariaDB 5.5 to MariaDB 10.0 and from MariaDB 10.3 to 10.5. 297 | 298 | **Important**: Upgrading to a new version is always risky and users are expected to make a full 299 | back-up of all data before. 300 | 301 | A safer solution to upgrade is to dump all data using `mysqldump` or `mysqldbexport` and then 302 | load the data using `mysql` or `mysqldbimport` into an empty (freshly initialized) database. 303 | 304 | Another way of proceeding with the upgrade is starting the new version of the `mysqld` daemon 305 | and run `mysql_upgrade` right after the start. This so called in-place upgrade is generally 306 | faster for large data directory, but only possible if upgrading from the very previous version, 307 | so skipping versions is not supported. 308 | 309 | This container detects whether the data needs to be upgraded using `mysql_upgrade` and 310 | we can control it by setting `MYSQL_DATADIR_ACTION` variable, which can have one or more of the following values: 311 | 312 | * `upgrade-warn` -- If the data version can be determined and the data come from a different version 313 | of the daemon, a warning is printed but the container starts. This is the default value. 314 | Since historically the version file `mysql_upgrade_info` was not created, when using this option, 315 | the version file is created if not exist, but no `mysql_upgrade` will be called. 316 | However, this automatic creation will be removed after few months, since the version should be 317 | created on most deployments at that point. 318 | * `upgrade-auto` -- `mysql_upgrade` is run at the beginning of the container start, when the local 319 | daemon is running, but only if the data version can be determined and the data come 320 | with the very previous version. A warning is printed if the data come from even older 321 | or newer version. This value effectively enables automatic upgrades, 322 | but it is always risky and users should still back-up all the data before starting the newer container. 323 | Set this option only if you have very good back-ups at any moment and you are fine to fail-over 324 | from the back-up. 325 | * `upgrade-force` -- `mysql_upgrade --force` is run at the beginning of the container start, when the local 326 | daemon is running, no matter what version of the daemon the data come from. 327 | This is also the way to create the missing version file `mysql_upgrade_info` if not present 328 | in the root of the data directory; this file holds information about the version of the data. 329 | 330 | There are also some other actions that you may want to run at the beginning of the container start, 331 | when the local daemon is running, no matter what version of the data is detected: 332 | 333 | * `optimize` -- runs `mysqlcheck --optimize`. It optimizes all the tables. 334 | * `analyze` -- runs `mysqlcheck --analyze`. It analyzes all the tables. 335 | * `disable` -- nothing is done regarding data directory version. 336 | 337 | Multiple values are separated by comma and run in-order, e.g. `MYSQL_DATADIR_ACTION="optimize,analyze"`. 338 | 339 | 340 | Changing the replication binlog_format 341 | -------------------------------------- 342 | Some applications may wish to use `row` binlog_formats (for example, those built 343 | with change-data-capture in mind). The default replication/binlog format is 344 | `statement` but to change it you can set the `MYSQL_BINLOG_FORMAT` environment 345 | variable. For example `MYSQL_BINLOG_FORMAT=row`. Now when you run the database 346 | with `master` replication turned on (ie, set the Docker/container `cmd` to be 347 | `run-mysqld-master`) the binlog will emit the actual data for the rows that change 348 | as opposed to the statements (ie, DML like insert...) that caused the change. 349 | 350 | 351 | Troubleshooting 352 | --------------- 353 | The mysqld deamon in the container logs to the standard output, so the log is available in the container log. The log can be examined by running: 354 | 355 | podman logs 356 | 357 | 358 | See also 359 | -------- 360 | Dockerfile and other sources for this container image are available on 361 | https://github.com/sclorg/mariadb-container. 362 | In that repository, the Dockerfile for RHEL8 is called Dockerfile.rhel8, 363 | the Dockerfile for RHEL9 is called Dockerfile.rhel9 364 | and the Dockerfile for CentOS Stream 9 is called Dockerfile.c9s. 365 | --------------------------------------------------------------------------------