|
| 1 | +# MySQL debug build for e2e binlog INCIDENT_EVENT testing. |
| 2 | +# |
| 3 | +# The official mysql image ships only the minimal server, which is not compiled WITH_DEBUG and |
| 4 | +# therefore lacks the DBUG facility needed to inject a LOST_EVENTS incident at runtime |
| 5 | +# (SET GLOBAL debug='+d,binlog_inject_incident'). We swap the minimal server for the full server |
| 6 | +# plus mysqld-debug, then route only the final foreground server to mysqld-debug. The stock |
| 7 | +# entrypoint's config checks, datadir initialization, and temporary init server keep using the |
| 8 | +# release binary because the debug binary can trip InnoDB assertions on that path. |
| 9 | +ARG MYSQL_VERSION=8.0.46 |
| 10 | +FROM mysql:${MYSQL_VERSION} |
| 11 | +ARG MYSQL_VERSION |
| 12 | + |
| 13 | +LABEL org.opencontainers.image.source="https://github.com/PeerDB-io/peerdb" \ |
| 14 | + org.opencontainers.image.title="PeerDB MySQL Debug" \ |
| 15 | + org.opencontainers.image.description="MySQL ${MYSQL_VERSION} debug image for PeerDB e2e tests" |
| 16 | + |
| 17 | +# Keep the debug/full-server RPMs exactly matched to the server-minimal RPM in the base image. |
| 18 | +# This lets MYSQL_VERSION move without independently hard-coding package versions here. |
| 19 | +# |
| 20 | +# Installing mysql-community-server rewrites /etc/my.cnf with RPM defaults, so preserve the |
| 21 | +# official Docker image config first. It keeps server logs on stderr and includes conf.d. |
| 22 | +RUN set -eux; \ |
| 23 | + mysql_rpm_version="$(rpm -q --qf '%{VERSION}-%{RELEASE}.%{ARCH}' mysql-community-server-minimal)"; \ |
| 24 | + cp /etc/my.cnf /tmp/docker-my.cnf; \ |
| 25 | + printf '%s\n' \ |
| 26 | + '[mysql80-community]' \ |
| 27 | + 'name=MySQL 8.0 Community Server' \ |
| 28 | + 'baseurl=https://repo.mysql.com/yum/mysql-8.0-community/el/9/$basearch/' \ |
| 29 | + 'enabled=1' \ |
| 30 | + 'gpgcheck=1' \ |
| 31 | + 'gpgkey=https://repo.mysql.com/RPM-GPG-KEY-mysql-2023' \ |
| 32 | + > /etc/yum.repos.d/mysql-community-debug.repo \ |
| 33 | + && microdnf -y remove mysql-community-server-minimal \ |
| 34 | + && microdnf -y --setopt=install_weak_deps=0 install \ |
| 35 | + "mysql-community-client-${mysql_rpm_version}" \ |
| 36 | + "mysql-community-client-plugins-${mysql_rpm_version}" \ |
| 37 | + "mysql-community-common-${mysql_rpm_version}" \ |
| 38 | + "mysql-community-icu-data-files-${mysql_rpm_version}" \ |
| 39 | + "mysql-community-libs-${mysql_rpm_version}" \ |
| 40 | + "mysql-community-server-${mysql_rpm_version}" \ |
| 41 | + "mysql-community-server-debug-${mysql_rpm_version}" \ |
| 42 | + && microdnf clean all \ |
| 43 | + && rm -f /etc/yum.repos.d/mysql-community-debug.repo |
| 44 | + |
| 45 | +# Restore the official Docker config, but keep the RPM socket path. The official image normally |
| 46 | +# uses /var/run/mysqld/mysqld.sock and creates a compatibility symlink in /var/lib/mysql; mysqld-debug |
| 47 | +# asserts while scanning that dangling symlink during final startup. |
| 48 | +RUN set -eux; \ |
| 49 | + cp /tmp/docker-my.cnf /etc/my.cnf; \ |
| 50 | + sed -i 's!socket=/var/run/mysqld/mysqld.sock!socket=/var/lib/mysql/mysql.sock!g' /etc/my.cnf; \ |
| 51 | + rm -f /tmp/docker-my.cnf |
| 52 | + |
| 53 | +# Route entrypoint checks, datadir init, and the temporary init server to the release binary. |
| 54 | +# Only the final foreground server should use mysqld-debug; running debug for init/temp startup |
| 55 | +# trips InnoDB debug assertions before the test can run. |
| 56 | +RUN set -eux; \ |
| 57 | + mv /usr/sbin/mysqld /usr/sbin/mysqld-release; \ |
| 58 | + printf '%s\n' \ |
| 59 | + '#!/bin/bash' \ |
| 60 | + 'for arg in "$@"; do' \ |
| 61 | + ' case "$arg" in' \ |
| 62 | + ' --initialize|--initialize-insecure|--daemonize|--verbose|--help|--validate-config)' \ |
| 63 | + ' exec /usr/sbin/mysqld-release "$@"' \ |
| 64 | + ' ;;' \ |
| 65 | + ' esac' \ |
| 66 | + 'done' \ |
| 67 | + 'exec /usr/sbin/mysqld-debug "$@"' \ |
| 68 | + > /usr/sbin/mysqld; \ |
| 69 | + chmod +x /usr/sbin/mysqld |
0 commit comments