forked from cytopia-deprecated/docker-mysql-5.7
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
158 lines (135 loc) · 4.31 KB
/
Dockerfile
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
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
##
## MySQL 5.7
##
FROM centos:7
MAINTAINER "cytopia" <[email protected]>
##
## Labels
##
LABEL \
name="cytopia's MySQL 5.7 Image" \
image="mysql-5.7" \
vendor="cytopia" \
license="MIT" \
build-date="2017-09-28"
###
### Envs
###
# Version
# Check for Updates:
# https://dev.mysql.com/downloads/repo/yum/
ENV YUM_REPO_URL="https://dev.mysql.com/get/mysql57-community-release-el7-10.noarch.rpm "
# User/Group
ENV MY_USER="mysql"
ENV MY_GROUP="mysql"
ENV MY_UID="48"
ENV MY_GID="48"
# Files
ENV MYSQL_BASE_INCL="/etc/my.cnf.d"
ENV MYSQL_CUST_INCL1="/etc/mysql/conf.d"
ENV MYSQL_CUST_INCL2="/etc/mysql/docker-default.d"
ENV MYSQL_DEF_DAT="/var/lib/mysql"
ENV MYSQL_DEF_LOG="/var/log/mysql"
ENV MYSQL_DEF_PID="/var/run/mysqld"
ENV MYSQL_DEF_SCK="/var/sock/mysqld"
ENV MYSQL_LOG_SLOW="${MYSQL_DEF_LOG}/slow.log"
ENV MYSQL_LOG_ERROR="${MYSQL_DEF_LOG}/error.log"
ENV MYSQL_LOG_QUERY="${MYSQL_DEF_LOG}/query.log"
###
### Install
###
RUN groupadd -g ${MY_GID} -r ${MY_GROUP} && \
adduser ${MY_USER} -u ${MY_UID} -M -s /sbin/nologin -g ${MY_GROUP}
RUN \
yum -y install epel-release && \
rpm -ivh ${YUM_REPO_URL} && \
yum-config-manager --disable mysql55-community && \
yum-config-manager --disable mysql56-community && \
yum-config-manager --enable mysql57-community && \
yum-config-manager --disable mysql80-community && \
yum clean all
RUN yum -y update && yum -y install \
mysql-community-server
RUN \
yum -y autoremove && \
yum clean metadata && \
yum clean all && \
yum -y install hostname && \
yum clean all
##
## Configure
##
RUN \
rm -rf ${MYSQL_BASE_INCL} && \
rm -rf ${MYSQL_CUST_INCL1} && \
rm -rf ${MYSQL_CUST_INCL2} && \
rm -rf ${MYSQL_DEF_DAT} && \
rm -rf ${MYSQL_DEF_SCK} && \
rm -rf ${MYSQL_DEF_PID} && \
rm -rf ${MYSQL_DEF_LOG} && \
\
mkdir -p ${MYSQL_BASE_INCL} && \
mkdir -p ${MYSQL_CUST_INCL1} && \
mkdir -p ${MYSQL_CUST_INCL2} && \
mkdir -p ${MYSQL_DEF_DAT} && \
mkdir -p ${MYSQL_DEF_SCK} && \
mkdir -p ${MYSQL_DEF_PID} && \
mkdir -p ${MYSQL_DEF_LOG} && \
\
chown -R ${MY_USER}:${MY_GROUP} ${MYSQL_BASE_INCL} && \
chown -R ${MY_USER}:${MY_GROUP} ${MYSQL_CUST_INCL1} && \
chown -R ${MY_USER}:${MY_GROUP} ${MYSQL_CUST_INCL2} && \
chown -R ${MY_USER}:${MY_GROUP} ${MYSQL_DEF_DAT} && \
chown -R ${MY_USER}:${MY_GROUP} ${MYSQL_DEF_SCK} && \
chown -R ${MY_USER}:${MY_GROUP} ${MYSQL_DEF_PID} && \
chown -R ${MY_USER}:${MY_GROUP} ${MYSQL_DEF_LOG} && \
\
chmod 0775 ${MYSQL_BASE_INCL} && \
chmod 0775 ${MYSQL_CUST_INCL1} && \
chmod 0775 ${MYSQL_CUST_INCL2} && \
chmod 0775 ${MYSQL_DEF_DAT} && \
chmod 0775 ${MYSQL_DEF_SCK} && \
chmod 0775 ${MYSQL_DEF_PID} && \
chmod 0775 ${MYSQL_DEF_LOG}
RUN \
echo "[client]" > /etc/my.cnf && \
echo "socket = ${MYSQL_DEF_SCK}/mysqld.sock" >> /etc/my.cnf && \
\
echo "[mysql]" >> /etc/my.cnf && \
echo "socket = ${MYSQL_DEF_SCK}/mysqld.sock" >> /etc/my.cnf && \
\
echo "[mysqld]" >> /etc/my.cnf && \
echo "skip-host-cache" >> /etc/my.cnf && \
echo "skip-name-resolve" >> /etc/my.cnf && \
echo "datadir = ${MYSQL_DEF_DAT}" >> /etc/my.cnf && \
echo "user = ${MY_USER}" >> /etc/my.cnf && \
echo "port = 3306" >> /etc/my.cnf && \
echo "bind-address = 0.0.0.0" >> /etc/my.cnf && \
echo "socket = ${MYSQL_DEF_SCK}/mysqld.sock" >> /etc/my.cnf && \
echo "pid-file = ${MYSQL_DEF_PID}/mysqld.pid" >> /etc/my.cnf && \
echo "general_log_file = ${MYSQL_LOG_QUERY}" >> /etc/my.cnf && \
echo "slow_query_log_file = ${MYSQL_LOG_SLOW}" >> /etc/my.cnf && \
echo "log-error = ${MYSQL_LOG_ERROR}" >> /etc/my.cnf && \
echo "!includedir ${MYSQL_BASE_INCL}/" >> /etc/my.cnf && \
echo "!includedir ${MYSQL_CUST_INCL1}/" >> /etc/my.cnf && \
echo "!includedir ${MYSQL_CUST_INCL2}/" >> /etc/my.cnf
##
## Bootstrap Scipts
##
COPY ./scripts/docker-entrypoint.sh /
##
## Ports
##
EXPOSE 3306
##
## Volumes
##
VOLUME /var/lib/mysql
VOLUME /var/log/mysql
VOLUME /var/sock/mysqld
VOLUME /etc/mysql/conf.d
VOLUME /etc/mysql/docker-default.d
##
## Entrypoint
##
ENTRYPOINT ["/docker-entrypoint.sh"]