forked from biarms/mysql
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile-5.5
127 lines (108 loc) · 6.13 KB
/
Dockerfile-5.5
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
# 1. Define args usable during the pre-build phase
# BUILD_ARCH: the docker architecture, with a tailing '/'. For instance, "arm64v8/"
ARG BUILD_ARCH
# Changed from original - end: don't inherit from debian:jessie, because mysql-server-5.7 don't exist on debian:jessie arm apt-get repo
FROM ${BUILD_ARCH}ubuntu:trusty
# Changed from original - end
# Changed from original - start: add one line to override the maintainer
MAINTAINER Brother In Arms <[email protected]>
# Changed from original - end
# 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
# Changed from original - start: upgrade to 1.12 (was inspired by https://github.com/rothgar/rpi-wordpress/blob/master/mysql/Dockerfile)
# add gosu for easy step-down from root
ENV GOSU_VERSION=1.12
RUN set -x \
&& apt-get update && apt-get install -y --no-install-recommends ca-certificates wget \
&& wget -O /usr/local/bin/gosu "https://github.com/tianon/gosu/releases/download/$GOSU_VERSION/gosu-$(dpkg --print-architecture | awk -F- '{ print $NF }')" \
&& chmod +x /usr/local/bin/gosu \
&& gosu nobody true \
&& apt-get purge -y --auto-remove wget \
&& rm -rf /var/lib/apt/lists/*
# Changed from original - end: upgrade to 1.12 and don't check asc file (was inspired by https://github.com/rothgar/rpi-wordpress/blob/master/mysql/Dockerfile)
RUN mkdir /docker-entrypoint-initdb.d
# RUN cat /etc/apt/sources.list
# RUN cat /etc/apt/sources.list.d/ubuntu-esm-infra-trusty.list
RUN apt-get update && apt-get install -y --no-install-recommends \
# for MYSQL_RANDOM_ROOT_PASSWORD
pwgen \
# for mysql_ssl_rsa_setup
openssl \
# FATAL ERROR: please install the following Perl modules before executing /usr/local/mysql/scripts/mysql_install_db:
# File::Basename
# File::Copy
# Sys::Hostname
# Data::Dumper
perl \
&& rm -rf /var/lib/apt/lists/*
# RUN set -ex; \
# # gpg: key 5072E1F5: public key "MySQL Release Engineering <[email protected]>" imported
# key='A4A9406876FCBD3C456770C88C718D3B5072E1F5'; \
# export GNUPGHOME="$(mktemp -d)"; \
# gpg --keyserver ha.pool.sks-keyservers.net --recv-keys "$key"; \
# gpg --export "$key" > /etc/apt/trusted.gpg.d/mysql.gpg; \
# rm -r "$GNUPGHOME"; \
# apt-key list > /dev/null
# Changed from original - start: MYSQL_VERSION and ENV MYSQL_MAJOR 5.7 are not used anymore
# ENV MYSQL_MAJOR 5.7
# ENV MYSQL_VERSION 5.7.21-1debian8
# Changed from original - end
# Changed from original - start: mysql-server is found in official ubuntu repo
# RUN echo "deb http://repo.mysql.com/apt/debian/ jessie mysql-${MYSQL_MAJOR}" > /etc/apt/sources.list.d/mysql.list
# Changed from original - end
# 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
RUN { \
# Changed from original - start: mysql-community-server is named mysql-server on ubuntu
echo mysql-server mysql-server/data-dir select ''; \
# Changed from original: root-pass is names root_password on ubuntu
echo mysql-server mysql-server/root_password password 'changeit'; \
# Changed from original: re-root-pass is names root_password_again on ubuntu
echo mysql-server mysql-server/root_password_again password 'changeit'; \
echo mysql-server mysql-server/remove-test-db select false; \
# Changed from original - end
} | debconf-set-selections \
&& apt-get update && apt-get install -y "mysql-server" && 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
&& find /etc/mysql/ -name '*.cnf' -print0 \
| xargs -0 grep -lZE '^(bind-address|log)' \
| xargs -rt -0 sed -Ei 's/^(bind-address|log)/#&/' \
# don't reverse lookup hostnames, they are usually another container
&& echo '[mysqld]\nskip-host-cache\nskip-name-resolve' > /etc/mysql/conf.d/docker.cnf
VOLUME /var/lib/mysql
# ENV MYSQL_MAJOR 5.5
# ADD https://raw.githubusercontent.com/docker-library/mysql/master/${MYSQL_MAJOR}/docker-entrypoint.sh /usr/local/bin/
# RUN chmod +x /usr/local/bin/docker-entrypoint.sh \
# && chown mysql:mysql /usr/local/bin/docker-entrypoint.sh \
# && ln -s usr/local/bin/docker-entrypoint.sh /entrypoint.sh # backwards compat
# # Changed from original - start: on ubuntu, /usr/local/bin is not in the path
# ENTRYPOINT ["/usr/local/bin/docker-entrypoint.sh"]
# # Changed from original - end: on ubuntu, /usr/local/bin is not in the path
# ADD https://raw.githubusercontent.com/docker-library/mysql/master/${MYSQL_MAJOR}/docker-entrypoint.sh /usr/local/bin/
COPY entrypoint-5.5.sh /usr/local/bin/docker-entrypoint.sh
RUN chmod +x /usr/local/bin/docker-entrypoint.sh \
&& chown mysql:mysql /usr/local/bin/docker-entrypoint.sh \
&& ln -s usr/local/bin/docker-entrypoint.sh /entrypoint.sh # backwards compat
ENTRYPOINT ["/usr/local/bin/docker-entrypoint.sh"]
# Changed from original - start: add tzdata package to fix a timezone blocking issue at startup
# (according to https://serverfault.com/questions/511821/how-to-update-install-zoneinfo-timezone-database-on-centos)
# To solve this error message:
# There were fatal errors during processing of zoneinfo directory
# make: *** [test] Error 1
RUN ln -fs /usr/share/zoneinfo/Europe/Paris /etc/localtime && apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y tzdata && rm -rf /var/lib/apt/lists/*
# Changed from original - end
EXPOSE 3306
CMD ["mysqld"]
# Changed from original: next line was added
# (inspired by https://github.com/rothgar/rpi-wordpress/blob/master/mysql/Dockerfile)
ADD my-small.cnf /etc/mysql/conf.d/my.cnf
ARG VCS_REF
ARG BUILD_DATE
LABEL \
org.label-schema.build-date=${BUILD_DATE} \
org.label-schema.vcs-ref=${VCS_REF} \
org.label-schema.vcs-url="https://github.com/biarms/mysql"