|
| 1 | +# |
| 2 | +# NOTE: THIS DOCKERFILE IS GENERATED VIA "apply-templates.sh" |
| 3 | +# |
| 4 | +# PLEASE DO NOT EDIT IT DIRECTLY. |
| 5 | +# |
| 6 | + |
| 7 | +FROM oraclelinux:8-slim |
| 8 | + |
| 9 | +RUN set -eux; \ |
| 10 | + groupadd --system --gid 999 mysql; \ |
| 11 | + useradd --system --uid 999 --gid 999 --home-dir /var/lib/mysql --no-create-home mysql |
| 12 | + |
| 13 | +# add gosu for easy step-down from root |
| 14 | +# https://github.com/tianon/gosu/releases |
| 15 | +ENV GOSU_VERSION 1.16 |
| 16 | +RUN set -eux; \ |
| 17 | +# TODO find a better userspace architecture detection method than querying the kernel |
| 18 | + arch="$(uname -m)"; \ |
| 19 | + case "$arch" in \ |
| 20 | + aarch64) gosuArch='arm64' ;; \ |
| 21 | + x86_64) gosuArch='amd64' ;; \ |
| 22 | + *) echo >&2 "error: unsupported architecture: '$arch'"; exit 1 ;; \ |
| 23 | + esac; \ |
| 24 | + curl -fL -o /usr/local/bin/gosu.asc "https://github.com/tianon/gosu/releases/download/$GOSU_VERSION/gosu-$gosuArch.asc"; \ |
| 25 | + curl -fL -o /usr/local/bin/gosu "https://github.com/tianon/gosu/releases/download/$GOSU_VERSION/gosu-$gosuArch"; \ |
| 26 | + export GNUPGHOME="$(mktemp -d)"; \ |
| 27 | + gpg --batch --keyserver hkps://keys.openpgp.org --recv-keys B42F6819007F00F88E364FD4036A9C25BF357DD4; \ |
| 28 | + gpg --batch --verify /usr/local/bin/gosu.asc /usr/local/bin/gosu; \ |
| 29 | + rm -rf "$GNUPGHOME" /usr/local/bin/gosu.asc; \ |
| 30 | + chmod +x /usr/local/bin/gosu; \ |
| 31 | + gosu --version; \ |
| 32 | + gosu nobody true |
| 33 | + |
| 34 | +RUN set -eux; \ |
| 35 | + microdnf install -y \ |
| 36 | + bzip2 \ |
| 37 | + gzip \ |
| 38 | + openssl \ |
| 39 | + xz \ |
| 40 | + zstd \ |
| 41 | +# Oracle Linux 8+ is very slim :) |
| 42 | + findutils \ |
| 43 | + ; \ |
| 44 | + microdnf clean all |
| 45 | + |
| 46 | +RUN set -eux; \ |
| 47 | +# https://dev.mysql.com/doc/refman/8.0/en/checking-gpg-signature.html |
| 48 | +# gpg: key 3A79BD29: public key "MySQL Release Engineering <mysql-build@oss.oracle.com>" imported |
| 49 | + key='859BE8D7C586F538430B19C2467B942D3A79BD29'; \ |
| 50 | + export GNUPGHOME="$(mktemp -d)"; \ |
| 51 | + gpg --batch --keyserver keyserver.ubuntu.com --recv-keys "$key"; \ |
| 52 | + gpg --batch --export --armor "$key" > /etc/pki/rpm-gpg/RPM-GPG-KEY-mysql; \ |
| 53 | + rm -rf "$GNUPGHOME" |
| 54 | + |
| 55 | +ENV MYSQL_MAJOR innovation |
| 56 | +ENV MYSQL_VERSION 8.1.0-1.el8 |
| 57 | + |
| 58 | +RUN set -eu; \ |
| 59 | + . /etc/os-release; \ |
| 60 | + { \ |
| 61 | + echo '[mysqlinnovation-server-minimal]'; \ |
| 62 | + echo 'name=MySQL innovation Server Minimal'; \ |
| 63 | + echo 'enabled=1'; \ |
| 64 | + echo "baseurl=https://repo.mysql.com/yum/mysql-innovation-community/docker/el/${VERSION_ID%%[.-]*}/\$basearch/"; \ |
| 65 | + echo 'gpgcheck=1'; \ |
| 66 | + echo 'gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql'; \ |
| 67 | +# https://github.com/docker-library/mysql/pull/680#issuecomment-825930524 |
| 68 | + echo 'module_hotfixes=true'; \ |
| 69 | + } | tee /etc/yum.repos.d/mysql-community-minimal.repo |
| 70 | + |
| 71 | +RUN set -eux; \ |
| 72 | + microdnf install -y "mysql-community-server-minimal-$MYSQL_VERSION"; \ |
| 73 | + microdnf clean all; \ |
| 74 | +# the "socket" value in the Oracle packages is set to "/var/lib/mysql" which isn't a great place for the socket (we want it in "/var/run/mysqld" instead) |
| 75 | +# https://github.com/docker-library/mysql/pull/680#issuecomment-636121520 |
| 76 | + grep -F 'socket=/var/lib/mysql/mysql.sock' /etc/my.cnf; \ |
| 77 | + sed -i 's!^socket=.*!socket=/var/run/mysqld/mysqld.sock!' /etc/my.cnf; \ |
| 78 | + grep -F 'socket=/var/run/mysqld/mysqld.sock' /etc/my.cnf; \ |
| 79 | + { echo '[client]'; echo 'socket=/var/run/mysqld/mysqld.sock'; } >> /etc/my.cnf; \ |
| 80 | + \ |
| 81 | +# make sure users dumping files in "/etc/mysql/conf.d" still works |
| 82 | + ! grep -F '!includedir' /etc/my.cnf; \ |
| 83 | + { echo; echo '!includedir /etc/mysql/conf.d/'; } >> /etc/my.cnf; \ |
| 84 | + mkdir -p /etc/mysql/conf.d; \ |
| 85 | +# ensure these directories exist and have useful permissions |
| 86 | +# the rpm package has different opinions on the mode of `/var/run/mysqld`, so this needs to be after install |
| 87 | + mkdir -p /var/lib/mysql /var/run/mysqld; \ |
| 88 | + chown mysql:mysql /var/lib/mysql /var/run/mysqld; \ |
| 89 | +# ensure that /var/run/mysqld (used for socket and lock files) is writable regardless of the UID our mysqld instance ends up having at runtime |
| 90 | + chmod 1777 /var/lib/mysql /var/run/mysqld; \ |
| 91 | + \ |
| 92 | + mkdir /docker-entrypoint-initdb.d; \ |
| 93 | + \ |
| 94 | + mysqld --version; \ |
| 95 | + mysql --version |
| 96 | + |
| 97 | +RUN set -eu; \ |
| 98 | + . /etc/os-release; \ |
| 99 | + { \ |
| 100 | + echo '[mysql-tools-community]'; \ |
| 101 | + echo 'name=MySQL Tools Community'; \ |
| 102 | + echo "baseurl=https://repo.mysql.com/yum/mysql-tools-community/el/${VERSION_ID%%[.-]*}/\$basearch/"; \ |
| 103 | + echo 'enabled=1'; \ |
| 104 | + echo 'gpgcheck=1'; \ |
| 105 | + echo 'gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql'; \ |
| 106 | +# https://github.com/docker-library/mysql/pull/680#issuecomment-825930524 |
| 107 | + echo 'module_hotfixes=true'; \ |
| 108 | + } | tee /etc/yum.repos.d/mysql-community-tools.repo |
| 109 | +ENV MYSQL_SHELL_VERSION 8.0.34-1.el8 |
| 110 | +RUN set -eux; \ |
| 111 | + microdnf install -y "mysql-shell-$MYSQL_SHELL_VERSION"; \ |
| 112 | + microdnf clean all; \ |
| 113 | + \ |
| 114 | + mysqlsh --version |
| 115 | + |
| 116 | +VOLUME /var/lib/mysql |
| 117 | + |
| 118 | +COPY docker-entrypoint.sh /usr/local/bin/ |
| 119 | +ENTRYPOINT ["docker-entrypoint.sh"] |
| 120 | + |
| 121 | +EXPOSE 3306 33060 |
| 122 | +CMD ["mysqld"] |
0 commit comments