Skip to content

Commit

Permalink
Use new -core packages for 8.0.1+
Browse files Browse the repository at this point in the history
The packages mysql-community-client-core and mysql-community-server-core
contain only the binaries needed by the client and server, with no
configuration, services or debug binaries, making them significantly
smaller in size.

* Install -core packages instead of full mysql-server
  Images that build on this and install further packages that depend on
  MySQL may lose the size benefit if the dep is on "mysql-server", but
  should otherwise work as before.
* Add all config files, since core packages do not include any.
  Included the config files in git instead of generating them in the build
  script, to make it a bit easier to see exactly what the default config
  of the image is.
  • Loading branch information
ltangvald committed Apr 11, 2017
1 parent 6b1dc54 commit ba70c92
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 8 deletions.
11 changes: 3 additions & 8 deletions 8.0/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
FROM debian:jessie

# add our user and group first to make sure their IDs get assigned consistently, regardless of whatever dependencies get added
RUN groupadd -r mysql && useradd -r -g mysql mysql

Expand Down Expand Up @@ -54,19 +53,15 @@ RUN { \
echo mysql-community-server mysql-community-server/re-root-pass password ''; \
echo mysql-community-server mysql-community-server/remove-test-db select false; \
} | debconf-set-selections \
&& apt-get update && apt-get install -y mysql-server="${MYSQL_VERSION}" && rm -rf /var/lib/apt/lists/* \
&& apt-get update && apt-get install -y mysql-community-client-core="${MYSQL_VERSION}" mysql-community-server-core="${MYSQL_VERSION}" && rm -rf /var/lib/apt/lists/* \
&& rm -rf /var/lib/mysql && mkdir -p /var/lib/mysql /var/run/mysqld \
&& chown -R mysql:mysql /var/lib/mysql /var/run/mysqld \
# 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
&& chmod 777 /var/run/mysqld

# comment out a few problematic configuration values
# don't reverse lookup hostnames, they are usually another container
RUN sed -Ei 's/^(bind-address|log)/#&/' /etc/mysql/mysql.conf.d/mysqld.cnf \
&& echo '[mysqld]\nskip-host-cache\nskip-name-resolve' > /etc/mysql/conf.d/docker.cnf

VOLUME /var/lib/mysql

# Config files
COPY mysql/ /etc/mysql/
COPY docker-entrypoint.sh /usr/local/bin/
RUN ln -s usr/local/bin/docker-entrypoint.sh /entrypoint.sh # backwards compat
ENTRYPOINT ["docker-entrypoint.sh"]
Expand Down
3 changes: 3 additions & 0 deletions 8.0/mysql/conf.d/docker.cnf
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[mysqld]
skip-host-cache
skip-name-resolve
17 changes: 17 additions & 0 deletions 8.0/mysql/my.cnf
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; version 2 of the License.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA

!includedir /etc/mysql/conf.d/
!includedir /etc/mysql/mysql.conf.d/
28 changes: 28 additions & 0 deletions 8.0/mysql/mysql.conf.d/mysqld.cnf
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Copyright (c) 2014, 2017, Oracle and/or its affiliates. All rights reserved.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; version 2 of the License.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA

#
# The MySQL Server configuration file.
#
# For explanations see
# http://dev.mysql.com/doc/mysql/en/server-system-variables.html

[mysqld]
pid-file = /var/run/mysqld/mysqld.pid
socket = /var/run/mysqld/mysqld.sock
datadir = /var/lib/mysql
secure-file-priv= NULL
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0

0 comments on commit ba70c92

Please sign in to comment.