From c9404e5bffe2f0a3818c79ded628242f2264b0e1 Mon Sep 17 00:00:00 2001 From: Ken Bingham Date: Thu, 17 May 2018 22:31:31 -0400 Subject: [PATCH 1/7] strip trailing whack from DATADIR --- 5.7/docker-entrypoint.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/5.7/docker-entrypoint.sh b/5.7/docker-entrypoint.sh index 112d88c22..16ebbeb2b 100755 --- a/5.7/docker-entrypoint.sh +++ b/5.7/docker-entrypoint.sh @@ -95,7 +95,7 @@ if [ "$1" = 'mysqld' -a -z "$wantHelp" ]; then # Get config DATADIR="$(_get_config 'datadir' "$@")" - if [ ! -d "$DATADIR/mysql" ]; then + if [ ! -d "${DATADIR%/}/mysql" ]; then file_env 'MYSQL_ROOT_PASSWORD' if [ -z "$MYSQL_ROOT_PASSWORD" -a -z "$MYSQL_ALLOW_EMPTY_PASSWORD" -a -z "$MYSQL_RANDOM_ROOT_PASSWORD" ]; then echo >&2 'error: database is uninitialized and password option is not specified ' From de5f48489afaed8de46800e64c113fd56aff53a0 Mon Sep 17 00:00:00 2001 From: Ken Bingham Date: Thu, 17 May 2018 22:32:45 -0400 Subject: [PATCH 2/7] also recursively chown initdb.d dir because if mounted volume the scripts are not necessarily readable depending on mountpoint perms and after this point in the script all execution is EID mysql --- 5.7/docker-entrypoint.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/5.7/docker-entrypoint.sh b/5.7/docker-entrypoint.sh index 16ebbeb2b..c7045e297 100755 --- a/5.7/docker-entrypoint.sh +++ b/5.7/docker-entrypoint.sh @@ -85,7 +85,7 @@ if [ "$1" = 'mysqld' -a -z "$wantHelp" -a "$(id -u)" = '0' ]; then _check_config "$@" DATADIR="$(_get_config 'datadir' "$@")" mkdir -p "$DATADIR" - chown -R mysql:mysql "$DATADIR" + chown -R mysql:mysql "$DATADIR" /docker-entrypoint-initdb.d/ exec gosu mysql "$BASH_SOURCE" "$@" fi From 72b07281eeb73ad40d8f75d6e4c84c09898aff94 Mon Sep 17 00:00:00 2001 From: Ken Bingham Date: Thu, 17 May 2018 22:34:42 -0400 Subject: [PATCH 3/7] set working dir so we can use relative path to executable which avoids a failure mode preventing execution of entrypoint in some version I can't remember --- 5.7/Dockerfile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/5.7/Dockerfile b/5.7/Dockerfile index aa2441798..7b2add2ba 100644 --- a/5.7/Dockerfile +++ b/5.7/Dockerfile @@ -70,9 +70,10 @@ RUN { \ VOLUME /var/lib/mysql +WORKDIR /usr/local/bin COPY docker-entrypoint.sh /usr/local/bin/ RUN ln -s usr/local/bin/docker-entrypoint.sh /entrypoint.sh # backwards compat -ENTRYPOINT ["docker-entrypoint.sh"] +ENTRYPOINT ["./docker-entrypoint.sh"] EXPOSE 3306 CMD ["mysqld"] From d16aaed34c671cf294d20f279610f37806da1541 Mon Sep 17 00:00:00 2001 From: Ken Bingham Date: Thu, 17 May 2018 22:35:15 -0400 Subject: [PATCH 4/7] let the symlink target be absolute --- 5.7/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/5.7/Dockerfile b/5.7/Dockerfile index 7b2add2ba..2288a93b1 100644 --- a/5.7/Dockerfile +++ b/5.7/Dockerfile @@ -72,7 +72,7 @@ VOLUME /var/lib/mysql WORKDIR /usr/local/bin COPY docker-entrypoint.sh /usr/local/bin/ -RUN ln -s usr/local/bin/docker-entrypoint.sh /entrypoint.sh # backwards compat +RUN ln -s /usr/local/bin/docker-entrypoint.sh /entrypoint.sh # backwards compat ENTRYPOINT ["./docker-entrypoint.sh"] EXPOSE 3306 From 3db92adb0638921f17f9cb0d0a24adad820ead66 Mon Sep 17 00:00:00 2001 From: Ken Bingham Date: Fri, 18 May 2018 00:41:19 -0400 Subject: [PATCH 5/7] source seed scripts from a copy of the initdb.d dir because EID mysql may not have permission to read a docker volume mounted on the usual initdb.d path --- 5.7/docker-entrypoint.sh | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/5.7/docker-entrypoint.sh b/5.7/docker-entrypoint.sh index c7045e297..db9c56862 100755 --- a/5.7/docker-entrypoint.sh +++ b/5.7/docker-entrypoint.sh @@ -84,8 +84,11 @@ _get_config() { if [ "$1" = 'mysqld' -a -z "$wantHelp" -a "$(id -u)" = '0' ]; then _check_config "$@" DATADIR="$(_get_config 'datadir' "$@")" - mkdir -p "$DATADIR" - chown -R mysql:mysql "$DATADIR" /docker-entrypoint-initdb.d/ + # seed scripts from a copy of the initdb.d dir because EID mysql may not have permission to read + # a docker volume mounted on the usual initdb.d path + mkdir -p "$DATADIR" /etc/mysql/initdb.d + cp -RT /docker-entrypoint-initdb.d /etc/mysql/initdb.d + chown -R mysql:mysql "$DATADIR" /etc/mysql/initdb.d exec gosu mysql "$BASH_SOURCE" "$@" fi @@ -191,7 +194,7 @@ if [ "$1" = 'mysqld' -a -z "$wantHelp" ]; then fi echo - for f in /docker-entrypoint-initdb.d/*; do + for f in /etc/mysql/initdb.d/*; do process_init_file "$f" "${mysql[@]}" done From a428f8cbc8ef9d6dc37e294820ca54b9953f7294 Mon Sep 17 00:00:00 2001 From: Ken Bingham Date: Fri, 18 May 2018 00:49:48 -0400 Subject: [PATCH 6/7] fixup read+execute filemode on entrypoint --- 5.7/Dockerfile | 3 ++- 5.7/docker-entrypoint.sh | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/5.7/Dockerfile b/5.7/Dockerfile index 2288a93b1..7ef237d84 100644 --- a/5.7/Dockerfile +++ b/5.7/Dockerfile @@ -71,7 +71,8 @@ RUN { \ VOLUME /var/lib/mysql WORKDIR /usr/local/bin -COPY docker-entrypoint.sh /usr/local/bin/ +COPY ./docker-entrypoint.sh . +RUN chmod 0755 ./docker-entrypoint.sh RUN ln -s /usr/local/bin/docker-entrypoint.sh /entrypoint.sh # backwards compat ENTRYPOINT ["./docker-entrypoint.sh"] diff --git a/5.7/docker-entrypoint.sh b/5.7/docker-entrypoint.sh index db9c56862..1e0e8dc6e 100755 --- a/5.7/docker-entrypoint.sh +++ b/5.7/docker-entrypoint.sh @@ -86,9 +86,9 @@ if [ "$1" = 'mysqld' -a -z "$wantHelp" -a "$(id -u)" = '0' ]; then DATADIR="$(_get_config 'datadir' "$@")" # seed scripts from a copy of the initdb.d dir because EID mysql may not have permission to read # a docker volume mounted on the usual initdb.d path - mkdir -p "$DATADIR" /etc/mysql/initdb.d + mkdir -p "$DATADIR" /etc/mysql/initdb.d/ cp -RT /docker-entrypoint-initdb.d /etc/mysql/initdb.d - chown -R mysql:mysql "$DATADIR" /etc/mysql/initdb.d + chown -R mysql:mysql "$DATADIR" /etc/mysql/initdb.d/ exec gosu mysql "$BASH_SOURCE" "$@" fi From c7fdd8a03a67145be835671c83da42ab68b5084f Mon Sep 17 00:00:00 2001 From: Ken Bingham Date: Sat, 19 May 2018 12:01:25 -0400 Subject: [PATCH 7/7] try several keyservers because gosu intermittently fails with "unable to assign host address" when service is not available --- 5.7/Dockerfile | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/5.7/Dockerfile b/5.7/Dockerfile index 7ef237d84..4e40e40e7 100644 --- a/5.7/Dockerfile +++ b/5.7/Dockerfile @@ -38,7 +38,14 @@ RUN set -ex; \ # gpg: key 5072E1F5: public key "MySQL Release Engineering " imported key='A4A9406876FCBD3C456770C88C718D3B5072E1F5'; \ export GNUPGHOME="$(mktemp -d)"; \ - gpg --keyserver ha.pool.sks-keyservers.net --recv-keys "$key"; \ + for keyserver in $(shuf -e \ + ha.pool.sks-keyservers.net \ + hkp://p80.pool.sks-keyservers.net:80 \ + keyserver.ubuntu.com \ + hkp://keyserver.ubuntu.com:80 \ + pgp.mit.edu) ; do \ + gpg --keyserver $keyserver --recv-keys "$key" && break || true ; \ + done && \ gpg --export "$key" > /etc/apt/trusted.gpg.d/mysql.gpg; \ rm -rf "$GNUPGHOME"; \ apt-key list > /dev/null