|
| 1 | +# vim:set ft=dockerfile: |
| 2 | +FROM ubuntu:xenial |
| 3 | + |
| 4 | +# add our user and group first to make sure their IDs get assigned consistently, regardless of whatever dependencies get added |
| 5 | +RUN groupadd -r mysql && useradd -r -g mysql mysql |
| 6 | + |
| 7 | +# https://bugs.debian.org/830696 (apt uses gpgv by default in newer releases, rather than gpg) |
| 8 | +RUN set -ex; \ |
| 9 | +apt-get update; \ |
| 10 | +if ! which gpg; then \ |
| 11 | +apt-get install -y --no-install-recommends gnupg; \ |
| 12 | +fi; \ |
| 13 | +# Ubuntu includes "gnupg" (not "gnupg2", but still 2.x), but not dirmngr, and gnupg 2.x requires dirmngr |
| 14 | +# so, if we're not running gnupg 1.x, explicitly install dirmngr too |
| 15 | +if ! gpg --version | grep -q '^gpg (GnuPG) 1\.'; then \ |
| 16 | + apt-get install -y --no-install-recommends dirmngr; \ |
| 17 | +fi; \ |
| 18 | +rm -rf /var/lib/apt/lists/* |
| 19 | + |
| 20 | +# add gosu for easy step-down from root |
| 21 | +ENV GOSU_VERSION 1.10 |
| 22 | +RUN set -ex; \ |
| 23 | +\ |
| 24 | +fetchDeps=' \ |
| 25 | +ca-certificates \ |
| 26 | +wget \ |
| 27 | +'; \ |
| 28 | +apt-get update; \ |
| 29 | +apt-get install -y --no-install-recommends $fetchDeps; \ |
| 30 | +rm -rf /var/lib/apt/lists/*; \ |
| 31 | +\ |
| 32 | +dpkgArch="$(dpkg --print-architecture | awk -F- '{ print $NF }')"; \ |
| 33 | +wget -O /usr/local/bin/gosu "https://github.com/tianon/gosu/releases/download/$GOSU_VERSION/gosu-$dpkgArch"; \ |
| 34 | +wget -O /usr/local/bin/gosu.asc "https://github.com/tianon/gosu/releases/download/$GOSU_VERSION/gosu-$dpkgArch.asc"; \ |
| 35 | +\ |
| 36 | +# verify the signature |
| 37 | +export GNUPGHOME="$(mktemp -d)"; \ |
| 38 | +gpg --batch --keyserver ha.pool.sks-keyservers.net --recv-keys B42F6819007F00F88E364FD4036A9C25BF357DD4; \ |
| 39 | +gpg --batch --verify /usr/local/bin/gosu.asc /usr/local/bin/gosu; \ |
| 40 | +command -v gpgconf > /dev/null && gpgconf --kill all || :; \ |
| 41 | +rm -r "$GNUPGHOME" /usr/local/bin/gosu.asc; \ |
| 42 | +\ |
| 43 | +chmod +x /usr/local/bin/gosu; \ |
| 44 | +# verify that the binary works |
| 45 | +gosu nobody true; \ |
| 46 | +\ |
| 47 | +apt-get purge -y --auto-remove $fetchDeps |
| 48 | + |
| 49 | +RUN mkdir /docker-entrypoint-initdb.d |
| 50 | + |
| 51 | +# install "pwgen" for randomizing passwords |
| 52 | +# install "apt-transport-https" for Percona's repo (switched to https-only) |
| 53 | +RUN apt-get update && apt-get install -y --no-install-recommends \ |
| 54 | +apt-transport-https ca-certificates \ |
| 55 | +tzdata \ |
| 56 | +pwgen \ |
| 57 | +&& rm -rf /var/lib/apt/lists/* |
| 58 | + |
| 59 | +RUN { \ |
| 60 | +echo "mariadb-server-10.6" mysql-server/root_password password 'unused'; \ |
| 61 | +echo "mariadb-server-10.6" mysql-server/root_password_again password 'unused'; \ |
| 62 | +} | debconf-set-selections |
| 63 | + |
| 64 | +RUN apt-get update -y |
| 65 | +RUN apt-get install -y software-properties-common wget |
| 66 | +#RUN apt-key adv --recv-keys --keyserver keyserver.ubuntu.com 0xcbcb082a1bb943db |
| 67 | +#RUN apt-key adv --recv-keys --keyserver ha.pool.sks-keyservers.net F1656F24C74CD1D8 |
| 68 | +#RUN echo 'deb http://yum.mariadb.org/galera/repo/deb xenial main' > /etc/apt/sources.list.d/galera-test-repo.list |
| 69 | +#RUN apt-get update -y |
| 70 | + |
| 71 | +RUN apt-get install -y curl libdbi-perl rsync socat libnuma1 libaio1 zlib1g-dev libreadline5 libjemalloc1 libsnappy1v5 libcrack2 |
| 72 | + |
| 73 | +#RUN apt-get install -y galera3 |
| 74 | + |
| 75 | +COPY *.deb /root/ |
| 76 | +RUN chmod 777 /root/* |
| 77 | + |
| 78 | +RUN dpkg --install /root/mysql-common* |
| 79 | +RUN dpkg --install /root/mariadb-common* |
| 80 | +RUN dpkg -R --unpack /root/ |
| 81 | +RUN apt-get install -f -y |
| 82 | +RUN ls -lrt /etc/mysql |
| 83 | +RUN ls -lrt /etc/mysql/mariadb.conf.d |
| 84 | +RUN rm -rf /var/lib/apt/lists/* \ |
| 85 | + && sed -ri 's/^user\s/#&/' /etc/mysql/my.cnf /etc/mysql/mariadb.conf.d/*.cnf \ |
| 86 | + && rm -rf /var/lib/mysql && mkdir -p /var/lib/mysql /var/run/mysqld \ |
| 87 | + && chown -R mysql:mysql /var/lib/mysql /var/run/mysqld \ |
| 88 | + && chmod 777 /var/run/mysqld \ |
| 89 | + && find /etc/mysql/ -name '*.cnf' -print0 \ |
| 90 | + | xargs -0 grep -lZE '^(bind-address|log)' \ |
| 91 | + | xargs -rt -0 sed -Ei 's/^(bind-address|log)/#&/' \ |
| 92 | + && echo '[mysqld]\nskip-host-cache\nskip-name-resolve' > /etc/mysql/mariadb.conf.d/docker.cnf |
| 93 | + |
| 94 | +VOLUME /var/lib/mysql |
| 95 | + |
| 96 | +COPY docker-entrypoint.sh /usr/local/bin/ |
| 97 | +RUN ln -s usr/local/bin/docker-entrypoint.sh / # backwards compat |
| 98 | +ENTRYPOINT ["docker-entrypoint.sh"] |
| 99 | + |
| 100 | +EXPOSE 3306 |
| 101 | +CMD ["mysqld"] |
| 102 | + |
0 commit comments