Skip to content

Commit 9898215

Browse files
authored
Merge pull request #259 from infosiftr/automatic-ssl
Add "openssl" and invoke "mysql_ssl_rsa_setup" at runtime so that automatic SSL works the same as the MySQL packages
2 parents 64e0cf2 + eeb0c33 commit 9898215

File tree

4 files changed

+28
-2
lines changed

4 files changed

+28
-2
lines changed

5.7/Dockerfile

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,18 @@ RUN set -x \
1919

2020
RUN mkdir /docker-entrypoint-initdb.d
2121

22+
RUN apt-get update && apt-get install -y --no-install-recommends \
23+
# for MYSQL_RANDOM_ROOT_PASSWORD
24+
pwgen \
25+
# for mysql_ssl_rsa_setup
26+
openssl \
2227
# FATAL ERROR: please install the following Perl modules before executing /usr/local/mysql/scripts/mysql_install_db:
2328
# File::Basename
2429
# File::Copy
2530
# Sys::Hostname
2631
# Data::Dumper
27-
RUN apt-get update && apt-get install -y perl pwgen --no-install-recommends && rm -rf /var/lib/apt/lists/*
32+
perl \
33+
&& rm -rf /var/lib/apt/lists/*
2834

2935
RUN set -ex; \
3036
# gpg: key 5072E1F5: public key "MySQL Release Engineering <[email protected]>" imported

5.7/docker-entrypoint.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,13 @@ if [ "$1" = 'mysqld' -a -z "$wantHelp" ]; then
8787
"$@" --initialize-insecure
8888
echo 'Database initialized'
8989

90+
if command -v mysql_ssl_rsa_setup > /dev/null && [ ! -e "$DATADIR/server-key.pem" ]; then
91+
# https://github.com/mysql/mysql-server/blob/23032807537d8dd8ee4ec1c4d40f0633cd4e12f9/packaging/deb-in/extra/mysql-systemd-start#L81-L84
92+
echo 'Initializing certificates'
93+
mysql_ssl_rsa_setup --datadir="$DATADIR"
94+
echo 'Certificates initialized'
95+
fi
96+
9097
"$@" --skip-networking --socket=/var/run/mysqld/mysqld.sock &
9198
pid="$!"
9299

8.0/Dockerfile

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,18 @@ RUN set -x \
1919

2020
RUN mkdir /docker-entrypoint-initdb.d
2121

22+
RUN apt-get update && apt-get install -y --no-install-recommends \
23+
# for MYSQL_RANDOM_ROOT_PASSWORD
24+
pwgen \
25+
# for mysql_ssl_rsa_setup
26+
openssl \
2227
# FATAL ERROR: please install the following Perl modules before executing /usr/local/mysql/scripts/mysql_install_db:
2328
# File::Basename
2429
# File::Copy
2530
# Sys::Hostname
2631
# Data::Dumper
27-
RUN apt-get update && apt-get install -y perl pwgen --no-install-recommends && rm -rf /var/lib/apt/lists/*
32+
perl \
33+
&& rm -rf /var/lib/apt/lists/*
2834

2935
RUN set -ex; \
3036
# gpg: key 5072E1F5: public key "MySQL Release Engineering <[email protected]>" imported

8.0/docker-entrypoint.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,13 @@ if [ "$1" = 'mysqld' -a -z "$wantHelp" ]; then
8787
"$@" --initialize-insecure
8888
echo 'Database initialized'
8989

90+
if command -v mysql_ssl_rsa_setup > /dev/null && [ ! -e "$DATADIR/server-key.pem" ]; then
91+
# https://github.com/mysql/mysql-server/blob/23032807537d8dd8ee4ec1c4d40f0633cd4e12f9/packaging/deb-in/extra/mysql-systemd-start#L81-L84
92+
echo 'Initializing certificates'
93+
mysql_ssl_rsa_setup --datadir="$DATADIR"
94+
echo 'Certificates initialized'
95+
fi
96+
9097
"$@" --skip-networking --socket=/var/run/mysqld/mysqld.sock &
9198
pid="$!"
9299

0 commit comments

Comments
 (0)