2014-11-24 15:31:55 -08:00
# vim:set ft=dockerfile:
2018-07-13 13:56:30 -07:00
FROM ubuntu:%%SUITE%%
2014-11-24 15:31:55 -08:00
# 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
2018-07-13 13:56:30 -07:00
# https://bugs.debian.org/830696 (apt uses gpgv by default in newer releases, rather than gpg)
RUN set -ex; \
apt-get update; \
if ! which gpg; then \
apt-get install -y --no-install-recommends gnupg; \
fi ; \
rm -rf /var/lib/apt/lists/*
2016-05-17 12:48:56 -07:00
# add gosu for easy step-down from root
2020-04-16 00:06:26 -07:00
# https://github.com/tianon/gosu/releases
2021-09-03 11:19:09 +10:00
ENV GOSU_VERSION 1.14
2020-04-16 00:06:26 -07:00
RUN set -eux; \
2017-11-13 15:55:56 -08:00
apt-get update; \
2021-03-14 13:15:35 +11:00
DEBIAN_FRONTEND = noninteractive apt-get install -y --no-install-recommends ca-certificates; \
2021-03-12 12:18:37 +11:00
savedAptMark = " $( apt-mark showmanual) " ; \
apt-get install -y --no-install-recommends wget; \
2017-11-13 15:55:56 -08:00
rm -rf /var/lib/apt/lists/*; \
dpkgArch = " $( dpkg --print-architecture | awk -F- '{ print $NF }' ) " ; \
wget -O /usr/local/bin/gosu " https://github.com/tianon/gosu/releases/download/ $GOSU_VERSION /gosu- $dpkgArch " ; \
wget -O /usr/local/bin/gosu.asc " https://github.com/tianon/gosu/releases/download/ $GOSU_VERSION /gosu- $dpkgArch .asc " ; \
export GNUPGHOME = " $( mktemp -d) " ; \
2019-07-03 07:51:44 -07:00
gpg --batch --keyserver hkps://keys.openpgp.org --recv-keys B42F6819007F00F88E364FD4036A9C25BF357DD4; \
2017-11-13 15:55:56 -08:00
gpg --batch --verify /usr/local/bin/gosu.asc /usr/local/bin/gosu; \
2020-04-16 00:06:26 -07:00
gpgconf --kill all; \
rm -rf " $GNUPGHOME " /usr/local/bin/gosu.asc; \
apt-mark auto '.*' > /dev/null; \
[ -z " $savedAptMark " ] || apt-mark manual $savedAptMark > /dev/null; \
apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant= false; \
2017-11-13 15:55:56 -08:00
chmod +x /usr/local/bin/gosu; \
2020-04-16 00:06:26 -07:00
gosu --version; \
gosu nobody true
2016-01-29 09:45:15 -08:00
2015-08-11 16:39:56 -07:00
RUN mkdir /docker-entrypoint-initdb.d
2021-05-25 14:11:26 +10:00
# install "libjemalloc2" as it offers better performance in some cases. Use with LD_PRELOAD
2018-07-13 13:56:30 -07:00
# install "pwgen" for randomizing passwords
2018-07-17 13:40:05 -07:00
# install "tzdata" for /usr/share/zoneinfo/
2020-02-15 18:03:15 +00:00
# install "xz-utils" for .sql.xz docker-entrypoint-initdb.d files
2021-05-20 22:48:10 +02:00
# install "zstd" for .sql.zst docker-entrypoint-initdb.d files
2019-07-11 20:00:40 +02:00
RUN set -ex; \
apt-get update; \
2021-03-12 13:11:00 +11:00
DEBIAN_FRONTEND = noninteractive apt-get install -y --no-install-recommends \
2021-05-25 14:11:26 +10:00
libjemalloc2 \
2016-07-22 12:35:55 -07:00
pwgen \
2018-07-17 13:40:05 -07:00
tzdata \
2020-02-15 18:03:15 +00:00
xz-utils \
2021-05-20 22:48:10 +02:00
zstd \
2019-07-11 20:00:40 +02:00
; \
rm -rf /var/lib/apt/lists/*
2016-05-17 12:48:56 -07:00
2021-07-02 18:53:42 +10:00
ARG GPG_KEYS = 177F4010FE56CA3336300305F1656F24C74CD1D8
2018-07-13 13:56:30 -07:00
# pub rsa4096 2016-03-30 [SC]
# 177F 4010 FE56 CA33 3630 0305 F165 6F24 C74C D1D8
# uid [ unknown] MariaDB Signing Key <signing-key@mariadb.org>
# sub rsa4096 2016-03-30 [E]
2021-03-12 13:43:34 +11:00
2017-01-10 13:54:55 -08:00
RUN set -ex; \
export GNUPGHOME = " $( mktemp -d) " ; \
2021-07-02 18:53:42 +10:00
for key in $GPG_KEYS ; do \
2021-06-23 13:50:06 +10:00
gpg --batch --keyserver keyserver.ubuntu.com --recv-keys " $key " ; \
2017-01-10 13:54:55 -08:00
done ; \
2021-07-02 18:53:42 +10:00
gpg --batch --export $GPG_KEYS > /etc/apt/trusted.gpg.d/mariadb.gpg; \
2018-07-18 13:22:52 -07:00
command -v gpgconf > /dev/null && gpgconf --kill all || :; \
2021-06-29 14:05:55 +10:00
rm -fr " $GNUPGHOME " ; \
2017-01-10 13:54:55 -08:00
apt-key list
2016-03-04 19:36:48 +01:00
2018-07-17 14:19:00 -07:00
# bashbrew-architectures:%%ARCHES%%
2021-03-12 13:43:34 +11:00
ARG MARIADB_MAJOR = %%MARIADB_MAJOR%%
2021-07-13 10:37:18 +10:00
ENV MARIADB_MAJOR $MARIADB_MAJOR
2021-03-12 13:43:34 +11:00
ARG MARIADB_VERSION = %%MARIADB_VERSION%%
2021-07-13 10:37:18 +10:00
ENV MARIADB_VERSION $MARIADB_VERSION
2019-03-01 13:15:13 -08:00
# release-status:%%MARIADB_RELEASE_STATUS%%
2021-03-02 15:00:11 +11:00
# (https://downloads.mariadb.org/rest-api/mariadb/)
2014-11-24 15:31:55 -08:00
2021-03-12 13:43:34 +11:00
# Allowing overriding of REPOSITORY, a URL that includes suite and component for testing and Enterprise Versions
2021-07-13 10:27:06 +10:00
ARG REPOSITORY = "http://archive.mariadb.org/mariadb-%%MARIADB_VERSION_BASIC%%/repo/ubuntu/ %%SUITE%% main"
2021-03-12 13:43:34 +11:00
2018-07-13 13:56:30 -07:00
RUN set -e; \
2021-07-13 10:27:06 +10:00
echo " deb ${ REPOSITORY } " > /etc/apt/sources.list.d/mariadb.list; \
2018-07-13 13:56:30 -07:00
{ \
2015-04-22 10:03:02 -06:00
echo 'Package: *' ; \
echo 'Pin: release o=MariaDB' ; \
echo 'Pin-Priority: 999' ; \
} > /etc/apt/preferences.d/mariadb
# add repository pinning to make sure dependencies from this MariaDB repo are preferred over Debian dependencies
# libmariadbclient18 : Depends: libmysqlclient18 (= 5.5.42+maria-1~wheezy) but 5.5.43-0+deb7u1 is to be installed
2014-11-24 15:31:55 -08:00
2015-08-11 16:39:56 -07:00
# the "/var/lib/mysql" stuff here is because the mysql-server postinst doesn't have an explicit way to disable the mysql_install_db codepath besides having a database already "configured" (ie, stuff in /var/lib/mysql/mysql)
# also, we set debconf keys to make APT a little quieter
2018-07-13 13:56:30 -07:00
RUN set -ex; \
{ \
2017-07-27 17:21:39 -07:00
echo " mariadb-server- $MARIADB_MAJOR " mysql-server/root_password password 'unused' ; \
echo " mariadb-server- $MARIADB_MAJOR " mysql-server/root_password_again password 'unused' ; \
2018-07-13 13:56:30 -07:00
} | debconf-set-selections; \
apt-get update; \
2019-06-03 16:32:38 -07:00
# mariadb-backup is installed at the same time so that `mysql-common` is only installed once from just mariadb repos
2022-06-08 12:53:27 +10:00
apt-get install -y \
" mariadb-server= $MARIADB_VERSION " mariadb-backup socat \
2018-07-13 13:56:30 -07:00
; \
rm -rf /var/lib/apt/lists/*; \
2016-05-17 12:48:56 -07:00
# purge and re-create /var/lib/mysql with appropriate ownership
2018-07-13 13:56:30 -07:00
rm -rf /var/lib/mysql; \
mkdir -p /var/lib/mysql /var/run/mysqld; \
chown -R mysql:mysql /var/lib/mysql /var/run/mysqld; \
2016-05-17 12:48:56 -07:00
# 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
2018-07-13 13:56:30 -07:00
chmod 777 /var/run/mysqld; \
2015-08-11 16:39:56 -07:00
# comment out a few problematic configuration values
2018-07-13 13:56:30 -07:00
find /etc/mysql/ -name '*.cnf' -print0 \
2020-06-24 10:15:02 -07:00
| xargs -0 grep -lZE '^(bind-address|log|user\s)' \
| xargs -rt -0 sed -Ei 's/^(bind-address|log|user\s)/#&/' ; \
2015-08-11 16:39:56 -07:00
# don't reverse lookup hostnames, they are usually another container
2021-06-09 19:54:42 +10:00
# Issue #327 Correct order of reading directories /etc/mysql/mariadb.conf.d before /etc/mysql/conf.d (mount-point per documentation)
if [ ! -L /etc/mysql/my.cnf ] ; then sed -i -e '/includedir/i[mariadb]\nskip-host-cache\nskip-name-resolve\n' /etc/mysql/my.cnf; \
# 10.5+
else sed -i -e '/includedir/ {N;s/\(.*\)\n\(.*\)/[mariadbd]\nskip-host-cache\nskip-name-resolve\n\n\2\n\1/}' \
/etc/mysql/mariadb.cnf; fi
2014-11-24 15:31:55 -08:00
VOLUME /var/lib/mysql
2022-01-31 15:27:25 +11:00
COPY healthcheck.sh /usr/local/bin/healthcheck.sh
2016-05-17 12:48:56 -07:00
COPY docker-entrypoint.sh /usr/local/bin/
2016-05-19 07:52:19 -07:00
RUN ln -s usr/local/bin/docker-entrypoint.sh / # backwards compat
2016-05-17 12:48:56 -07:00
ENTRYPOINT [ "docker-entrypoint.sh" ]
2014-11-24 15:31:55 -08:00
EXPOSE 3306
CMD [ "mysqld" ]