浏览代码

Use Mysql official docker image (#8003)

Joan Miquel 2 年之前
父节点
当前提交
15a641c95c
共有 3 个文件被更改,包括 14 次插入48 次删除
  1. 4 4
      toolset/databases/mysql/create.sql
  2. 3 0
      toolset/databases/mysql/my.cnf
  3. 7 44
      toolset/databases/mysql/mysql.dockerfile

+ 4 - 4
toolset/databases/mysql/create.sql

@@ -2,17 +2,17 @@
 # http://stackoverflow.com/questions/37719818/the-server-time-zone-value-aest-is-unrecognized-or-represents-more-than-one-ti
 SET GLOBAL time_zone = '+00:00';
 
-CREATE USER 'benchmarkdbuser'@'%' IDENTIFIED WITH mysql_native_password BY 'benchmarkdbpass';
-CREATE USER 'benchmarkdbuser'@'localhost' IDENTIFIED WITH mysql_native_password BY 'benchmarkdbpass';
+CREATE USER IF NOT EXISTS 'benchmarkdbuser'@'%' IDENTIFIED WITH mysql_native_password BY 'benchmarkdbpass';
+CREATE USER IF NOT EXISTS 'benchmarkdbuser'@'localhost' IDENTIFIED WITH mysql_native_password BY 'benchmarkdbpass';
 
 -- GitHub Actions/CI run the database server on the same system as the benchmarks.
 -- Because we setup MySQL with the skip-name-resolve option, the IP address 127.0.0.1 might not be resolved to localhost
 -- anymore. This does not seem to matter, as long as Unix sockets are being used (e.g. when setting up the docker image),
 -- because the host is set to be localhost implicitly, but it matters for local TCP connections.
-CREATE USER 'benchmarkdbuser'@'127.0.0.1' IDENTIFIED WITH mysql_native_password BY 'benchmarkdbpass';
+CREATE USER IF NOT EXISTS 'benchmarkdbuser'@'127.0.0.1' IDENTIFIED WITH mysql_native_password BY 'benchmarkdbpass';
 
 # modified from SO answer http://stackoverflow.com/questions/5125096/for-loop-in-mysql
-CREATE DATABASE hello_world;
+CREATE DATABASE IF NOT EXISTS hello_world;
 USE hello_world;
 
 CREATE TABLE  world (

+ 3 - 0
toolset/databases/mysql/my.cnf

@@ -5,6 +5,7 @@
 [client]
 port            = 3306
 socket          = /var/run/mysqld/mysqld.sock
+default-character-set=utf8
 
 #######################
 # mysqld              #
@@ -20,6 +21,8 @@ default_authentication_plugin = mysql_native_password
 user            = mysql
 pid-file        = /var/run/mysqld/mysqld.pid
 socket          = /var/run/mysqld/mysqld.sock
+datadir         = /ssd
+secure-file-priv= NULL
 port            = 3306
 skip-external-locking
 skip-name-resolve

+ 7 - 44
toolset/databases/mysql/mysql.dockerfile

@@ -1,46 +1,9 @@
-FROM ubuntu:22.04
+FROM mysql:8.0-debian
 
-ARG MYSQL_VERSION=8.0
+ENV MYSQL_ROOT_PASSWORD=root
+ENV MYSQL_USER=benchmarkdbuser
+ENV MYSQL_PASSWORD=benchmarkdbpass
+ENV MYSQL_DATABASE=hello_world
 
-COPY create.sql /tmp/
-COPY my.cnf ./
-
-ARG DEBIAN_FRONTEND=noninteractive
-ADD "https://keyserver.ubuntu.com/pks/lookup?op=get&search=0x859be8d7c586f538430b19c2467b942d3a79bd29" \
-    /etc/apt/keyrings/mysql.asc
-RUN chmod 644 /etc/apt/keyrings/mysql.asc && \
-    apt-get -yqq update && \
-    apt-get -yqq install \
-      apt-utils \
-      locales \
-      lsb-release && \
-    echo "deb [ signed-by=/etc/apt/keyrings/mysql.asc ] http://repo.mysql.com/apt/ubuntu $(lsb_release -cs) mysql-${MYSQL_VERSION}" > \
-      /etc/apt/sources.list.d/mysql.list && \
-    locale-gen en_US.UTF-8
-
-ENV LANG=en_US.UTF-8
-ENV LANGUAGE=en_US:en
-ENV LC_ALL=en_US.UTF-8
-
-# https://bugs.mysql.com/bug.php?id=90695
-RUN ["/bin/bash", "-c", "debconf-set-selections <<< \"mysql-server mysql-server/lowercase-table-names select Enabled\""]
-RUN ["/bin/bash", "-c", "debconf-set-selections <<< \"mysql-community-server mysql-community-server/data-dir select 'Y'\""]
-RUN ["/bin/bash", "-c", "debconf-set-selections <<< \"mysql-community-server mysql-community-server/root-pass password secret\""]
-RUN ["/bin/bash", "-c", "debconf-set-selections <<< \"mysql-community-server mysql-community-server/re-root-pass password secret\""]
-RUN apt-get -yqq update && \
-    apt-get -yqq install mysql-server && \
-    mv /etc/mysql/my.cnf /etc/mysql/my.cnf.orig && \
-    mv my.cnf /etc/mysql/my.cnf && \
-    rm -rf /ssd/log/mysql /ssd/mysql && \
-    cp -Rp /var/lib/mysql /ssd  && \
-    cp -Rp /var/log/mysql /ssd/log && \
-    mkdir -p /var/run/mysqld && \
-    chown -R mysql:mysql /ssd /var/lib/mysql /var/log/mysql /var/run/mysqld && \
-    (mysqld &) && \
-    until mysqladmin -uroot -psecret ping; do sleep 1; done && \
-    mysqladmin -uroot -psecret flush-hosts && \
-    mysql -uroot -psecret < /tmp/create.sql && \
-    mysqladmin -uroot -psecret shutdown && \
-    chown -R mysql:mysql /ssd /var/lib/mysql /var/log/mysql /var/run/mysqld
-
-CMD ["mysqld"]
+COPY my.cnf /etc/mysql/
+COPY create.sql /docker-entrypoint-initdb.d/